示例#1
0
    def delete(self, request, *args, **kwargs):
        """
        Don't delete the object but update its status, and return a simple "OK",
        not a redirect
        """
        self.object = self.get_object()
        self.object.github_status = GITHUB_STATUS_CHOICES.WAITING_DELETE
        self.object.save(update_fields=['github_status'])

        MilestoneEditJob.add_job(self.object.pk,
                             mode='delete',
                             gh=self.request.user.get_connection())

        messages.success(self.request,
            u'The milestone <strong>%s</strong> will be deleted shortly' % self.object.short_title)

        return HttpResponse('OK')
示例#2
0
    def form_valid(self, form):
        """
        Override the default behavior to add a job to create/update the milestone
        on the github side, and simple return 'OK', not a redirect.
        """
        self.object = form.save()

        edit_mode = 'update'
        if self.object.github_status == GITHUB_STATUS_CHOICES.WAITING_CREATE:
            edit_mode = 'create'

        MilestoneEditJob.add_job(self.object.pk,
                                 mode=edit_mode,
                                 gh=self.request.user.get_connection())

        messages.success(self.request,
            u'The milestone <strong>%s</strong> will be %sd shortly' % (
                                                self.object.short_title, edit_mode))

        return HttpResponse('OK')