コード例 #1
0
ファイル: models.py プロジェクト: ozgurlukicin/ozgurlukicin
 def save(self):
     if not self.hash:
         random.seed()
         salt = sha(str(random.random())).hexdigest()
         self.hash = sha(salt).hexdigest()
     if not self.ip:
         self.ip = threadlocals.get_current_ip()
     super(Person, self).save()
コード例 #2
0
 def save(self):
     if not self.hash:
         random.seed()
         salt = sha(str(random.random())).hexdigest()
         self.hash = sha(salt).hexdigest()
     if not self.ip:
         self.ip = threadlocals.get_current_ip()
     super(Person, self).save()
コード例 #3
0
def create_forum_topic(article, forum_name):
    if article.id == None:
        # forum topic not created, lets create
        user = get_object_or_404(User,
                                 username=threadlocals.get_current_user())
        forum = Forum.objects.filter(name=forum_name).order_by("id")[0]
        topic = Topic(
            forum=forum,
            title=article.title,
        )
        topic.save()

        post = Post(
            topic=topic,
            author=user,
            text=article.text,
            ip=threadlocals.get_current_ip(),
            hidden=not article.status,
        )
        post.save()

        topic.topic_latest_post = post
        topic.posts = 1
        topic.hidden = not article.status
        topic.topic_latest_post = post
        topic.forum.posts += 1
        topic.forum.topics += 1
        if article.status:
            topic.forum.forum_latest_post = post
        topic.forum.save()
        topic.save()
        article.topic = topic
    else:
        # this is modified, let's update the forum topic
        topic = article.topic
        topic.tags.clear()
        for tag in article.tags.all():
            topic.tags.add(tag)

        topic.hidden = not article.status
        topic.locked = not article.status
        topic.title = article.title
        topic.save()

        post = topic.post_set.order_by("created")[0]
        post.text = article.text
        post.hidden = not article.status
        post.edited = article.update
        post.save()
    if article.status:
        try:
            ping_google()
        # we're catching SitemapNotFound exception
        # no need to import this exception class since there is only 1 exception in the function.
        except:
            pass
コード例 #4
0
ファイル: tools.py プロジェクト: ozgurlukicin/ozgurlukicin
def create_forum_topic(article, forum_name):
    if article.id == None:
        # forum topic not created, lets create
        user = get_object_or_404(User, username=threadlocals.get_current_user())
        forum = Forum.objects.filter(name=forum_name).order_by("id")[0]
        topic = Topic(
                forum = forum,
                title = article.title,
                )
        topic.save()

        post = Post(
                topic=topic,
                author=user,
                text=article.text,
                ip=threadlocals.get_current_ip(),
                hidden=not article.status,
                )
        post.save()

        topic.topic_latest_post = post
        topic.posts = 1
        topic.hidden = not article.status
        topic.topic_latest_post = post
        topic.forum.posts += 1
        topic.forum.topics += 1
        if article.status:
            topic.forum.forum_latest_post = post
        topic.forum.save()
        topic.save()
        article.topic = topic
    else:
        # this is modified, let's update the forum topic
        topic = article.topic
        topic.tags.clear()
        for tag in article.tags.all():
            topic.tags.add(tag)

        topic.hidden = not article.status
        topic.locked = not article.status
        topic.title = article.title
        topic.save()

        post = topic.post_set.order_by("created")[0]
        post.text = article.text
        post.hidden = not article.status
        post.edited = article.update
        post.save()
    if article.status:
        try:
            ping_google()
        # we're catching SitemapNotFound exception
        # no need to import this exception class since there is only 1 exception in the function.
        except:
            pass
コード例 #5
0
def pastedtext_add(request):
    if request.method == "POST":
        form = PastedTextForm(request.POST.copy())
        if form.is_valid():
            paste = form.save(commit=False)
            paste.author = request.user
            paste.ip = threadlocals.get_current_ip()
            paste.save()
            return HttpResponseRedirect(paste.get_absolute_url())
    else:
        form = PastedTextForm()
    return render_response(request, "paste/pastedtext_add.html", {"form":form})
コード例 #6
0
ファイル: models.py プロジェクト: ozgurlukicin/ozgurlukicin
    def save(self):
        new_post = False

        if not self.id:
            new_post = True

        if not self.ip:
            self.ip = threadlocals.get_current_ip()
        super(Post, self).save()

        if new_post:
            t = Topic.objects.get(pk=self.topic.id)
            t.topic_latest_post_id = self.id
            t.posts += 1
            t.save()

            f = Forum.objects.get(pk=self.topic.forum.id)
            f.forum_latest_post_id = self.id
            f.posts += 1
            f.save()
コード例 #7
0
    def save(self):
        new_post = False

        if not self.id:
            new_post = True

        if not self.ip:
            self.ip = threadlocals.get_current_ip()
        super(Post, self).save()

        if new_post:
            t = Topic.objects.get(pk=self.topic.id)
            t.topic_latest_post_id = self.id
            t.posts += 1
            t.save()

            f = Forum.objects.get(pk=self.topic.forum.id)
            f.forum_latest_post_id = self.id
            f.posts += 1
            f.save()