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

Feat/new auth flow fix #1122

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def save_user(self, request, user, form, commit=False):
creator.bio = data.get('bio')
creator.location = location
creator.is_active = is_active
creator.tags.set(data.get('creator_tags'))
creator.save()

Setting(creator=creator, subscribe=data.get("subscribe")).save()
Expand Down
14 changes: 12 additions & 2 deletions zubhub_backend/zubhub/creators/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from django.utils.translation import gettext_lazy as _
import csv
from .admin import badges
from .models import CreatorGroup, Creator, CreatorGroupMembership
from .models import Location, PhoneNumber
from .models import CreatorGroup, Creator, CreatorGroupMembership, Location, PhoneNumber, CreatorTag
from allauth.account.models import EmailAddress
from rest_auth.registration.serializers import RegisterSerializer
from rest_auth.serializers import PasswordResetSerializer
Expand Down Expand Up @@ -199,6 +198,8 @@ class CustomRegisterSerializer(RegisterSerializer):
queryset=Location.objects.all())
bio = serializers.CharField(allow_blank=True, default="", max_length=255)
subscribe = serializers.BooleanField(default=False)
creator_tags = serializers.SlugRelatedField(slug_field='name',
queryset=CreatorTag.objects.all())

def validate_username(self, username):
# Check if the value is a valid email
Expand Down Expand Up @@ -247,13 +248,22 @@ def validate_location(self, location):
raise serializers.ValidationError(_("Location is required"))
return location

def validate_creator_tags(self, creator_tags):
if (len(creator_tags) < 1):
raise serializers.ValidationError(_("Creator tags are required"))
for tag in creator_tags:
if not CreatorTag.objects.filter(name=tag).exists():
raise serializers.ValidationError(_("Invalid creator tag: {}".format(tag)))
return creator_tags

def get_cleaned_data(self):
data_dict = super().get_cleaned_data()
data_dict['phone'] = self.validated_data.get('phone', '')
data_dict['dateOfBirth'] = self.validated_data.get('dateOfBirth', '')
data_dict['location'] = self.validated_data.get('location', '')
data_dict['bio'] = self.validated_data.get('bio', '')
data_dict['subscribe'] = self.validated_data.get('subscribe', '')
data_dict['creator_tags'] = self.validated_data.get('creator_tags', '')

return data_dict

Expand Down
3 changes: 1 addition & 2 deletions zubhub_backend/zubhub/creators/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import csv
from io import StringIO
from django.forms import ValidationError
from django.utils.translation import ugettext_lazy as _
from notifications.models import Notification
Expand Down Expand Up @@ -188,6 +186,7 @@ class RegisterCreatorAPIView(RegisterView):
"location": "string",\n
"bio": "",\n
"subscribe": false\n
"creator_tags": "string",\n
}\n
"""

Expand Down
2 changes: 2 additions & 0 deletions zubhub_frontend/zubhub/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions zubhub_frontend/zubhub/src/views/create_project/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,20 +693,7 @@ export const validationSchema = Yup.object().shape({
// ? false
// : true;
// }),
materials_used: Yup.string()
.max(10000, 'max')
.test('empty', 'required', value => {
let is_empty = true;

value &&
value.split(',').forEach(material => {
if (material) {
is_empty = false;
}
});

return !is_empty;
}),
materials_used: Yup.string().required('required'),
category: Yup.string(),
// tags: Yup.mixed().test('unsupported', 'unsupported', tags => {
// if (tags) {
Expand Down
Loading