Beispiel #1
0
    def edit(self,
             new_title,
             new_format,
             new_content,
             new_tags=None,
             new_note=None,
             keep_comments=True,
             cancel_modified_scopes=True):
        new_content = on_content_receive(new_content, new_format)
        if not keep_comments:
            self.comment_set.all().delete()
        elif self.content != new_content or new_format != self.format:
            comments = self.get_comments()
            tomodify_comments, toremove_comments = compute_new_comment_positions(
                self.content, self.format, new_content, new_format, comments)
            [comment.save(keep_dates=True) for comment in tomodify_comments]
            if cancel_modified_scopes:
                [comment.remove_scope() for comment in toremove_comments]
            else:
                [comment.delete() for comment in toremove_comments]

        self.title = new_title
        if new_tags:
            self.tags = new_tags
        if new_note:
            self.note = new_note
        self.content = new_content
        self.format = new_format
        self.save()
Beispiel #2
0
def text_pre_edit(request, key, adminkey=None):
    text = get_text_by_keys_or_404(key)
    
    text_version = text.get_latest_version()
    comments = text_version.get_comments()
    new_format = request.POST['new_format']
    new_content = on_content_receive(request.POST['new_content'], new_format)

    # TODO: RBE : si commentaire mal forme : (position non existante : boom par key error)
    _tomodify_comments, toremove_comments = compute_new_comment_positions(text_version.content, text_version.format, new_content, new_format, comments)
    return HttpResponse(simplejson.dumps({'nb_removed' : len(toremove_comments) }))
Beispiel #3
0
 def edit(self, new_title, new_format, new_content, new_tags=None, new_note=None, keep_comments=True, cancel_modified_scopes=True):
     new_content = on_content_receive(new_content, new_format) 
     if not keep_comments :
         self.comment_set.all().delete()
     elif self.content != new_content or new_format != self.format:
         comments = self.get_comments() ;
         tomodify_comments, toremove_comments = compute_new_comment_positions(self.content, self.format, new_content, new_format, comments)
         [comment.save(keep_dates=True) for comment in tomodify_comments]
         if cancel_modified_scopes :
             [comment.remove_scope() for comment in toremove_comments]
         else :
             [comment.delete() for comment in toremove_comments]
             
     self.title = new_title
     if new_tags:
         self.tags = new_tags
     if new_note:
         self.note = new_note
     self.content = new_content
     self.format = new_format
     self.save()
Beispiel #4
0
 def create_text(self,
                 title,
                 format,
                 content,
                 note,
                 name,
                 email,
                 tags,
                 user=None,
                 state='approved',
                 **kwargs):
     content = on_content_receive(content, format)
     text = self.create(name=name, email=email, user=user, state=state)
     text_version = TextVersion.objects.create(title=title,
                                               format=format,
                                               content=content,
                                               text=text,
                                               note=note,
                                               name=name,
                                               email=email,
                                               tags=tags,
                                               user=user)
     return text
Beispiel #5
0
 def create_text(self, title, format, content, note, name, email, tags, user=None, state='approved', **kwargs):
     content = on_content_receive(content, format)
     text = self.create(name=name, email=email, user=user, state=state)
     text_version = TextVersion.objects.create(title=title, format=format, content=content, text=text, note=note, name=name, email=email, tags=tags, user=user)
     cache.clear()
     return text