Exemplo n.º 1
0
def new_story():
    if(session and session['logged_in']):
        if request.method == 'POST':

            story = Story(genre_id = request.form.get('genre_id'),
                        country_id = request.form.get('country_id'),
                        storytype_id = request.form.get('storytype_id'),
                        media_topic = request.form.get('media_topic'),
                        media_text = request.form.get('media_text'),
                        media_desc = request.form.get('media_desc'),
                        hidden = request.form.get('hidden') != None,
                        owner = session['username'],
                        create_time = utils.get_now(),
                        lang_id = 2)

            db.session.add(story)
            db.session.commit()
            flash("New story created")
            return redirect(url_for("home"))
        else:
            my_uploads = db.session.query(Uploads).filter(Uploads.user_id==session['user_id']).order_by(Uploads.create_time.desc())
            blobs = []
            for blob in my_uploads:
                blobs.append(blob)
            return render_template("user/new_story.html", blobs=blobs)
    else:
        flash("Please login first")
        return redirect(url_for("home"))
Exemplo n.º 2
0
 def get(self, locality_id):
     l = Locality.query.get_or_raise(locality_id)
     return jsonify([
         self.schema.dump(d)
         for d in Hour.query.filter_by(locality_id=locality_id).order_by(
             Hour.date, Hour.hour_data).all()
         if dt.datetime.combine(date=d.date, time=d.hour_data) >= get_now()
     ])
Exemplo n.º 3
0
def new_category():
    if(session and session['logged_in']):
        if request.method == 'POST':

            category = LinkCategories(name = request.form.get('category_name'),
                        user_id = session['user_id'],
                        create_time = utils.get_now()
                    )

            db.session.add(category)
            db.session.commit()

            flash("New link category created")
            return redirect(url_for("links.all"))
        if request.method == 'GET':
            return render_template("links/new_category.html")
    else:
        flash("Please login first")
        return redirect(url_for("home"))
Exemplo n.º 4
0
def new_link():
    if(session and session['logged_in']):
        if request.method == 'GET':
            categories = LinkCategories.query.order_by(LinkCategories.create_time.desc())
            return render_template("links/new_link.html", categories=categories)
        if request.method == 'POST':

            link = Links(category = request.form.get('category'),
                        name = request.form.get('name'),
                        url = request.form.get('url'),
                        user_id = session['user_id'],
                        create_time = utils.get_now()
                    )

            db.session.add(link)
            db.session.commit()

            flash("New link created")
            return redirect(url_for("links.all"))
    else:
        flash("Please login first")
        return redirect(url_for("home"))
Exemplo n.º 5
0
def new_media():
    if (session and session['logged_in']):
        if request.method == 'GET':
            return render_template("user/new_media.html")
        if request.method == 'POST':
            media = Media(mediatype_id=request.form.get('mediatype_id'),
                          genre_id=request.form.get('genre_id'),
                          country_id=request.form.get('country_id'),
                          media_topic=request.form.get('media_topic'),
                          media_text=request.form.get('media_text'),
                          media_desc=request.form.get('media_desc'),
                          hidden=request.form.get('hidden') != None,
                          owner=session['username'],
                          create_time=utils.get_now(),
                          lang_id=2)

            db.session.add(media)
            db.session.commit()
            flash("New media added")
            return redirect(url_for("home"))
    else:
        flash("Please login first")
        return redirect(url_for("home"))