Exemplo n.º 1
0
 def form_valid(self, form):
     form.instance.pub_date = timezone.now()
     form.instance.project_tast_user = self.request.user
     
     response = super(RequiremenCreate, self).form_valid(form)
 
     #add event
     add_req = AddEvent(event_user=self.request.user, event_kind="A",date_created=timezone.now(),
                        requirement_task=form.instance,milestone=None)
     add_req.save()
 
     return response
Exemplo n.º 2
0
 def form_valid(self, form):
     form.instance.pub_date = timezone.now()
     form.instance.project_tast_user = self.request.user
     form.instance.state_kind = determine_task_state(on_wait=form.cleaned_data.get('is_on_wait'),
                                                assigned=form.cleaned_data.get('assigned_to'),
                                                resolved=False)
     
     # snimi objekat
     resp = super(TaskCreate, self).form_valid(form) 
     
     # snimi dogadjaje
     StateChange(new_state='C', event_user=self.request.user, event_kind='S', date_created=timezone.now(), requirement_task=form.instance).save()
     if  form.instance.state_kind != 'C': # ako je vec promenjeno stanje
         StateChange(new_state=form.instance.state_kind, event_user=self.request.user, event_kind='S', date_created=timezone.now(), requirement_task=form.instance).save()
     
     #add event
     add_req = AddEvent(event_user=self.request.user, event_kind="A",date_created=timezone.now(),
                        requirement_task=form.instance)
     add_req.save()
     
     return resp
Exemplo n.º 3
0
def addmilestone(request):
    if request.POST:
        form = MilestoneForm(request.POST)
        if form.is_valid():
            form.instance.date_created = timezone.now()
            form.save()
            
            #add event
            add_req = AddEvent(event_user=request.user, event_kind="A",date_created=timezone.now(),
                               requirement_task=None,milestone=form.instance)
            add_req.save()
            
            return HttpResponseRedirect(reverse('milestones'))
    else:
        form = MilestoneForm()
    
    back = ""
    try:
        back = request.META["HTTP_REFERER"]
    except(KeyError):
        back="/"
        
    return render(request,'tasks/addmilestone.html',{"form":form,
                                                     "back":back})