mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
@@ -525,15 +525,10 @@ class UserOrgAffiliationRequestInline(admin.TabularInline):
|
|||||||
extra = 0
|
extra = 0
|
||||||
form = UserOrgAffiliationRequestInlineForm
|
form = UserOrgAffiliationRequestInlineForm
|
||||||
verbose_name_plural = _("User is looking to be affiliated to these Organizations")
|
verbose_name_plural = _("User is looking to be affiliated to these Organizations")
|
||||||
|
raw_id_fields = ("org",)
|
||||||
def formfield_for_foreignkey(self, db_field, request, **kwargs):
|
autocomplete_lookup_fields = {
|
||||||
if db_field.name == "org":
|
"fk": ["org"],
|
||||||
kwargs["queryset"] = Organization.handleref.filter(status="ok").order_by(
|
}
|
||||||
"name"
|
|
||||||
)
|
|
||||||
return super(UserOrgAffiliationRequestInline, self).formfield_for_foreignkey(
|
|
||||||
db_field, request, **kwargs
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class InternetExchangeAdminForm(StatusForm):
|
class InternetExchangeAdminForm(StatusForm):
|
||||||
@@ -776,6 +771,10 @@ class PartnershipAdmin(admin.ModelAdmin):
|
|||||||
list_display = ("org_name", "level", "status")
|
list_display = ("org_name", "level", "status")
|
||||||
readonly_fields = ("status", "org_name")
|
readonly_fields = ("status", "org_name")
|
||||||
form = PartnershipAdminForm
|
form = PartnershipAdminForm
|
||||||
|
raw_id_fields = ("org",)
|
||||||
|
autocomplete_lookup_fields = {
|
||||||
|
"fk": ["org"],
|
||||||
|
}
|
||||||
|
|
||||||
def org_name(self, obj):
|
def org_name(self, obj):
|
||||||
if not obj.org:
|
if not obj.org:
|
||||||
@@ -960,6 +959,12 @@ class IXLanPrefixAdmin(SoftDeleteAdmin):
|
|||||||
list_filter = (StatusFilter,)
|
list_filter = (StatusFilter,)
|
||||||
form = StatusForm
|
form = StatusForm
|
||||||
|
|
||||||
|
raw_id_fields = ("ixlan",)
|
||||||
|
autocomplete_lookup_fields = {
|
||||||
|
"fk": ["ixlan"],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def ix(self, obj):
|
def ix(self, obj):
|
||||||
return obj.ixlan.ix
|
return obj.ixlan.ix
|
||||||
|
|
||||||
@@ -990,9 +995,9 @@ class NetworkIXLanAdmin(SoftDeleteAdmin):
|
|||||||
list_filter = (StatusFilter,)
|
list_filter = (StatusFilter,)
|
||||||
form = StatusForm
|
form = StatusForm
|
||||||
|
|
||||||
raw_id_fields = ("network",)
|
raw_id_fields = ("network","ixlan")
|
||||||
autocomplete_lookup_fields = {
|
autocomplete_lookup_fields = {
|
||||||
"fk": ["network",],
|
"fk": ["network","ixlan"],
|
||||||
}
|
}
|
||||||
|
|
||||||
def ix(self, obj):
|
def ix(self, obj):
|
||||||
@@ -1050,6 +1055,11 @@ class VerificationQueueAdmin(ModelAdminWithUrlActions):
|
|||||||
readonly_fields = ("created", "view", "extra")
|
readonly_fields = ("created", "view", "extra")
|
||||||
search_fields = ("item",)
|
search_fields = ("item",)
|
||||||
|
|
||||||
|
raw_id_fields = ("user",)
|
||||||
|
autocomplete_lookup_fields = {
|
||||||
|
"fk": ["user"],
|
||||||
|
}
|
||||||
|
|
||||||
def get_search_results(self, request, queryset, search_term):
|
def get_search_results(self, request, queryset, search_term):
|
||||||
# queryset, use_distinct = super(VerificationQueueAdmin, self).get_search_results(request, queryset, search_term)
|
# queryset, use_distinct = super(VerificationQueueAdmin, self).get_search_results(request, queryset, search_term)
|
||||||
if not search_term or search_term == "":
|
if not search_term or search_term == "":
|
||||||
|
|||||||
@@ -538,6 +538,18 @@ class Organization(pdb_models.OrganizationBase):
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def related_label(self):
|
||||||
|
"""
|
||||||
|
Used by grappelli autocomplete for representation
|
||||||
|
|
||||||
|
Since grappelli doesnt easily allow us to filter status
|
||||||
|
during autocomplete lookup, we make sure the objects
|
||||||
|
are marked accordingly in the result
|
||||||
|
"""
|
||||||
|
if self.status == "deleted":
|
||||||
|
return "[DELETED] {}".format(self)
|
||||||
|
return "{}".format(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def search_result_name(self):
|
def search_result_name(self):
|
||||||
"""
|
"""
|
||||||
@@ -1628,6 +1640,22 @@ class IXLan(pdb_models.IXLanBase):
|
|||||||
# return Network.handleref.filter(id__in=[i.network_id for i in
|
# return Network.handleref.filter(id__in=[i.network_id for i in
|
||||||
# q]).filter(status="ok")
|
# q]).filter(status="ok")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def autocomplete_search_fields():
|
||||||
|
"""
|
||||||
|
Used by grappelli autocomplete to determine what
|
||||||
|
fields to search in
|
||||||
|
"""
|
||||||
|
return ("ix__name__icontains",)
|
||||||
|
|
||||||
|
|
||||||
|
def related_label(self):
|
||||||
|
"""
|
||||||
|
Used by grappelli autocomplete for representation
|
||||||
|
"""
|
||||||
|
return "{} IXLan ({})".format(self.ix.name, self.id)
|
||||||
|
|
||||||
|
|
||||||
def nsp_has_perms_PUT(self, user, request):
|
def nsp_has_perms_PUT(self, user, request):
|
||||||
return validate_PUT_ownership(user, self, request.data, ["ix"])
|
return validate_PUT_ownership(user, self, request.data, ["ix"])
|
||||||
|
|
||||||
@@ -2883,6 +2911,22 @@ class User(AbstractBaseUser, PermissionsMixin):
|
|||||||
group = Group.objects.get(id=settings.USER_GROUP_ID)
|
group = Group.objects.get(id=settings.USER_GROUP_ID)
|
||||||
return group in self.groups.all()
|
return group in self.groups.all()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def autocomplete_search_fields():
|
||||||
|
"""
|
||||||
|
Used by grappelli autocomplete to determine what
|
||||||
|
fields to search in
|
||||||
|
"""
|
||||||
|
return ("username__icontains", "email__icontains", "last_name__icontains")
|
||||||
|
|
||||||
|
|
||||||
|
def related_label(self):
|
||||||
|
"""
|
||||||
|
Used by grappelli autocomplete for representation
|
||||||
|
"""
|
||||||
|
return "{} <{}> ({})".format(self.username, self.email, self.id)
|
||||||
|
|
||||||
|
|
||||||
def flush_affiliation_requests(self):
|
def flush_affiliation_requests(self):
|
||||||
"""
|
"""
|
||||||
Removes all user -> org affiliation requests for this user
|
Removes all user -> org affiliation requests for this user
|
||||||
|
|||||||
Reference in New Issue
Block a user