Skip to content
Snippets Groups Projects
Unverified Commit 083dddf5 authored by Torma Kristóf's avatar Torma Kristóf :alien:
Browse files

user is not serializable, use dict instead

parent f1828760
No related branches found
Tags 1.4.3
No related merge requests found
Pipeline #43314 passed
......@@ -11,4 +11,5 @@ def create_profile(backend, user, response, *args, **kwargs):
except exceptions.ObjectDoesNotExist:
models.Profile.objects.create(user=user)
if user.email is not None:
registration.delay(user)
registration.delay(
{'last_name': user.last_name, 'first_name': user.first_name, 'email': user.email})
......@@ -12,4 +12,8 @@ class Command(BaseCommand):
parser.add_argument('receiver_email', type=str)
def handle(self, *args, **options):
send_out_mail_task.delay(options['subject'], options['message'], options['SENDER_EMAIL'], options['receiver_email'])
send_out_mail_task.delay(
options['subject'],
options['message'],
options['SENDER_EMAIL'],
options['receiver_email'])
......@@ -59,9 +59,13 @@ class ProfileSerializer_User(serializers.ModelSerializer):
new_role = validated_data.get('role', instance.role)
if instance.role != new_role:
if new_role == 'Student':
admitted.delay(instance.user)
admitted.delay({'last_name': instance.user.last_name,
'first_name': instance.user.first_name,
'email': instance.user.email})
if new_role == 'Denied':
denied.delay(instance.user)
denied.delay({'last_name': instance.user.last_name,
'first_name': instance.user.first_name,
'email': instance.user.email})
return super().update(instance, validated_data)
def get_full_name(self, obj):
......@@ -118,9 +122,13 @@ class ProfileSerializer_Staff(serializers.ModelSerializer):
new_role = validated_data.get('role', instance.role)
if instance.role != new_role:
if new_role == 'Student':
admitted.delay(instance.user)
admitted.delay({'last_name': instance.user.last_name,
'first_name': instance.user.first_name,
'email': instance.user.email})
if new_role == 'Denied':
denied.delay(instance.user)
denied.delay({'last_name': instance.user.last_name,
'first_name': instance.user.first_name,
'email': instance.user.email})
return super().update(instance, validated_data)
def get_full_name(self, obj):
......
......@@ -11,7 +11,7 @@ HOMEWORK_LINK = os.getenv(
def get_full_name(user):
return user.last_name + " " + user.first_name
return user['last_name'] + " " + user['first_name']
def read_email(name):
......@@ -46,7 +46,7 @@ def registration(user):
subject = "KSZKépzés regisztráció"
message = read_email('registration.txt')
message = str.format(message % {'name': get_full_name(user)})
send_out_mail(subject, message, SENDER_EMAIL, [user.email, ])
send_out_mail(subject, message, SENDER_EMAIL, [user['email'], ])
@shared_task()
......@@ -54,7 +54,7 @@ def admitted(user):
subject = "Jelentkezés eredménye"
message = read_email('admitted.txt')
message = str.format(message % {'name': get_full_name(user)})
send_out_mail(subject, message, SENDER_EMAIL, [user.email, ])
send_out_mail(subject, message, SENDER_EMAIL, [user['email'], ])
@shared_task()
......@@ -62,7 +62,7 @@ def denied(user):
subject = "Jelentkezés eredménye"
message = read_email('denied.txt')
message = str.format(message % {'name': get_full_name(user)})
send_out_mail(subject, message, SENDER_EMAIL, [user.email, ])
send_out_mail(subject, message, SENDER_EMAIL, [user['email'], ])
@shared_task()
......@@ -75,7 +75,7 @@ def new_homework(user, deadline):
'name': get_full_name(user),
'link': HOMEWORK_LINK,
'deadline': deadline})
send_out_mail(subject, message, SENDER_EMAIL, [user.email, ])
send_out_mail(subject, message, SENDER_EMAIL, [user['email'], ])
@shared_task()
......@@ -90,4 +90,4 @@ def homework_corrected(user, title, accepted):
'link': HOMEWORK_LINK,
'status': status,
'title': title})
send_out_mail(subject, message, SENDER_EMAIL, [user.email, ])
send_out_mail(subject, message, SENDER_EMAIL, [user['email'], ])
......@@ -22,7 +22,10 @@ class TaskSerializer(serializers.ModelSerializer):
role="Student").exclude(
user__email='')
for profile in profiles:
new_homework.delay(profile.user, validated_data.get('deadline'))
new_homework.delay({'last_name': profile.user.last_name,
'first_name': profile.user.first_name,
'email': profile.user.email},
validated_data.get('deadline'))
return self.Meta.model.objects.create(**validated_data)
......@@ -62,10 +65,14 @@ class SolutionSerializer_Student(serializers.ModelSerializer):
if instance.corrected is not True and validated_data.get(
'corrected', instance.corrected) is True:
homework_corrected.delay(
instance.created_by.user,
{
'last_name': instance.created_by.user.last_name,
'first_name': instance.created_by.user.first_name,
'email': instance.created_by.user.email},
instance.task.title,
validated_data.get('accepted', instance.accepted)
)
validated_data.get(
'accepted',
instance.accepted))
return super().update(instance, validated_data)
def create(self, validated_data):
......@@ -106,10 +113,14 @@ class SolutionSerializer_Staff(serializers.ModelSerializer):
if instance.corrected is not True and validated_data.get(
'corrected', instance.corrected) is True:
homework_corrected.delay(
instance.created_by.user,
{
'last_name': instance.created_by.user.last_name,
'first_name': instance.created_by.user.first_name,
'email': instance.created_by.user.email},
instance.task.title,
validated_data.get('accepted', instance.accepted)
)
validated_data.get(
'accepted',
instance.accepted))
return super().update(instance, validated_data)
def create(self, validated_data):
......
......@@ -34,4 +34,4 @@ EMAIL_HOST_PASSWORD = os.getenv('SMTP_PASSWORD')
CELERY_BROKER_URL = os.getenv('CELERY_BROKER_URL')
CELERY_RESULT_BACKEND = os.getenv('CELERY_BROKER_URL')
CSRF_TRUSTED_ORIGINS = [ os.getenv('CSRF_TRUSTED_ORIGINS') ]
CSRF_TRUSTED_ORIGINS = [os.getenv('CSRF_TRUSTED_ORIGINS')]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment