Exemple #1
0
class InvitationAdmin(admin.ModelAdmin):
    date_hierarchy = u'created'
    list_display = [
        u'id',
        u'email',
        u'created',
        decorate(
            lambda o: u'Accepted' if o.is_accepted else u'Expired'
            if o.is_expired else u'Pending' if o.is_pending else u'--',
            short_description=u'State',
        ),
        decorate(
            lambda o: admin_obj_format(
                o.invitor, u'{obj.first_name} {obj.last_name} <{obj.email}>'),
            short_description=u'Invitor',
            admin_order_field=u'invitor__email',
        ),
        decorate(
            lambda o: admin_obj_format(
                o.invitee, u'{obj.first_name} {obj.last_name} <{obj.email}>'),
            short_description=u'Invitee',
            admin_order_field=u'invitee__email',
        ),
    ]
    list_filter = [
        u'created',
        simple_list_filter_factory(u'State', u'state', [
            (u'1', u'Accepted', lambda qs: qs.accepted()),
            (u'2', u'Expired', lambda qs: qs.expired()),
            (u'3', u'Pending', lambda qs: qs.pending()),
        ]),
    ]
    search_fields = [
        u'=id',
        u'email',
        u'invitor__first_name',
        u'invitor__last_name',
        u'invitor__email',
        u'invitee__first_name',
        u'invitee__last_name',
        u'invitee__email',
    ]
    ordering = [
        u'-created',
        u'-id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'invitor',
        u'invitee',
        u'message',
    ]
    inlines = []

    def get_queryset(self, request):
        queryset = super(InvitationAdmin, self).get_queryset(request)
        queryset = queryset.select_related(u'invitor')
        queryset = queryset.select_related(u'invitee')
        return queryset
Exemple #2
0
class BranchAdmin(admin.ModelAdmin):
    date_hierarchy = None
    list_display = [
        u'id',
        decorate(
            lambda o: admin_obj_format(o.inforequest),
            short_description=u'Inforequest',
            admin_order_field=u'inforequest',
        ),
        decorate(
            lambda o: admin_obj_format(o.obligee, u'{obj.name}'),
            short_description=u'Obligee',
            admin_order_field=u'obligee',
        ),
        decorate(
            lambda o: admin_obj_format(o.advanced_by),
            short_description=u'Advanced by',
            admin_order_field=u'advanced_by',
        ),
    ]
    list_filter = [
        simple_list_filter_factory(u'Advanced', u'advanced', [
            (u'1', u'Yes', lambda qs: qs.advanced()),
            (u'2', u'No', lambda qs: qs.main()),
        ]),
    ]
    search_fields = [
        u'=id',
        u'=inforequest__id',
        u'obligee__name',
        u'=advanced_by__id',
    ]
    ordering = [
        u'id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'inforequest',
        u'obligee',
        u'historicalobligee',
        u'advanced_by',
    ]
    inlines = []

    def get_queryset(self, request):
        queryset = super(BranchAdmin, self).get_queryset(request)
        queryset = queryset.select_related(u'inforequest')
        queryset = queryset.select_related(u'obligee')
        queryset = queryset.select_related(u'advanced_by')
        return queryset
Exemple #3
0
class ObligeeAliasAdmin(admin.ModelAdmin):
    date_hierarchy = None
    list_display = [
        u'id',
        decorate(
            lambda o: admin_obj_format(o.obligee, u'{obj.name}'),
            short_description=u'Obligee',
            admin_order_field=u'obligee__name',
        ),
        u'name',
    ]
    list_filter = [
        u'obligee__type',
        u'obligee__status',
    ]
    search_fields = [
        u'=id',
        u'name',
        u'obligee__name',
    ]
    ordering = [
        u'id',
    ]
    exclude = []
    readonly_fields = [
        u'slug',
    ]
    raw_id_fields = [
        u'obligee',
    ]
    inlines = []
Exemple #4
0
class HistoricalObligeeAdmin(admin.ModelAdmin):
    date_hierarchy = u'history_date'
    list_display = [
        u'id',
        decorate(
            lambda o: admin_obj_format(o.history_object),
            short_description=u'Obligee',
            admin_order_field=u'id',
        ),
        u'name',
        u'status',
        u'history_date',
        u'history_type',
    ]
    list_filter = [
        u'status',
        u'history_date',
        u'history_type',
    ]
    search_fields = [
        u'=id',
        u'name',
    ]
    ordering = [
        u'id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'history_user',
    ]
    inlines = []
Exemple #5
0
class DistrictAdmin(admin.ModelAdmin):
    date_hierarchy = None
    list_display = [
        u'id',
        u'name',
        decorate(
            lambda o: admin_obj_format(o.region, u'{obj.name}'),
            short_description=u'Region',
            admin_order_field=u'region__name',
        ),
    ]
    list_filter = [
        u'region__name',
    ]
    search_fields = [
        u'=id',
        u'name',
        u'=region__id',
        u'region__name',
    ]
    ordering = [
        u'id',
    ]
    exclude = []
    readonly_fields = [
        u'slug',
    ]
    raw_id_fields = [
        u'region',
    ]
    inlines = []
Exemple #6
0
class NeighbourhoodAdmin(admin.ModelAdmin):
    date_hierarchy = None
    list_display = [
        u'id',
        u'name',
        decorate(
            lambda o: admin_obj_format(o.municipality, u'{obj.name}'),
            short_description=u'Municipality',
            admin_order_field=u'municipality__name',
        ),
        decorate(
            lambda o: admin_obj_format(o.district, u'{obj.name}'),
            short_description=u'District',
            admin_order_field=u'district__name',
        ),
        decorate(
            lambda o: admin_obj_format(o.region, u'{obj.name}'),
            short_description=u'Region',
            admin_order_field=u'region__name',
        ),
    ]
    list_filter = [
        u'district__name',
        u'region__name',
    ]
    search_fields = [
        u'=id',
        u'name',
        u'=municipality__id',
        u'municipality__name',
        u'=district__id',
        u'district__name',
        u'=region__id',
        u'region__name',
    ]
    ordering = [
        u'id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'municipality',
        u'district',
        u'region',
    ]
    inlines = []
Exemple #7
0
class InforequestDraftAdmin(admin.ModelAdmin):
    date_hierarchy = u'modified'
    list_display = [
        u'id',
        decorate(
            lambda o: admin_obj_format(
                o.applicant, u'{obj.first_name} {obj.last_name} <{obj.email}>'
            ),
            short_description=u'Applicant',
            admin_order_field=u'applicant__email',
        ),
        decorate(
            lambda o: admin_obj_format(o.obligee, u'{obj.name}'),
            short_description=u'Obligee',
            admin_order_field=u'obligee',
        ),
        u'modified',
    ]
    list_filter = [
        u'modified',
    ]
    search_fields = [
        u'=id',
        u'applicant__first_name',
        u'applicant__last_name',
        u'applicant__email',
        u'obligee__name',
    ]
    ordering = [
        u'id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'applicant',
        u'obligee',
    ]
    inlines = []

    def get_queryset(self, request):
        queryset = super(InforequestDraftAdmin, self).get_queryset(request)
        queryset = queryset.select_related(u'applicant')
        queryset = queryset.select_related(u'obligee')
        return queryset
Exemple #8
0
class ActionAdmin(admin.ModelAdmin):
    date_hierarchy = u'created'
    list_display = [
        u'id',
        decorate(
            lambda o: admin_obj_format(o.branch),
            short_description=u'Branch',
            admin_order_field=u'branch',
        ),
        decorate(
            lambda o: admin_obj_format(o.email),
            short_description=u'E-mail',
            admin_order_field=u'email',
        ),
        u'type',
        u'created',
    ]
    list_filter = [
        u'type',
        u'created',
    ]
    search_fields = [
        u'=id',
        u'=branch__id',
        u'=email__id',
    ]
    ordering = [
        u'-created',
        u'-id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'branch',
        u'email',
    ]
    inlines = []

    def get_queryset(self, request):
        queryset = super(ActionAdmin, self).get_queryset(request)
        queryset = queryset.select_related(u'branch')
        queryset = queryset.select_related(u'email')
        return queryset
Exemple #9
0
class ProfileAdmin(admin.ModelAdmin):
    date_hierarchy = None
    list_display = [
        u'id',
        decorate(
            lambda o: admin_obj_format(
                o.user, u'{obj.first_name} {obj.last_name} <{obj.email}>'),
            short_description=u'User',
            admin_order_field=u'user__email',
        ),
        u'street',
        u'city',
        u'zip',
        decorate(
            lambda o: o.undecided_emails_count,
            short_description=u'Undecided E-mails',
            admin_order_field=u'undecided_emails_count',
        ),
    ]
    list_filter = [
        simple_list_filter_factory(u'Undecided E-mail', u'undecided', [
            (u'1', u'With',
             lambda qs: qs.filter(undecided_emails_count__gt=0)),
            (u'0', u'Without', lambda qs: qs.filter(undecided_emails_count=0)),
        ]),
    ]
    search_fields = [
        u'=id',
        u'user__first_name',
        u'user__last_name',
        u'user__email',
        u'street',
        u'city',
        u'zip',
    ]
    ordering = [
        u'id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'user',
    ]
    inlines = []

    def get_queryset(self, request):
        queryset = super(ProfileAdmin, self).get_queryset(request)
        queryset = queryset.select_related(u'user')
        queryset = queryset.select_undecided_emails_count()
        return queryset
Exemple #10
0
class InvitationSupplyAdmin(admin.ModelAdmin):
    date_hierarchy = None
    list_display = [
        u'id',
        decorate(
            lambda o: admin_obj_format(
                o.user, u'{obj.first_name} {obj.last_name} <{obj.email}>'),
            short_description=u'User',
            admin_order_field=u'user__email',
        ),
        u'enabled',
        u'unlimited',
        u'supply',
    ]
    list_filter = [
        u'enabled',
        u'unlimited',
    ]
    search_fields = [
        u'=id',
        u'user__first_name',
        u'user__last_name',
        u'user__email',
    ]
    ordering = [
        u'id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'user',
    ]
    inlines = []

    def get_queryset(self, request):
        queryset = super(InvitationSupplyAdmin, self).get_queryset(request)
        queryset = queryset.select_related(u'user')
        return queryset
Exemple #11
0
class WizardDraftAdmin(admin.ModelAdmin):
    date_hierarchy = u'modified'
    list_display = [
        u'id',
        decorate(
            lambda o: admin_obj_format(
                o.owner, u'{obj.first_name} {obj.last_name} <{obj.email}>'),
            short_description=u'Owner',
            admin_order_field=u'owner__email',
        ),
        u'step',
        u'modified',
    ]
    list_filter = [
        u'modified',
    ]
    search_fields = [
        u'id',  # ID contains wizard name
        u'owner__first_name',
        u'owner__last_name',
        u'owner__email',
        u'step',
    ]
    ordering = [
        u'id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'owner',
    ]
    inlines = []

    def get_queryset(self, request):
        queryset = super(WizardDraftAdmin, self).get_queryset(request)
        queryset = queryset.select_related(u'owner')
        return queryset
Exemple #12
0
 def branch_applicant_live(self, branch):
     user = branch.inforequest.applicant if branch else None
     return admin_obj_format(user, u'{tag}\n{obj.first_name} {obj.last_name} <{obj.email}>')
Exemple #13
0
 def branch_details_live(self, branch):
     return admin_obj_format(branch)
Exemple #14
0
 def email_column(self, action):
     email = action.email
     return admin_obj_format(email)
Exemple #15
0
 def branch_applicant_column(self, action):
     user = action.branch.inforequest.applicant
     return admin_obj_format(user, u'{obj.first_name} {obj.last_name} <{obj.email}>')
Exemple #16
0
 def branch_column(self, action):
     branch = action.branch
     return admin_obj_format(branch)
Exemple #17
0
 def obligee_column(self, obligee):
     return admin_obj_format(obligee, link=False)
Exemple #18
0
 def user_column(self, profile):
     user = profile.user
     return admin_obj_format(user, u"{obj.first_name} {obj.last_name} <{obj.email}>")
Exemple #19
0
 def invitee_details_live(self, invitee):
     user = invitee
     return admin_obj_format(user, u'{tag}\n{obj.first_name} {obj.last_name} <{obj.email}>')
Exemple #20
0
 def invitee_column(self, invitation):
     user = invitation.invitee
     return admin_obj_format(user, u'{obj.first_name} {obj.last_name} <{obj.email}>')
Exemple #21
0
 def invitation_column(self, invitation):
     return admin_obj_format(invitation, link=False)
Exemple #22
0
 def message_column(self, message):
     return admin_obj_format(message, link=False)
Exemple #23
0
 def inforequest_field(self, branch):
     inforequest = branch.inforequest
     return admin_obj_format(inforequest)
Exemple #24
0
 def inforequest_applicant_field(self, branch):
     user = branch.inforequest.applicant
     return admin_obj_format(user, u'{obj.first_name} {obj.last_name} <{obj.email}>')
Exemple #25
0
 def email_details_live(self, email):
     return admin_obj_format(email)
Exemple #26
0
 def obligee_field(self, branch):
     obligee = branch.obligee
     return admin_obj_format(obligee, u'{obj.name}')
Exemple #27
0
 def message_details_live(self, message):
     return admin_obj_format(message)
Exemple #28
0
 def profile_field(self, user):
     profile = user.profile
     return admin_obj_format(profile)
Exemple #29
0
 def invitationsupply_column(self, invitationsupply):
     return admin_obj_format(invitationsupply, link=False)
Exemple #30
0
 def action_column(self, action):
     return admin_obj_format(action, link=False)
Exemple #31
0
 def user_column(self, profile):
     user = profile.user
     return admin_obj_format(user, u'{obj.first_name} {obj.last_name} <{obj.email}>')
Exemple #32
0
 def branch_inforequest_column(self, action):
     inforequest = action.branch.inforequest
     return admin_obj_format(inforequest)
Exemple #33
0
 def user_details_field(self, invitationsupply):
     user = invitationsupply.user
     return admin_obj_format(user, u'{tag}\n{obj.first_name} {obj.last_name} <{obj.email}>')
Exemple #34
0
 def branch_obligee_column(self, action):
     obligee = action.branch.obligee
     return admin_obj_format(obligee, u'{obj.name}')
Exemple #35
0
 def invitationsupply_field(self, user):
     invitationsupply = user.invitationsupply
     return admin_obj_format(invitationsupply)
Exemple #36
0
 def inforequest_field(self, action):
     inforequest = action.branch.inforequest if action else None
     return admin_obj_format(inforequest)
Exemple #37
0
 def branch_field(self, branch):
     return admin_obj_format(branch)
Exemple #38
0
 def branch_inforequest_live(self, branch):
     inforequest = branch.inforequest if branch else None
     return admin_obj_format(inforequest)
Exemple #39
0
 def action_field(self, message):
     action = try_except(lambda: message.action, None)
     return admin_obj_format(action)
Exemple #40
0
 def branch_obligee_live(self, branch):
     obligee = branch.obligee if branch else None
     return admin_obj_format(obligee, u'{tag}\n{obj.name}')
Exemple #41
0
 def inforequest_field(self, inforequest):
     return admin_obj_format(inforequest)
Exemple #42
0
 def branch_field(self, branch):
     return admin_obj_format(branch)
Exemple #43
0
 def obligee_field(self, inforequest):
     obligee = inforequest.main_branch.obligee
     return admin_obj_format(obligee, u'{obj.name}')
Exemple #44
0
 def profile_column(self, profile):
     return admin_obj_format(profile, link=False)
Exemple #45
0
 def inforequestdraft_field(self, draft):
     return admin_obj_format(draft)
Exemple #46
0
 def user_details_field(self, profile):
     user = profile.user
     return admin_obj_format(user, u"{tag}\n{obj.first_name} {obj.last_name} <{obj.email}>")
Exemple #47
0
 def obligee_field(self, draft):
     obligee = draft.obligee
     return admin_obj_format(obligee, u'{obj.name}')
Exemple #48
0
 def message_column(self, message):
     return admin_obj_format(message, link=False)
Exemple #49
0
class InforequestAdmin(admin.ModelAdmin):
    date_hierarchy = u'submission_date'
    list_display = [
        u'id',
        decorate(
            lambda o: admin_obj_format(
                o.applicant, u'{obj.first_name} {obj.last_name} <{obj.email}>'
            ),
            short_description=u'Applicant',
            admin_order_field=u'applicant__email',
        ),
        decorate(
            lambda o: admin_obj_format(o.main_branch.obligee, u'{obj.name}'),
            short_description=u'Obligee',
            admin_order_field=u'branch__obligee__name',
        ),
        u'subject',
        u'submission_date',
        decorate(
            lambda o: o.undecided_emails_count,
            short_description=u'Undecided E-mails',
            admin_order_field=u'undecided_emails_count',
        ),
        u'closed',
    ]
    list_filter = [
        u'submission_date',
        simple_list_filter_factory(u'Undecided E-mail', u'undecided', [
            (u'1', u'With',
             lambda qs: qs.filter(undecided_emails_count__gt=0)),
            (u'0', u'Without', lambda qs: qs.filter(undecided_emails_count=0)),
        ]),
        u'closed',
    ]
    search_fields = [
        u'=id',
        u'applicant__first_name',
        u'applicant__last_name',
        u'applicant__email',
        u'branch__obligee__name',
        u'unique_email',
        u'subject',
    ]
    ordering = [
        u'-submission_date',
        u'-id',
    ]
    exclude = []
    readonly_fields = []
    raw_id_fields = [
        u'applicant',
    ]
    inlines = []

    def get_queryset(self, request):
        queryset = super(InforequestAdmin, self).get_queryset(request)
        queryset = queryset.select_related(u'applicant')
        queryset = queryset.select_undecided_emails_count()
        queryset = queryset.prefetch_related(
            Inforequest.prefetch_main_branch(
                None, Branch.objects.select_related(u'obligee')))
        return queryset