def post(self, request, *args, **kwargs): form = forms.CreateIssueCommentForm(request.POST) if not form.is_valid(): return HttpResponseBadRequest() i = self.get_object() c = i.comments.create(content=form.cleaned_data['content'], created_by=request.user) return render(request, 'issues/_comment.html', {'c': c})
def post(self, request, *args, **kwargs): form = forms.CreateIssueCommentForm(request.POST) if not form.is_valid(): return HttpResponseBadRequest() i = self.get_object() c = i.comments.create(content=enhance_html(form.cleaned_data['content']), created_by=request.user) self.object = i # this makes the next line work context = self.get_context_data(object=i, c=c) return render(request, 'issues/_comment.html', context)
def get_context_data(self, **kwargs): d = super(IssueDetailView, self).get_context_data(**kwargs) m_id = self.request.GET.get('m_id', None) d['form'] = forms.CreateIssueCommentForm() d['reference_form'] = forms.CreateReferenceForm() d['proposal_form'] = forms.CreateProposalForm(community=self.community) if m_id: d['meeting'] = get_object_or_404(Meeting, id=m_id, community=self.community) a = d['meeting'].agenda.object_access_control( user=self.request.user, community=self.community).all() d['meeting_active_issues'] = [ ai.issue for ai in a if ai.issue.active ] else: d['meeting'] = None if self.request.GET.get('s', None) == '1': d['all_issues'] = self.get_queryset().exclude( status=IssueStatus.ARCHIVED).order_by('-created_at') o = self.get_object() group = self.request.user.get_default_group(o.community) \ if self.request.user.is_authenticated else '' if group == DefaultGroups.BOARD or \ group == DefaultGroups.SECRETARY: if o.is_current and self.request.user in \ o.community.upcoming_meeting_participants.all(): d['can_board_vote_self'] = True d['proposals'] = self.object.proposals.object_access_control( user=self.request.user, community=self.community).open() d['upcoming_issues'] = self.object.community.upcoming_issues( user=self.request.user, community=self.community) d['agenda_items'] = self.object.agenda_items.all() for ai in d['agenda_items']: ai.accepted_proposals = ai.accepted_proposals( user=self.request.user, community=self.community) ai.rejected_proposals = ai.rejected_proposals( user=self.request.user, community=self.community) ai.proposals = ai.proposals(user=self.request.user, community=self.community) return d
def post(self, request, *args, **kwargs): form = forms.CreateIssueCommentForm(request.POST) if not form.is_valid(): return HttpResponseBadRequest() i = self.get_object() comment_id = request.POST.get('comment_id', None) try: c = i.comments.get(pk=int(comment_id)) c.content = enhance_html(form.cleaned_data['content']) c.save() return json_response({'comment_id': c.id}) except: c = i.comments.create(content=enhance_html( form.cleaned_data['content']), created_by=request.user) return json_response({'comment_id': c.id})
def get_context_data(self, **kwargs): d = super(IssueDetailView, self).get_context_data(**kwargs) d['form'] = forms.CreateIssueCommentForm() d['proposal_form'] = forms.CreateProposalForm() return d