Skip to content

Commit

Permalink
Merge pull request #305 from ropable/master
Browse files Browse the repository at this point in the history
Additional processing rules for emailed referrals
  • Loading branch information
ropable authored Feb 19, 2024
2 parents c66687b + 646b575 commit 77e3f49
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 148 deletions.
2 changes: 1 addition & 1 deletion kustomize/overlays/prod/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ patches:
- path: geoserver_service_patch.yaml
images:
- name: ghcr.io/dbca-wa/prs
newTag: 2.5.39
newTag: 2.5.40
23 changes: 14 additions & 9 deletions prs2/harvester/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,26 @@ def harvest_referral(modeladmin, request, queryset):
actions = [harvest_referral]
date_hierarchy = 'received'
list_display = (
'received', 'from_email', 'subject', 'harvested', 'attachments',
'received', 'from_email', 'subject', 'harvested', 'attachments_url',
'referral_url', 'processed')
raw_id_fields = ('referral',)
search_fields = ('subject',)
readonly_fields = ['email_uid', 'to_email', 'from_email', 'subject', 'body', 'processed', 'log']

def attachments(self, instance):
return instance.emailattachment_set.count()
def attachments_url(self, instance):
if not instance.emailattachment_set.exists():
return ""
count = instance.emailattachment_set.count()
url = reverse("admin:harvester_emailattachment_changelist")
return mark_safe(f"<a href='{url}?emailed_referral_id__exact={instance.pk}'>{count}</a>")
attachments_url.short_description = 'attachments'

def referral_url(self, instance):
if not instance.referral:
return ''
url = reverse('admin:referral_referral_change', args=[instance.referral.pk])
return mark_safe('<a href="{}">{}</a>'.format(url, instance.referral.pk))
referral_url.short_description = 'Referral'
return ""
url = reverse("admin:referral_referral_change", args=[instance.referral.pk])
return mark_safe(f"<a href='{url}'>{instance.referral.pk}</a>")
referral_url.short_description = "Referral"


@admin.register(EmailAttachment)
Expand All @@ -55,14 +60,14 @@ class EmailAttachmentAdmin(admin.ModelAdmin):

def emailed_referral_url(self, instance):
url = reverse('admin:harvester_emailedreferral_change', args=[instance.emailed_referral.pk])
return mark_safe('<a href="{}">{}</a>'.format(url, instance.emailed_referral))
return mark_safe(f'<a href="{url}">{instance.emailed_referral}</a>')
emailed_referral_url.short_description = 'Emailed referral'

def record_url(self, instance):
if not instance.record:
return ''
url = reverse('admin:referral_record_change', args=[instance.record.pk])
return mark_safe('<a href="{}">{}</a>'.format(url, instance.record.pk))
return mark_safe(f'<a href="{url}">{instance.record.pk}</a>')
record_url.short_description = 'Record'


Expand Down
Loading

0 comments on commit 77e3f49

Please sign in to comment.