def form_valid(self, form): form.instance.create_user = get_user(self.request) form.instance.create_update_info() datetime_string = timezone.now().strftime('%Y%m%d%H%M%S%f') if form.instance.type.name == '数据库': form.instance.number = 'SD' + datetime_string elif form.instance.type.name == '业务服务': form.instance.number = 'SY' + datetime_string elif form.instance.type.name == '中间件': form.instance.number = 'SM' + datetime_string else: form.instance.number = 'SO' + datetime_string return super(TicketCreateFromTicketView, self).form_valid(form)
def get_context_data(self, **kargs): context = super().get_context_data(**kargs) current_user = get_user(self.request) my_all_tickets = Ticket.objects.filter( Q(create_user=current_user) | Q(audit_user=current_user) | Q(execute_user=current_user) | Q(test_user=current_user)) audit_tickets = Ticket.objects.filter(audit_user=current_user, status=10) execute_tickets = Ticket.objects.filter(execute_user=current_user, status=20) test_tickets = Ticket.objects.filter(test_user=current_user, status=30) all_tickets = [ my_all_tickets, audit_tickets, execute_tickets, test_tickets ] context['all_tickets'] = all_tickets context['current_user'] = current_user return context
def get_object(self, queryset=None): obj = super(JobDeleteView, self).get_object() if not obj.create_user == get_user(self.request): raise Http404 return obj
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['current_user'] = get_user(self.request) return context
def form_valid(self, form): form.instance.execute_user = get_user(self.request) form.instance.status = 0 form.instance.created_at = timezone.now() return super(JobPlanCreateView, self).form_valid(form)
def form_valid(self, form): form.instance.create_user = get_user(self.request) return super(JobCreateView, self).form_valid(form)
def form_valid(self, form): if form.instance.create_user == get_user(self.request): form.instance.status = -1 return super(TicketCancelUpdateView, self).form_valid(form)
def form_valid(self, form): form.instance.create_user = get_user(self.request) form.instance.create_update_info() return super(TicketUpdateView, self).form_valid(form)