added max_connection
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from rest_framework import serializers
|
||||
from rest_framework_gis.serializers import GeoFeatureModelSerializer
|
||||
from sqlalchemy.sql.functions import mode
|
||||
from .models import Location, Location_line, Location_polygon, JpnAdminMainPerf, JpnAdminPerf, JpnSubPerf, Useractions, GifuAreas, RogUser, UserTracks, GoalImages, CheckinImages
|
||||
from .models import Location, Location_line, Location_polygon, JpnAdminMainPerf, JpnAdminPerf, JpnSubPerf, Useractions, GifuAreas, RogUser, UserTracks, GoalImages, CheckinImages,CustomUser
|
||||
from drf_extra_fields.fields import Base64ImageField
|
||||
|
||||
#from django.contrib.auth.models import User
|
||||
@ -171,4 +171,25 @@ class ChangePasswordSerializer(serializers.Serializer):
|
||||
Serializer for password change endpoint.
|
||||
"""
|
||||
old_password = serializers.CharField(required=True)
|
||||
new_password = serializers.CharField(required=True)
|
||||
new_password = serializers.CharField(required=True)
|
||||
|
||||
|
||||
class RegistrationSerializer(serializers.ModelSerializer):
|
||||
password2 = serializers.CharField(style={"input_type": "password"}, write_only=True)
|
||||
|
||||
class Meta:
|
||||
model = CustomUser
|
||||
fields = ['email', 'is_rogaining', 'zekken_number', 'event_code', 'team_name', 'group', 'password', 'password2']
|
||||
extra_kwargs = {
|
||||
'password': {'write_only': True}
|
||||
}
|
||||
|
||||
def save(self):
|
||||
user = CustomUser(email=self.validated_data['email'], is_rogaining=self.validated_data['is_rogaining'], zekken_number=self.validated_data['zekken_number'], event_code=self.validated_data['event_code'], team_name=self.validated_data['team_name'], group=self.validated_data['group'])
|
||||
password = self.validated_data['password']
|
||||
password2 = self.validated_data['password2']
|
||||
if password != password2:
|
||||
raise serializers.ValidationError({'password': 'Passwords must match.'})
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
return user
|
||||
Reference in New Issue
Block a user