Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase2 ------- partial 7 #111

Merged
merged 46 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
dbcb665
added description to the video url field in project creation form iss…
NdibeRaymond Jan 6, 2021
0543e70
new deployment changes (#62)
NdibeRaymond Jan 6, 2021
53626bb
increased pagination limit from 6 to 20 (#63)
NdibeRaymond Jan 7, 2021
8c252de
phase2 patial ----- 2 (#65)
NdibeRaymond Jan 7, 2021
2cc4ca5
Merge branch 'master' into phase2
NdibeRaymond Jan 7, 2021
8fcdce5
fixed bug that occurs when user submit google drive video link (#72)
NdibeRaymond Jan 10, 2021
b754415
separated docker-compose files into dev and prod in preparation for C…
NdibeRaymond Jan 17, 2021
31be594
Merge branch 'master' into phase2
NdibeRaymond Jan 17, 2021
4f0052b
separated docker-compose files into dev and prod in preparation for C…
NdibeRaymond Jan 18, 2021
2d8a73f
Code Refactor (#67)
NdibeRaymond Jan 20, 2021
75c30b6
Merge branch 'master' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Jan 22, 2021
dbd07c9
Merge branch 'phase2' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Jan 22, 2021
ee5c092
Customized form submission error (#80)
NdibeRaymond Jan 22, 2021
396a2ca
fixed issue #34: Increased upload image size, added image compression…
NdibeRaymond Jan 22, 2021
44ebc8c
Removed line behind dob field label on the signup page (#81)
NdibeRaymond Jan 22, 2021
7c717d3
fixed issue #52: Added help text to project creation desc field (#82)
NdibeRaymond Jan 22, 2021
ee19d3e
fixed issue #59: Added projects, followers and following links to pro…
NdibeRaymond Jan 22, 2021
b39d701
added functionality to show creators we are following (#83)
NdibeRaymond Jan 22, 2021
2b802e8
Merge branch 'master' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Jan 24, 2021
5643b35
First Iteration of CI/CD workflow (#89)
NdibeRaymond Jan 25, 2021
965fd44
Second Iteration of CI/CD (#90)
NdibeRaymond Jan 25, 2021
193dadd
third iteration of CI/CD (#91)
NdibeRaymond Jan 25, 2021
fc199eb
Update build_deploy_backend.yml
NdibeRaymond Jan 25, 2021
68d997a
Fourth Iteration of CI/CD (#92)
NdibeRaymond Jan 25, 2021
35c2d4a
Added functionalities to update and delete projects (#88)
NdibeRaymond Jan 27, 2021
58d30e0
Merge branch 'phase2' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Jan 27, 2021
f513f53
Internationalization (#74)
NdibeRaymond Jan 28, 2021
d089d3f
Added feature for editing and deleting of user profiles (#97)
NdibeRaymond Jan 28, 2021
80b9790
Merge branch 'master' into phase2
NdibeRaymond Jan 28, 2021
8728f81
Merge branch 'phase2' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Jan 28, 2021
86dbe7b
prettified
NdibeRaymond Jan 28, 2021
f3a2335
phase2 ----- partial 5 ---- patch
NdibeRaymond Jan 28, 2021
8651198
Merge branch 'master' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Jan 29, 2021
884275a
Reduce error page svg size (#99)
NdibeRaymond Feb 4, 2021
bc5f7f3
Merge branch 'phase2' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Feb 5, 2021
96a26d8
Merge branch 'master' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Feb 8, 2021
963eaa9
Improved project creation form (#100)
NdibeRaymond Feb 8, 2021
d4f3aad
Added option to add phone number during registration or update of cre…
NdibeRaymond Feb 8, 2021
3bbcbf2
Merge branch 'master' into phase2
NdibeRaymond Feb 8, 2021
fd3cb08
Merge branch 'master' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Feb 9, 2021
2c2251e
Merge branch 'master' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Feb 9, 2021
20739a7
Merge branch 'master' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Feb 9, 2021
c4ad409
Merge branch 'phase2' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Feb 10, 2021
7403265
Merge branch 'master' of https://github.com/unstructuredstudio/zubhub…
NdibeRaymond Feb 15, 2021
2043148
UI improvement (#108)
NdibeRaymond Feb 17, 2021
e756df0
implemented feature to store robohash profile images on our server to…
NdibeRaymond Feb 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions zubhub_backend/zubhub/creators/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_app_config = 'creators.apps.CreatorsConfig'
3 changes: 3 additions & 0 deletions zubhub_backend/zubhub/creators/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

class CreatorsConfig(AppConfig):
name = 'creators'

def ready(self):
import creators.signals
9 changes: 5 additions & 4 deletions zubhub_backend/zubhub/creators/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from django.utils.text import slugify
from django.contrib.auth.models import AbstractUser
from django.db import models, transaction
from django.dispatch import Signal
from .managers import PhoneNumberManager
from .utils import user_phone
from . import signals

try:
from allauth.account import app_settings as allauth_settings
Expand Down Expand Up @@ -51,7 +51,8 @@ class Creator(AbstractUser):
projects_count = models.IntegerField(blank=True, default=0)

def save(self, *args, **kwargs):
self.avatar = 'https://robohash.org/{0}'.format(self.username)
if not self.avatar:
self.avatar = 'https://robohash.org/{0}'.format(self.username)
self.followers_count = self.followers.count()
self.following_count = self.following.count()
self.projects_count = self.projects.count()
Expand Down Expand Up @@ -152,7 +153,7 @@ def confirm(self, request):
if not self.phone_number.verified:
phone_number = self.phone_number
get_adapter(request).confirm_phone(request, phone_number)
signals.phone_confirmed.send(
Signal().send(
sender=self.__class__,
request=request,
phone_number=phone_number,
Expand All @@ -161,7 +162,7 @@ def confirm(self, request):

def send(self, request=None, signup=False):
get_adapter(request).send_confirmation_text(request, self, signup)
signals.phone_confirmation_sent.send(
Signal().send(
sender=self.__class__,
request=request,
confirmation=self,
Expand Down
1 change: 1 addition & 0 deletions zubhub_backend/zubhub/creators/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def validate_phone(self, phone):
return phone

def update(self, user, validated_data):
print("update was called")
creator = super().update(user, validated_data)
phone_number = PhoneNumber.objects.filter(user=creator)
email_address = EmailAddress.objects.filter(user=creator)
Expand Down
13 changes: 11 additions & 2 deletions zubhub_backend/zubhub/creators/signals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from django.dispatch import Signal

from django.db.models.signals import pre_delete
from django.dispatch import Signal, receiver
from .models import Creator
# from django.contrib.auth import get_user_model
from projects.tasks import delete_image_from_DO_space
# Provides the arguments "request", "phone_number"
phone_confirmed = Signal()
# Provides the arguments "request", "confirmation", "signup"
phone_confirmation_sent = Signal()


@receiver(pre_delete, sender=Creator)
def creator_to_be_deleted(sender, instance, **kwargs):
delete_image_from_DO_space.delay(
"zubhub", instance.avatar.split(".com/")[1])
34 changes: 33 additions & 1 deletion zubhub_backend/zubhub/creators/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from celery import shared_task
from random import uniform

import boto3
import requests
from django.conf import settings
# from django.contrib.auth import get_user_model
try:
from allauth.account.adapter import get_adapter
except ImportError:
Expand All @@ -14,3 +17,32 @@ def send_text(self, phone, template_name, ctx):
except Exception as e:
raise self.retry(exc=e, countdown=int(
uniform(2, 4) ** self.request.retries))


@shared_task(name="creators.tasks.upload_image_to_DO_space", bind=True, acks_late=True, max_retries=10)
def upload_image_to_DO_space(self, bucket, key, user_id):
from creators.models import Creator

creator = Creator.objects.filter(id=user_id)

session = boto3.session.Session()
client = session.client('s3',
region_name=settings.DOSPACE_REGION,
endpoint_url=settings.DOSPACE_ENDPOINT_URL,
aws_access_key_id=settings.DOSPACE_ACCESS_KEY_ID,
aws_secret_access_key=settings.DOSPACE_ACCESS_SECRET_KEY)

try:
res = requests.get(creator[0].avatar)
res = client.put_object(Bucket=bucket, Key=key,
Body=res.content, ContentType=res.headers["Content-Type"], ACL="public-read")
if res.get("ResponseMetadata") and res["ResponseMetadata"]["HTTPStatusCode"] == 200:

avatar = 'https://{0}.{1}/{2}'.format(
bucket, settings.DOSPACE_ENDPOINT_URL.split("https://")[1], key)

creator.update(avatar=avatar)

except Exception as e:
raise self.retry(exc=e, countdown=int(
uniform(2, 4) ** self.request.retries))
24 changes: 24 additions & 0 deletions zubhub_backend/zubhub/creators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from django.utils.encoding import force_str
from django.utils.http import base36_to_int, int_to_base36, urlencode
from django.contrib.auth import get_user_model
from projects.tasks import delete_image_from_DO_space
from creators.tasks import upload_image_to_DO_space


try:
Expand Down Expand Up @@ -144,6 +146,28 @@ def send_phone_confirmation(request, user, signup=False, phone=None):
assert phone_number


def process_avatar(oldInstance, newInstance):

key = 'avatar/{0}'.format(newInstance.username)

if oldInstance and oldInstance.username != newInstance.username:
newInstance.avatar = 'https://robohash.org/{0}'.format(
newInstance.username)
newInstance.save()

if(oldInstance.avatar.find(".com") > 0):

delete_image_from_DO_space.delay(
"zubhub", oldInstance.avatar.split(".com/")[1])

upload_image_to_DO_space.delay(
'zubhub', key, newInstance.id)

elif not oldInstance:

upload_image_to_DO_space.delay(
'zubhub', key, newInstance.id)

# def sync_user_email_addresses(user):
# """
# Keep user.email in sync with user.emailaddress_set.
Expand Down
6 changes: 3 additions & 3 deletions zubhub_backend/zubhub/creators/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .permissions import IsOwner
from .models import Location
from .pagination import CreatorNumberPagination
from .utils import perform_send_phone_confirmation, perform_send_email_confirmation
from .utils import perform_send_phone_confirmation, perform_send_email_confirmation, process_avatar

from .models import PhoneConfirmationHMAC

Expand All @@ -36,14 +36,13 @@ class UserProfileAPIView(RetrieveAPIView):
lookup_field = "username"
permission_classes = [AllowAny]

# perform_send_phone_confirmation


class RegisterCreatorAPIView(RegisterView):
serializer_class = CustomRegisterSerializer

def perform_create(self, serializer):
creator = super().perform_create(serializer)
process_avatar(None, creator)
perform_send_phone_confirmation(
self.request._request, creator, signup=True)
return creator
Expand Down Expand Up @@ -87,6 +86,7 @@ def perform_update(self, serializer):

perform_send_email_confirmation(
self.request._request, creator[0], signup=True)
process_avatar(self.request.user, creator[0])
return response

def get_object(self):
Expand Down
3 changes: 1 addition & 2 deletions zubhub_backend/zubhub/projects/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

class CommentSerializer(serializers.ModelSerializer):
id = serializers.UUIDField(read_only=True)
creator = serializers.SlugRelatedField(
slug_field='username', read_only=True)
creator = CreatorSerializer(read_only=True)
created_on = serializers.DateTimeField(read_only=True)

class Meta:
Expand Down
15 changes: 8 additions & 7 deletions zubhub_frontend/zubhub/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
"login": "Login",
"signup": "Sign Up",
"createProject": "Create Project",
"projects": "Projects",
"profile": "My Profile",
"projects": "My Projects",
"followers": "Followers",
"following": "Following",
"savedProjects": "Saved Projects",
"savedProjects": "Bookmarks",
"logout": "Logout"
},
"errors": {
Expand Down Expand Up @@ -259,7 +260,7 @@
},
"video": {
"label": "Let's add a video",
"topHelperText": "It's ok if you don't have them",
"topHelperText": "It's ok if you don't have them, add images instead",
"bottomHelperText": "YouTube, Vimeo, Google Drive links are supported",
"errors": {
"shouldBeVideoUrl": "you are required to submit a video url here",
Expand Down Expand Up @@ -374,10 +375,10 @@
"followingCount": "Following",
"about": {
"label": "About Me",
"placeholder": "You will be able to change this next month 😀!"
"placeholder": "tell us more about you by clicking on the edit button at the top of the page 😀!"
},
"projects": {
"label": "Latest projects of",
"label": "Latest projects",
"viewAll": "View all >>"
},
"tooltips": {
Expand Down Expand Up @@ -416,14 +417,14 @@
},
"email": {
"label": "Email",
"disabledHelperText": "to edit this field mail admin@unstrucutred.studio",
"disabledHelperText": "to edit this field mail admin@unstructured.studio",
"errors": {
"invalid": "invalid email"
}
},
"phone": {
"label": "Phone",
"disabledHelperText": "to edit this field mail admin@unstrucutred.studio",
"disabledHelperText": "to edit this field mail admin@unstructured.studio",
"errors": {
"invalid": "Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed."
}
Expand Down
15 changes: 8 additions & 7 deletions zubhub_frontend/zubhub/public/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
"login": "लॉग इन करें",
"signup": "साइन अप करें",
"createProject": "प्रोजेक्ट बनाएं",
"savedProjects": "बचाए गए प्रोजेक्ट",
"projects": "परियोजनाओं",
"profile": "मेरी प्रोफाइल",
"projects": "मेरे प्रोजेक्ट्स",
"followers": "अनुयायियों",
"following": "निम्नलिखित",
"savedProjects": "बुकमार्क",
"logout": "लॉग आउट"
},
"errors": {
Expand Down Expand Up @@ -259,7 +260,7 @@
},
"video": {
"label": "आइए एक वीडियो जोड़ें",
"topHelperText": "यह ठीक है अगर आपके पास उन्हें नहीं है",
"topHelperText": "यह ठीक है अगर आपके पास उन्हें नहीं है, इसके बजाय चित्र जोड़ें",
"bottomHelperText": "YouTube, Vimeo, Google Drive लिंक समर्थित हैं",
"errors": {
"shouldBeVideoUrl": "आपको यहां एक वीडियो url प्रस्तुत करना आवश्यक है",
Expand Down Expand Up @@ -374,10 +375,10 @@
"followingCount": "निम्नलिखित",
"about": {
"label": "मेरे बारे में",
"placeholder": "आप इसे अगले महीने बदल पाएंगे 😀!"
"placeholder": "पृष्ठ के शीर्ष पर स्थित संपादित करें बटन पर क्लिक करके हमें अपने बारे में और बताएं 😀!"
},
"projects": {
"label": "की नवीनतम परियोजनाएँ",
"label": "नयी परियोजनाएं",
"viewAll": "सभी देखें >>"
},
"tooltips": {
Expand Down Expand Up @@ -416,14 +417,14 @@
},
"email": {
"label": "ईमेल",
"disabledHelperText": "इस फ़ील्ड मेल को संपादित करने के लिए admin@unstrucutred.studio",
"disabledHelperText": "इस फ़ील्ड मेल को संपादित करने के लिए admin@unstructured.studio",
"errors": {
"invalid": "अमान्य ईमेल"
}
},
"phone": {
"label": "फ़ोन",
"disabledHelperText": "इस फ़ील्ड मेल को संपादित करने के लिए admin@unstrucutred.studio",
"disabledHelperText": "इस फ़ील्ड मेल को संपादित करने के लिए admin@unstructured.studio",
"errors": {
"invalid": "फ़ोन नंबर प्रारूप में दर्ज किया जाना चाहिए: '+999999999'। 15 अंकों तक की अनुमति।"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const styles = theme => ({
primaryButtonStyle: {
backgroundColor: '#00B8C4',
borderRadius: 15,
borderRadius: 30,
color: 'white',
'&:hover': {
backgroundColor: '#03848C',
},
},
secondaryButtonStyle: {
borderRadius: 15,
borderRadius: 30,
backgroundColor: 'white',
color: '#00B8C4',
'&:hover': {
Expand All @@ -17,7 +17,7 @@ const styles = theme => ({
},
},
dangerButtonStyle: {
borderRadius: 15,
borderRadius: 30,
backgroundColor: 'rgb(220, 0, 78)',
color: 'white',
'&:hover': {
Expand All @@ -35,6 +35,11 @@ const styles = theme => ({
},
},
},
customButtonStyle: {
[theme.breakpoints.up('1600')]: {
fontSize: '1.5rem',
},
},
fullWidth: {
width: '100%',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const styles = theme => ({
filter:
"progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffcc00', endColorstr='#ffffff', GradientType=0 )",
alignItems: 'center',
flexDirection: 'column',
justifyContent: 'center',
},
mediaBoxStyle: {
Expand Down Expand Up @@ -84,10 +83,14 @@ const styles = theme => ({
fontSize: '1.3rem',
},
descriptionStyle: {
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
flexGrow: 1,
'& p': {
overflow: 'hidden',
textOverflow: 'ellipsis',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
},
},
creatorBoxStyle: {
marginTop: '0.5em',
Expand Down
Loading