Skip to content

Commit 644f81b

Browse files
authored
[Fixes #13935] Added extra_data JSONField on Profile (#13938)
* [Fixes #13935] Added extra_data JSONField in Profile
1 parent 28991ec commit 644f81b

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

geonode/api/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ class Meta:
560560
resource_name = "profiles"
561561
allowed_methods = ["get"]
562562
ordering = ["username", "date_joined"]
563-
excludes = ["is_staff", "password", "is_superuser", "is_active", "last_login"]
563+
excludes = ["is_staff", "password", "is_superuser", "is_active", "last_login", "extra_data"]
564564

565565
filtering = {
566566
"username": ALL,
@@ -615,7 +615,7 @@ class Meta:
615615
resource_name = "owners"
616616
allowed_methods = ["get"]
617617
ordering = ["username", "date_joined"]
618-
excludes = ["is_staff", "password", "is_superuser", "is_active", "last_login"]
618+
excludes = ["is_staff", "password", "is_superuser", "is_active", "last_login", "extra_data"]
619619

620620
filtering = {
621621
"username": ALL,

geonode/people/forms/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ class Meta:
6363
"is_active",
6464
"date_joined",
6565
"language",
66+
"extra_data",
6667
)

geonode/people/migrations/0032_set_contributors_group.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Assign the contributors group to users according to #7364
2-
from django.contrib.auth import get_user_model
3-
from django.contrib.auth.models import Group, Permission
4-
from django.contrib.contenttypes.models import ContentType
5-
62
from django.db import migrations
73
from django.db.migrations.operations import RunPython
84

95

106
def forwards_func(apps, schema_editor):
117
from geonode.groups.conf import settings as groups_settings
8+
Group = apps.get_model("auth", "Group")
9+
Permission = apps.get_model("auth", "Permission")
10+
ContentType = apps.get_model("contenttypes", "ContentType")
11+
Profile = apps.get_model("people", "Profile")
1212

1313
# assign contributors group to users
1414
cont_group, _ = Group.objects.get_or_create(name='contributors')
@@ -21,18 +21,22 @@ def forwards_func(apps, schema_editor):
2121
)
2222
if perm:
2323
cont_group.permissions.add(perm)
24-
# Exclude admins and anonymous user
25-
users_to_update = get_user_model().objects.filter(pk__gt=0)
24+
25+
# Exclude anonymous user
26+
users_to_update = Profile.objects.exclude(username="AnonymousUser")
2627
for user in users_to_update:
2728
registeredmembers_group.user_set.add(user)
29+
# Exclude additional staff and superusers also
2830
for user in users_to_update.exclude(is_staff=True, is_superuser=True):
2931
cont_group.user_set.add(user)
3032

3133
def reverse_func(apps, schema_editor):
3234
# remove contributors group from users
3335
try:
36+
Group = apps.get_model("auth", "Group")
37+
Profile = apps.get_model("people", "Profile")
3438
cont_group = Group.objects.get(name='contributors')
35-
users_to_update = get_user_model().objects.filter(
39+
users_to_update = Profile.objects.filter(
3640
pk__gt=0, is_staff=False, is_superuser=False
3741
)
3842
for user in users_to_update:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 5.2.10 on 2026-02-05 10:24
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("people", "0038_migrate_sha1_passwords"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="profile",
15+
name="extra_data",
16+
field=models.JSONField(
17+
blank=True, default=dict, help_text="additional profile-related attributes", verbose_name="Extra Data"
18+
),
19+
),
20+
]

geonode/people/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ class Profile(AbstractUser):
133133
choices=TIMEZONES,
134134
blank=True,
135135
)
136+
extra_data = models.JSONField(
137+
_("Extra Data"),
138+
blank=True,
139+
default=dict,
140+
help_text=_("additional profile-related attributes"),
141+
)
136142

137143
def __init__(self, *args, **kwargs):
138144
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)