Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return self.readonly_fields
@admin.register(models.Record)
class RecordAdmin(admin.ModelAdmin):
list_display = ("id", "identifier", "title",)
inlines = [StyleInline,]
readonly_fields = ('publication_date','modified',)
def get_readonly_fields(self, request, obj=None):
if obj:
return self.readonly_fields + ('identifier',)
return self.readonly_fields
@admin.register(models.Organization)
class OrganizationAdmin(admin.ModelAdmin):
inlines = [CollaboratorInline,]
@admin.register(models.PycswConfig)
class PycswConfigAdmin(admin.ModelAdmin):
#def has_add_permission(self, request):
# return False
def has_delete_permission(self, request, obj=None):
return False
url = models.URLField()
address = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=50, blank=True)
state_or_province = models.CharField(max_length=50, blank=True)
postal_code = models.CharField(max_length=30, blank=True)
country = models.CharField(max_length=50, blank=True)
def __unicode__(self):
return self.short_name
class Collaborator(models.Model):
name = models.CharField(max_length=255)
position = models.CharField(max_length=255)
email = models.EmailField()
organization = models.ForeignKey(Organization,
related_name="collaborators")
url = models.URLField(blank=True)
phone = models.CharField(max_length=50, blank=True)
fax = models.CharField(max_length=50, blank=True)
hours_of_service = models.CharField(max_length=50, blank=True)
contact_instructions = models.CharField(max_length=255, blank=True)
def __unicode__(self):
return "{}({})".format(self.name, self.organization.short_name)
class Record(models.Model):
identifier = models.CharField(
max_length=255, db_index=True, help_text="Maps to pycsw:Identifier")
title = models.CharField(max_length=255, null=True,blank=True,
help_text='Maps to pycsw:Title')
typename = models.CharField(