コード例 #1
0
    def delete(self, request, *args, **kwargs):
        """
        Don't delete the object but update its status
        """
        self.object = self.get_object()
        self.object.github_status = GITHUB_STATUS_CHOICES.WAITING_DELETE
        self.object.save(update_fields=['github_status'])

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

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

        return HttpResponseRedirect(self.get_success_url())
コード例 #2
0
    def form_valid(self, form):
        """
        Override the default behavior to add a job to create/update the label
        on the github side
        """
        response = super(LabelFormBaseView, self).form_valid(form)

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

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

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

        return response