Пример #1
0
 def change_status_to_read(self, request, queryset):
     for ticket in queryset:
         if ticket.status == Ticket.NEW_STATUS:
             StatusLog.add_log(ticket, request.user, ticket.READ_STATUS)
     count = queryset.filter(status=Ticket.NEW_STATUS).update(status=Ticket.READ_STATUS)
     if count:
         messages.success(request, ungettext(
             'Status `read` put %(count)d ticket.',
             'Status `read` put %(count)d tickets.',
             count) % dict(count=count))
     else:
         messages.error(request, _('Status `read` can be supplied only by a new tickets.'))
Пример #2
0
 def change_status_to_closed(self, request, queryset):
     deny_statuses = [Ticket.CLOSED_STATUS, Ticket.SOLVED_STATUS, Ticket.REOPENED_STATUS]
     for ticket in queryset:
         if not ticket.status in deny_statuses:
             StatusLog.add_log(ticket, request.user, ticket.CLOSED_STATUS)
     count = queryset.exclude(status__in=deny_statuses).\
         update(status=Ticket.CLOSED_STATUS, closed_at=datetime.now())
     if count:
         messages.success(request, ungettext(
             'Status `closed` put %(count)d ticket.',
             'Status `closed` put %(count)d tickets.',
             count) % dict(count=count))
     else:
         messages.error(request, _('Status `closed` can not be put tickets by status '
                                   '%(statuses)s.') % dict(statuses=', '.join(deny_statuses)))
Пример #3
0
 def save_model(self, request, obj, form, change):
     if '_ticket_process' in request.POST:
         obj.manager = request.user
     obj.save()
     if 'status' in form.changed_data:
         StatusLog.add_log(obj, request.user, obj.status)