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
 | 
			
		||||
    form = UserOrgAffiliationRequestInlineForm
 | 
			
		||||
    verbose_name_plural = _("User is looking to be affiliated to these Organizations")
 | 
			
		||||
 | 
			
		||||
    def formfield_for_foreignkey(self, db_field, request, **kwargs):
 | 
			
		||||
        if db_field.name == "org":
 | 
			
		||||
            kwargs["queryset"] = Organization.handleref.filter(status="ok").order_by(
 | 
			
		||||
                "name"
 | 
			
		||||
            )
 | 
			
		||||
        return super(UserOrgAffiliationRequestInline, self).formfield_for_foreignkey(
 | 
			
		||||
            db_field, request, **kwargs
 | 
			
		||||
        )
 | 
			
		||||
    raw_id_fields = ("org",)
 | 
			
		||||
    autocomplete_lookup_fields = {
 | 
			
		||||
        "fk": ["org"],
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class InternetExchangeAdminForm(StatusForm):
 | 
			
		||||
@@ -776,6 +771,10 @@ class PartnershipAdmin(admin.ModelAdmin):
 | 
			
		||||
    list_display = ("org_name", "level", "status")
 | 
			
		||||
    readonly_fields = ("status", "org_name")
 | 
			
		||||
    form = PartnershipAdminForm
 | 
			
		||||
    raw_id_fields = ("org",)
 | 
			
		||||
    autocomplete_lookup_fields = {
 | 
			
		||||
        "fk": ["org"],
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    def org_name(self, obj):
 | 
			
		||||
        if not obj.org:
 | 
			
		||||
@@ -960,6 +959,12 @@ class IXLanPrefixAdmin(SoftDeleteAdmin):
 | 
			
		||||
    list_filter = (StatusFilter,)
 | 
			
		||||
    form = StatusForm
 | 
			
		||||
 | 
			
		||||
    raw_id_fields = ("ixlan",)
 | 
			
		||||
    autocomplete_lookup_fields = {
 | 
			
		||||
        "fk": ["ixlan"],
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def ix(self, obj):
 | 
			
		||||
        return obj.ixlan.ix
 | 
			
		||||
 | 
			
		||||
@@ -990,9 +995,9 @@ class NetworkIXLanAdmin(SoftDeleteAdmin):
 | 
			
		||||
    list_filter = (StatusFilter,)
 | 
			
		||||
    form = StatusForm
 | 
			
		||||
 | 
			
		||||
    raw_id_fields = ("network",)
 | 
			
		||||
    raw_id_fields = ("network","ixlan")
 | 
			
		||||
    autocomplete_lookup_fields = {
 | 
			
		||||
        "fk": ["network",],
 | 
			
		||||
        "fk": ["network","ixlan"],
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    def ix(self, obj):
 | 
			
		||||
@@ -1050,6 +1055,11 @@ class VerificationQueueAdmin(ModelAdminWithUrlActions):
 | 
			
		||||
    readonly_fields = ("created", "view", "extra")
 | 
			
		||||
    search_fields = ("item",)
 | 
			
		||||
 | 
			
		||||
    raw_id_fields = ("user",)
 | 
			
		||||
    autocomplete_lookup_fields = {
 | 
			
		||||
        "fk": ["user"],
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    def get_search_results(self, request, queryset, search_term):
 | 
			
		||||
        # queryset, use_distinct = super(VerificationQueueAdmin, self).get_search_results(request, queryset, search_term)
 | 
			
		||||
        if not search_term or search_term == "":
 | 
			
		||||
 
 | 
			
		||||
@@ -538,6 +538,18 @@ class Organization(pdb_models.OrganizationBase):
 | 
			
		||||
    def __unicode__(self):
 | 
			
		||||
        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
 | 
			
		||||
    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
 | 
			
		||||
        # 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):
 | 
			
		||||
        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)
 | 
			
		||||
        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):
 | 
			
		||||
        """
 | 
			
		||||
        Removes all user -> org affiliation requests for this user
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user