def form_valid(self, form): self.object = form.instance self.object.task_id = self.kwargs["task_id"] # started by self.object.started_by = self.request.user self.object.save() # will be celery task # create an action action(self.request.user, self.object, "comment", self.object.task) return super(CreateTaskComment, self).form_valid(form)
def form_valid(self, form): self.object = form.instance self.object.discussion_id = self.kwargs["discussion_id"] # started by self.object.started_by = self.request.user self.object.save() # create an action # will be celery task action(self.request.user, self.object, "comment", self.object.discussion) return super(CreateDiscussionComment, self).form_valid(form)
def form_valid(self, form): self.object = form.instance self.object.project_id = self.kwargs["project_id"] # started by self.object.started_by = self.request.user self.object.ordering = 1 # temporary fix self.object.save() # create an action # will be celery task action(self.request.user, self.object, "create", self.object.project) return super(CreateTask, self).form_valid(form)
def form_valid(self, form): self.object = form.instance self.object.project_id = self.kwargs["project_id"] # started by self.object.started_by = self.request.user self.object.save() # create an action # will be celery task action(self.request.user, self.object, "create", self.object.project) start_following(self.request.user, self.object) return super(CreateDiscussion, self).form_valid(form)
def assign_user(request): user_id = request.GET.get('user_id') task_id = request.GET.get('task_id') u = Profile.objects.get(id=int(user_id)) t = Task.objects.get(id=int(task_id)) if u in t.project.people.all() and u not in t.people.all(): t.people.add(u) action(request.user, u, "assigntotask", t) result = {'user_id': u.id, 'username': u.username} return HttpResponse(simplejson.dumps(result), mimetype="application/json")
def remove_user(request): user_id = request.GET.get('user_id') task_id = request.GET.get('task_id') p = Profile.objects.get(id=int(user_id)) t = Task.objects.get(id=int(task_id)) if p in t.project.people.all() and p in t.people.all(): t.people.remove(p) action(request.user, p, "removefromtask", t) result = {} return HttpResponse(simplejson.dumps(result), mimetype="application/json")
def create_project(request, template="new_project.html"): if request.method == "POST": form = NewProjectForm(request.POST) if form.is_valid(): title = request.POST.get("title") desc = request.POST.get("description") prj = Project(title=title, description=desc) prj.save() prj.people.add(request.user) if prj: action(request.user, prj, "create") return redirect(prj) else: form = NewProjectForm() ctx = {"form": form} return render(request, template, ctx)