From e81658fa22d5ee14e975d5ae01c4030ed87f9154 Mon Sep 17 00:00:00 2001 From: Tudor Amariei Date: Tue, 12 Nov 2024 13:52:25 +0200 Subject: [PATCH] Add NGO Group to NGO user --- backend/hub/forms.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/hub/forms.py b/backend/hub/forms.py index 3e85f8e0..6895ede0 100644 --- a/backend/hub/forms.py +++ b/backend/hub/forms.py @@ -3,6 +3,7 @@ from django import forms from django.conf import settings from django.contrib.auth import get_user_model +from django.contrib.auth.models import Group from django.core.exceptions import PermissionDenied, ValidationError from django.urls import reverse_lazy from django.utils.safestring import mark_safe @@ -10,6 +11,7 @@ from django_recaptcha.fields import ReCaptchaField from sentry_sdk import capture_message +from accounts.models import NGO_GROUP from civil_society_vote.common.messaging import send_email from hub.models import FLAG_CHOICES, PHASE_CHOICES, Candidate, City, Domain, FeatureFlag, Organization @@ -132,6 +134,8 @@ def save(self, commit=True): raise ValidationError(_("Organization already exists.")) user = UserModel.objects.get(pk=user_id) + user.groups.add(Group.objects.get(name=NGO_GROUP)) + organization = Organization.objects.create(ngohub_org_id=ngohub_org_id) organization.users.add(user)