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(settings): Mutation for changing address from settings #389

Merged
merged 2 commits into from
Sep 22, 2024
Merged
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
26 changes: 25 additions & 1 deletion users/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,30 @@ def mutate(self, info, notify_on_shift, notify_on_deposit, notify_on_quote):
return UpdateMyEmailSettingsMutation(user=user)


class UpdateMyAddressSettingsMutation(graphene.Mutation):
class Arguments:
study_address = graphene.String()

user = graphene.Field(UserNode)

def mutate(self, info, study_address):
user = info.context.user

study_address = study_address.strip()

if len(study_address) == 0:
raise ValueError("Study address cannot be empty")

if len(study_address) > 64:
raise ValueError("Study address cannot be longer than 64 characters")


study_address = strip_tags(study_address)
user.study_address = study_address
user.save()
return UpdateMyAddressSettingsMutation(user=user)


class AddUserToUserTypeMutation(graphene.Mutation):
class Arguments:
user_id = graphene.ID()
Expand Down Expand Up @@ -611,6 +635,6 @@ class UserMutations(graphene.ObjectType):
update_about_me = UpdateAboutMeMutation.Field()
update_my_allergies = UpdateMyAllergies.Field()
update_my_email_notifications = UpdateMyEmailSettingsMutation.Field()

update_my_address = UpdateMyAddressSettingsMutation.Field()
add_user_to_user_type = AddUserToUserTypeMutation.Field()
remove_user_from_user_type = RemoveUserFromUserTypeMutation.Field()
Loading