Skip to content

Commit

Permalink
Merge pull request #432 from dimagi/pkv/add-payment-unit-admin
Browse files Browse the repository at this point in the history
Add PaymentUnit model to admin
  • Loading branch information
pxwxnvermx authored Nov 20, 2024
2 parents 1bd704b + 9fdfd5a commit 464c0a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion commcare_connect/opportunity/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@


admin.site.register(CommCareApp)
admin.site.register(PaymentUnit)
admin.site.register(UserInvite)
admin.site.register(DeliveryType)
admin.site.register(DeliverUnitFlagRules)
Expand Down Expand Up @@ -103,6 +102,7 @@ class CompletedModuleAdmin(admin.ModelAdmin):
@admin.register(UserVisit)
class UserVisitAdmin(admin.ModelAdmin):
list_display = ["deliver_unit", "user", "opportunity", "status"]
search_fields = ["opportunity_access__user__username", "opportunity_access__opportunity__name"]


@admin.register(Assessment)
Expand All @@ -113,6 +113,7 @@ class AssessmentAdmin(admin.ModelAdmin):
@admin.register(CompletedWork)
class CompletedWorkAdmin(admin.ModelAdmin):
list_display = ["get_username", "get_opp_name", "opportunity_access", "payment_unit", "status"]
search_fields = ["opportunity_access__user__username", "opportunity_access__opportunity__name"]

@admin.display(description="Opportunity Name")
def get_opp_name(self, obj):
Expand All @@ -121,3 +122,13 @@ def get_opp_name(self, obj):
@admin.display(description="Username")
def get_username(self, obj):
return obj.opportunity_access.user.username


@admin.register(PaymentUnit)
class PaymentUnitAdmin(admin.ModelAdmin):
list_display = ["name", "get_opp_name"]
search_fields = ["name"]

@admin.display(description="Opportunity Name")
def get_opp_name(self, obj):
return obj.opportunity_access.opportunity.name
3 changes: 3 additions & 0 deletions commcare_connect/opportunity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ class PaymentUnit(models.Model):
null=True,
)

def __str__(self):
return self.name


class DeliverUnit(models.Model):
app = models.ForeignKey(
Expand Down

0 comments on commit 464c0a0

Please sign in to comment.