예제 #1
0
def topic_addtopic():
    form = request.form
    title = form['title']
    u = current_user()
    Topic.add_topic(form, user_id=u.id)
    m = Topic.one(title=title)
    return redirect(url_for('.detail', id=m.id))
예제 #2
0
    def post(self):

        user = users.get_current_user()
        if not user:
            return self.write("you are not loged in!")

        title = self.request.get("title")
        content = self.request.get("content")

        author = User.query(User.email == user.email()).get()
        topic = Topic.query(
            Topic.title == title).get()  # check if topic exists

        if author:
            if not topic:  # if not, create new one
                author_email = author.email
                author_avatar = author.avatar_url

                new_topic = Topic.add_topic(title=title,
                                            content=content,
                                            author_email=author_email,
                                            author_avatar=author_avatar)

                return self.redirect_to("topic", topic_id=new_topic.key.id())
            else:
                return self.write("Topic with the same title already exists!")
예제 #3
0
def addtopic():
    user = current_user()
    if user is None:
        return 'fail'
    res = Topic.add_topic(user, request.form)
    if res is not None:
        return 'success'
    else:
        return 'fail'
예제 #4
0
파일: command.py 프로젝트: Junred/ItChat
 def create_topic(self, user_id, topic_name):
     Topic.add_topic(user_id, topic_name, auto_commit=True)