Skip to content

Commit

Permalink
Rename organization_email -> email in organization profile
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankApiyo committed Oct 2, 2024
1 parent 1dfcd5d commit 1c80a5e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
6 changes: 3 additions & 3 deletions onadata/apps/api/migrations/0008_org_profile_email.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Generated by Django 4.2.14 on 2024-10-01 08:01
"""
Add organization_email field to the organization profile model
Add email field to the organization profile model
"""
from django.db import migrations, models


class Migration(migrations.Migration):
"""
Add organization_email field to the organization profile model
Add email field to the organization profile model
"""

dependencies = [
Expand All @@ -17,7 +17,7 @@ class Migration(migrations.Migration):
operations = [
migrations.AddField(
model_name="organizationprofile",
name="organization_email",
name="email",
field=models.EmailField(
blank=True, max_length=254, verbose_name="email address"
),
Expand Down
7 changes: 1 addition & 6 deletions onadata/apps/api/models/organization_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,14 @@ class Meta:
is_organization = models.BooleanField(default=True)
# Other fields here
creator = models.ForeignKey(User, on_delete=models.CASCADE)
organization_email = models.EmailField(_("email address"), blank=True)
email = models.EmailField(_("email address"), blank=True)

def __str__(self):
return f"{self.name}[{self.user.username}]"

def save(self, *args, **kwargs): # pylint: disable=arguments-differ
super().save(*args, **kwargs)

@property
def email(self):
"organization email"
return self.organization_email

def remove_user_from_organization(self, user):
"""Removes a user from all teams/groups in the organization.
Expand Down
2 changes: 1 addition & 1 deletion onadata/apps/api/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def create_organization_object(org_name, creator, attrs=None):
organization=attrs.get("organization", ""),
home_page=attrs.get("home_page", ""),
twitter=attrs.get("twitter", ""),
organization_email=email,
email=email,
)
return profile

Expand Down
2 changes: 1 addition & 1 deletion onadata/libs/serializers/organization_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def update(self, instance, validated_data):
instance.user.last_name = last_name

if "email" in validated_data:
instance.organization_email = validated_data.pop("email")
instance.email = validated_data.pop("email")

instance.user.save()
return super().update(instance, validated_data)
Expand Down

0 comments on commit 1c80a5e

Please sign in to comment.