Skip to content

Commit

Permalink
Add NGO Group to NGO user
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Nov 12, 2024
1 parent a6511cf commit e81658f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/hub/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
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
from django.utils.translation import gettext_lazy as _
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

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit e81658f

Please sign in to comment.