email superuser
This commit is contained in:
parent
e60f4b817b
commit
1fc0627ca9
|
|
@ -139,22 +139,27 @@ class UserSerializer(serializers.ModelSerializer):
|
|||
new_email = validated_data.get('email')
|
||||
old_email = instance.email
|
||||
instance = super().update(instance, validated_data)
|
||||
if new_email and new_email != old_email:
|
||||
instance.email_confirmed = False
|
||||
instance.email = old_email
|
||||
instance.unconfirmed_email = new_email
|
||||
instance.save()
|
||||
# Send verification link on user email for change email address
|
||||
if settings.USE_CELERY:
|
||||
tasks.change_email_address.delay(
|
||||
user_id=instance.id,
|
||||
country_code=self.context.get('request').country_code,
|
||||
emails=[validated_data['email'], ])
|
||||
else:
|
||||
tasks.change_email_address(
|
||||
user_id=instance.id,
|
||||
country_code=self.context.get('request').country_code,
|
||||
emails=[validated_data['email'], ])
|
||||
user = self.context['request'].user
|
||||
if not user.is_superuser or not user.is_staff:
|
||||
"""
|
||||
superuser changes email immediately!
|
||||
"""
|
||||
if new_email and new_email != old_email:
|
||||
instance.email_confirmed = False
|
||||
instance.email = old_email
|
||||
instance.unconfirmed_email = new_email
|
||||
instance.save()
|
||||
# Send verification link on user email for change email address
|
||||
if settings.USE_CELERY:
|
||||
tasks.change_email_address.delay(
|
||||
user_id=instance.id,
|
||||
country_code=self.context.get('request').country_code,
|
||||
emails=[validated_data['email'], ])
|
||||
else:
|
||||
tasks.change_email_address(
|
||||
user_id=instance.id,
|
||||
country_code=self.context.get('request').country_code,
|
||||
emails=[validated_data['email'], ])
|
||||
|
||||
subscriptions_handler(subscriptions_list, instance)
|
||||
return instance
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ class NewsStatesView(generics.ListAPIView):
|
|||
'value': state[0],
|
||||
'state_translated': state[1],
|
||||
} for state in models.News.STATE_CHOICES]
|
||||
print(mutated_for_serializer)
|
||||
serializer = self.get_serializer(mutated_for_serializer, many=True)
|
||||
return response.Response(serializer.data)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user