Skip to content

Commit

Permalink
- Show Contact Roles again on the Profile Admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jun 26, 2019
1 parent 96605c4 commit 40dd120
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def clean(self):
"""
Make sure there is only one poc and author per resource
"""
if (self.role == self.resource.poc_role) or (
self.role == self.resource.metadata_author_role):
if (self.role == self.resource.poc) or (
self.role == self.resource.metadata_author):
contacts = self.resource.contacts.filter(
contactrole__role=self.role)
if contacts.count() == 1:
Expand All @@ -90,7 +90,7 @@ def clean(self):
raise ValidationError(
'There can be only one %s for a given resource' %
self.role)
if self.contact.user is None:
if self.contact is None:
# verify that any unbound contact is only associated to one
# resource
bounds = ContactRole.objects.filter(contact=self.contact).count()
Expand Down
7 changes: 7 additions & 0 deletions geonode/people/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
from django.conf import settings
from django.core.exceptions import PermissionDenied

from geonode.base.models import ContactRole

from .models import Profile
from .forms import ProfileCreationForm, ProfileChangeForm

Expand All @@ -44,6 +46,10 @@
sensitive_post_parameters_m = method_decorator(sensitive_post_parameters())


class ContactRolesInline(admin.TabularInline):
model = ContactRole


class ProfileAdmin(admin.ModelAdmin):
list_display = ('id', 'username', 'organization',)
search_fields = ('username', 'organization', 'profile', )
Expand Down Expand Up @@ -76,6 +82,7 @@ class ProfileAdmin(admin.ModelAdmin):
search_fields = ('username', 'first_name', 'last_name', 'email')
ordering = ('username',)
filter_horizontal = ('groups', 'user_permissions',)
inlines = [ContactRolesInline]

def get_fieldsets(self, request, obj=None):
if not obj:
Expand Down

0 comments on commit 40dd120

Please sign in to comment.