Ejemplo n.º 1
0
    def update_content(self, expected_version, author, content):
        """ creates a new revision and updates current comment """
        if self.version != expected_version:
            return False

        content = enhance_html(content.strip())

        if self.content == content:
            return True

        with transaction.atomic():
            IssueCommentRevision.objects.create(
                comment=self,
                version=expected_version,
                created_at=self.created_at,
                created_by=self.created_by,
                content=self.content,
            )
            self.version += 1
            self.last_edited_at = timezone.now()
            self.last_edited_by = author
            self.content = content
            self.save()

        return True
Ejemplo n.º 2
0
    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})
Ejemplo n.º 3
0
    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})
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    def update_reference(self, expected_version, author, reference):
        """ creates a new revision and updates current comment """
        if self.version != expected_version:
            return False

        reference = enhance_html(reference.strip())

        if self.reference == reference:
            return True

        with transaction.atomic():
            ReferenceRevision.objects.create(reference=self,
                                             version=expected_version,
                                             created_at=self.created_at,
                                             created_by=self.created_by,
                                             content=self.reference)
            self.version += 1
            self.last_edited_at = timezone.now()
            self.last_edited_by = author
            self.reference = reference
            self.save()

        return True
Ejemplo n.º 7
0
    def update_content(self, expected_version, author, content):
        """ creates a new revision and updates current comment """
        if self.version != expected_version:
            return False

        content = enhance_html(content.strip())

        if self.content == content:
            return True

        with transaction.atomic():
            IssueCommentRevision.objects.create(comment=self,
                                                version=expected_version,
                                                created_at=self.created_at,
                                                created_by=self.created_by,
                                                content=self.content)
            self.version += 1
            self.last_edited_at = timezone.now()
            self.last_edited_by = author
            self.content = content
            self.save()

        return True
Ejemplo n.º 8
0
 def clean(self, value, model_instance):
     value = super(HTMLField, self).clean(value, model_instance)
     return enhance_html(value)
Ejemplo n.º 9
0
 def clean(self, value, model_instance):
     value = super(HTMLField, self).clean(value, model_instance)
     return enhance_html(value)