delete option staff varizi
This commit is contained in:
1 parent
d99e47ecce
commit
b53a3e0c5c
14 files changed
+383
-3
No files matched your search
@@ -27,6 +27,29 @@ def configuration_snapshot(obj):
|
||||
return json.loads(serializers.serialize('json', [obj]))[0]['fields']
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
def delete_notice(actor, notice):
|
||||
# Receipt submission locks the same customer, then notice. Do not lock access
|
||||
# links here: anonymous submission already holds its link before the customer.
|
||||
actor = User.objects.select_related('staff_profile').get(pk=actor.pk)
|
||||
User.objects.select_for_update().get(pk=notice.customer_id)
|
||||
notice = PaymentNotice.objects.select_for_update().get(pk=notice.pk)
|
||||
if not policies.may_delete_notice(actor, notice):
|
||||
raise PermissionDenied
|
||||
if notice.receipts.exists():
|
||||
raise ValidationError('برای این اعلامیه فیش ثبت شده است؛ حذف آن امکانپذیر نیست، حتی اگر فیش رد شده باشد.')
|
||||
if notice.deleted_at:
|
||||
return
|
||||
notice.deleted_at = notice.cancelled_at = timezone.now()
|
||||
notice.save(update_fields=['deleted_at', 'cancelled_at', 'updated_at'])
|
||||
from apps.notifications.models import NotificationJob
|
||||
NotificationJob.objects.filter(payment_notification__notice=notice,
|
||||
status__in=['PENDING', 'RETRYING', 'FAILED']).update(status='CANCELLED',
|
||||
last_error='اعلامیه واریز حذف شده است.')
|
||||
audit(actor, 'NOTICE_DELETED', notice, {'number': notice.number, 'customer_id': notice.customer_id,
|
||||
'subject': notice.subject, 'amount': notice.amount})
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
def issue_notice(actor, data):
|
||||
unit = TicketPolicy.primary_unit(actor)
|
||||
|
||||
Reference in new issue
Block a user