Skip to content
Browse files

improved address report for admin

  • Loading branch information...
1 parent 0c71ed6 commit eb0a8f0eb977bc51106ad94c319ebf95fa04c788 @evildmp committed
View
4 arkestra_utilities/admin_mixins.py
@@ -61,6 +61,7 @@ def formfield_for_manytomany(self, db_field, request, **kwargs):
return super(AutocompleteMixin, self).formfield_for_manytomany(db_field, request, **kwargs)
+
class InputURLMixin(forms.ModelForm):
input_url = forms.CharField(max_length=255, required = False,
help_text=u"Enter the URL of an external item that you want <strong>automatically</strong> added to the database, but first check carefully using <strong>External URL</strong> (above) to make sure it's really not there.",
@@ -84,6 +85,7 @@ class InputURLMixin(forms.ModelForm):
'importance': ('', {'fields': ('importance',)}),
'url': ('If this is an external item', {'fields': ('external_url', 'input_url',)}),
'slug': ('If this is an internal item', {'fields': ('slug',)}),
- 'location': ('', {'fields': ('get_full_address', 'precise_location', 'access_note',)}),
+ 'location': ('', {'fields': ('precise_location', 'access_note',)}),
+ 'address_report': ('', {'fields': ('address_report',)}),
'email': ('', {'fields': ('email',)}),
}
View
8 arkestra_utilities/generic_models.py
@@ -38,8 +38,12 @@ class Meta:
hosted_by = models.ForeignKey(Entity, default=default_entity_id,
related_name='%(class)s_hosted_events', null=True, blank=True,
help_text=u"The entity responsible for publishing this item")
- publish_to = models.ManyToManyField(Entity, null=True, blank=True, related_name="%(class)s_publish_to",
- help_text=u"Use these sensibly - don't send minor items to the home page, for example")
+ publish_to = models.ManyToManyField(
+ Entity, verbose_name="Also publish to",
+ null=True, blank=True,
+ related_name="%(class)s_publish_to",
+ help_text=u"Use these sensibly - don't send minor items to the home page, for example.",
+ )
please_contact = models.ManyToManyField(Person, related_name='%(class)s_person',
help_text=u"The person to whom enquiries about this should be directed",
null=True, blank=True)
View
18 contacts_and_people/admin.py
@@ -189,16 +189,16 @@ class PersonAdmin(PersonAndEntityAdmin):
# list_editable = ('user',)
filter_horizontal = ('entities',)
prepopulated_fields = {'slug': ('title', 'given_name', 'middle_names', 'surname',)}
- readonly_fields = ['get_full_address',]
+ readonly_fields = ['address_report',]
- def get_full_address(self, instance):
+ def address_report(self, instance):
if instance.building and instance.get_full_address == instance.get_entity.get_full_address:
return "Warning: this Person has the Specify Building field set, probably unnecessarily."
else:
return "%s" % (", ".join(instance.get_full_address)) or "<span class='errors'>Warning: this person has no address.</span>"
- get_full_address.short_description = "Address"
- get_full_address.allow_tags = True
+ address_report.short_description = "Address"
+ address_report.allow_tags = True
name_fieldset = ('Name', {'fields': ('title', 'given_name', 'middle_names', 'surname',),})
override_fieldset = ('Over-ride default output', {
@@ -217,7 +217,7 @@ def get_full_address(self, instance):
tabs = [
('Personal details', {'fieldsets': (name_fieldset, fieldsets["image"])}),
('Contact information', {
- 'fieldsets': (fieldsets["email"], fieldsets["location"], override_fieldset),
+ 'fieldsets': (fieldsets["email"], fieldsets["address_report"], fieldsets["location"], override_fieldset),
'inlines': [PhoneContactInline,]
}),
('Description', {'fieldsets': (description_fieldset,)}),
@@ -318,15 +318,15 @@ class EntityAdmin(PersonAndEntityAdmin):
prepopulated_fields = {
'slug': ('name',)
}
- readonly_fields = ['get_full_address']
+ readonly_fields = ['address_report']
- def get_full_address(self, instance):
+ def address_report(self, instance):
if not instance.abstract_entity:
return "%s" % (", ".join(instance.get_full_address)) or "Warning: this Entity has no address."
else:
return "This is an abstract entity and therefore has no address"
- get_full_address.short_description = "Address"
+ address_report.short_description = "Address"
name_fieldset = ('Name', {'fields': ('name', 'short_name')})
website_fieldset = ('', {'fields': ('website',)})
@@ -365,7 +365,7 @@ def get_full_address(self, instance):
tabs = [
('Basic information', {'fieldsets': (name_fieldset, fieldsets["image"], website_fieldset, entity_hierarchy_fieldset)}),
- ('Location', {'fieldsets': (building_fieldset, fieldsets["location"],)}),
+ ('Location', {'fieldsets': (fieldsets["address_report"], building_fieldset, fieldsets["location"],)}),
('Contact', {
'fieldsets': (fieldsets["email"],),
'inlines': (PhoneContactInline,)
View
1 news_and_events/admin.py
@@ -226,6 +226,7 @@ class EventAdmin(NewsAndEventsAdmin):
# autocomplete fields
related_search_fields = ['hosted_by','parent','building', 'external_url']
+
# the tabs
fieldset_type = ('Type', {'fields': ('type',)},)
fieldset_building = ('Building', {'fields': ('building',)},)

0 comments on commit eb0a8f0

Please sign in to comment.
Something went wrong with that request. Please try again.