Víðir Valberg Guðmundsson
b2fa1dc92c
* Almost done, need the send to economic part. * Add a way to approve/reject an reimbursement and send mails accordingly. * finish work on custom invoice address * add textfield notes to Order for internal orga notes about the order * Almost done, need the send to economic part. * Add a way to approve/reject an reimbursement and send mails accordingly. * economy commit of doom.. replace reimbursement app with an economy app, add Expense and Reimbursement models, add management of expenses and reimbursements to backoffice. Rework and cleanup permissions stuff, add Camp.Permissions pseudo model to hold all our non-model permissions. still experimental, expect rough edges, but basic functionality should work.
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
from django.http import HttpResponseRedirect, Http404
|
|
|
|
|
|
class ExpensePermissionMixin(object):
|
|
"""
|
|
This mixin checks if request.user submitted the Expense, or if request.user has camps.economyteam_permission
|
|
"""
|
|
def get_object(self, queryset=None):
|
|
obj = super().get_object(queryset=queryset)
|
|
if obj.user == self.request.user or self.request.user.has_perm('camps.economyteam_permission'):
|
|
return obj
|
|
else:
|
|
# the current user is different from the user who submitted the expense, and user is not in the economy team; fuckery is afoot, no thanks
|
|
raise Http404()
|
|
|
|
|
|
class ReimbursementPermissionMixin(object):
|
|
"""
|
|
This mixin checks if request.user owns the Reimbursement, or if request.user has camps.economyteam_permission
|
|
"""
|
|
def get_object(self, queryset=None):
|
|
obj = super().get_object(queryset=queryset)
|
|
if obj.user == self.request.user or self.request.user.has_perm('camps.economyteam_permission'):
|
|
return obj
|
|
else:
|
|
# the current user is different from the user who owns the reimbursement, and user is not in the economy team; fuckery is afoot, no thanks
|
|
raise Http404()
|
|
|