Beispiel #1
0
def admin_jam(id = 0):
    mode = "create"
    jam = None

    if id != 0:
        jam = Jam.query.filter_by(id = id).first_or_404()
        mode = "edit"

    form = JamDetailsForm(obj=jam)

    if form.validate_on_submit():
        slug_jam = Jam.query.filter_by(slug = get_slug(form.title.data.strip())).first()
        if slug_jam and slug_jam != jam:
            flash("A jam with a similar title already exists (slug conflict).", "error")
        else:
            if mode == "create":
                jam = Jam("", datetime.utcnow())
                db.session.add(jam)

            form.populate_obj(jam)
            jam.title.strip()
            jam.slug = get_slug(jam.title)
            jam.theme.strip()
            jam.description.strip()
            jam.restrictions.strip()

            db.session.commit()
            flash("Jam settings have been saved.", "success")
            return redirect(url_for("admin_jam", id = jam.id))

    return render_template("admin/jam.html", id = id, mode = mode, jam = jam, form = form)
Beispiel #2
0
def admin_jam(id=0):
    mode = "create"
    jam = None

    if id != 0:
        jam = Jam.query.filter_by(id=id).first_or_404()
        mode = "edit"

    form = JamDetailsForm(obj=jam)

    if form.validate_on_submit():
        slug_jam = Jam.query.filter_by(slug=get_slug(form.title.data.strip())).first()
        if slug_jam and slug_jam != jam:
            flash("A jam with a similar title already exists (slug conflict).", "error")
        else:
            if mode == "create":
                jam = Jam("", datetime.utcnow())
                db.session.add(jam)

            form.populate_obj(jam)
            jam.title.strip()
            jam.slug = get_slug(jam.title)
            jam.theme.strip()
            jam.description.strip()
            jam.restrictions.strip()

            db.session.commit()
            flash("Jam settings have been saved.", "success")
            return redirect(url_for("admin_jam", id=jam.id))

    return render_template("admin/jam.html", id=id, mode=mode, jam=jam, form=form)
Beispiel #3
0
def edit_game(jam_slug, game_id):
    jam = Jam.query.filter_by(slug=jam_slug).first_or_404()
    game = Game.query.filter_by(is_deleted=False, id=game_id).first_or_404()

    if not game or not current_user in game.team.members:
        abort(403)

    form = GameEditForm(request.form, obj=game)
    package_form = GameAddPackageForm()
    screenshot_form = GameAddScreenshotForm()

    if form.validate_on_submit():
        slug = get_slug(form.title.data)
        # if not jam.games.filter_by(slug = slug).first() in (game, None):
        # flash("A game with a similar title already exists. Please choose another title.", category = "error")
        # else:
        # form.populate_obj(game) this breaks dynamic stuff below

        game.title = form.title.data
        game.description = form.description.data
        game.technology = form.technology.data
        game.help = form.help.data

        if game.jam.getStatus().code < 4:
            for c in RATING_CATEGORIES:
                setattr(game, "score_" + c + "_enabled", form.get(c).data)

        game.slug = get_slug(game.title)
        db.session.commit()
        flash("Your settings have been applied.", category="success")
        return redirect(game.url())

    # if package_form.validate_on_submit():
    #    s = GamePackage(game, package_form.url.data, package_form.type.data)
    #    db.session.add(s)
    #    db.session.commit()
    #    flash("Your package has been added.", "success")
    #    return redirect(request.url)

    # if screenshot_form.validate_on_submit():
    #    s = GameScreenshot(screenshot_form.url.data, screenshot_form.caption.data, game)
    #    db.session.add(s)
    #    db.session.commit()
    #    flash("Your screenshot has been added.", "success")
    #    return redirect(request.url)

    return render_template("jam/game/edit.html", jam=jam, game=game,
                           form=form, package_form=package_form, screenshot_form=screenshot_form)
Beispiel #4
0
 def __init__(self, title, start_time, duration=48, team_limit=0, theme=''):
     self.title = title
     self.slug = get_slug(title)
     self.start_time = start_time
     self.duration = duration
     self.registration_duration = 24 * 14
     self.packaging_duration = 24 * 1
     self.rating_duration = 24 * 5
     self.announced = datetime.utcnow()
     self.theme = theme
     self.team_limit = team_limit
Beispiel #5
0
 def __init__(self, title, start_time, duration = 48, team_limit = 0, theme = ''):
     self.title = title
     self.slug = get_slug(title)
     self.start_time = start_time
     self.duration = duration
     self.registration_duration = 24 * 14
     self.packaging_duration = 24 * 1
     self.rating_duration = 24 * 5
     self.announced = datetime.utcnow()
     self.theme = theme
     self.team_limit = team_limit
Beispiel #6
0
def edit_game(jam_slug, game_id):
    jam = Jam.query.filter_by(slug=jam_slug).first_or_404()
    game = Game.query.filter_by(is_deleted=False, id=game_id).first_or_404()

    if not game or current_user not in game.team.members:
        abort(403)

    form = GameEditForm(request.form, obj=game)
    package_form = GameAddPackageForm()
    screenshot_form = GameAddScreenshotForm()

    if form.validate_on_submit():
        game.title = form.title.data
        game.description = form.description.data
        game.technology = form.technology.data
        game.help = form.help.data

        if game.jam.get_status().code < 4:
            for c in RATING_CATEGORIES:
                setattr(game, "score_{c}_enabled", form.get(c).data)

        game.slug = get_slug(game.title)
        db.session.commit()
        flash("Your settings have been applied.", category="success")
        return redirect(game.url())

    if package_form.validate_on_submit():
        s = GamePackage(game, package_form.url.data, package_form.type.data)
        db.session.add(s)
        db.session.commit()
        flash("Your package has been added.", "success")
        return redirect(request.url)

    if screenshot_form.validate_on_submit():
        s = GameScreenshot(screenshot_form.url.data,
                           screenshot_form.caption.data, game)
        db.session.add(s)
        db.session.commit()
        flash("Your screenshot has been added.", "success")
        return redirect(request.url)

    return render_template("jam/game/edit.html",
                           jam=jam,
                           game=game,
                           form=form,
                           package_form=package_form,
                           screenshot_form=screenshot_form)
Beispiel #7
0
def edit_game(jam_slug, game_id):
    jam = Jam.query.filter_by(slug=jam_slug).first_or_404()
    game = Game.query.filter_by(is_deleted=False, id=game_id).first_or_404()

    if not game or current_user not in game.team.members:
        abort(403)

    form = GameEditForm(request.form, obj=game)
    package_form = GameAddPackageForm()
    screenshot_form = GameAddScreenshotForm()

    if form.validate_on_submit():
        game.title = form.title.data
        game.description = form.description.data
        game.technology = form.technology.data
        game.help = form.help.data

        if game.jam.get_status().code < 4:
            for c in RATING_CATEGORIES:
                setattr(game, "score_{c}_enabled", form.get(c).data)

        game.slug = get_slug(game.title)
        db.session.commit()
        flash("Your settings have been applied.", category="success")
        return redirect(game.url())

    if package_form.validate_on_submit():
        s = GamePackage(game, package_form.url.data, package_form.type.data)
        db.session.add(s)
        db.session.commit()
        flash("Your package has been added.", "success")
        return redirect(request.url)

    if screenshot_form.validate_on_submit():
        s = GameScreenshot(screenshot_form.url.data, screenshot_form.caption.data, game)
        db.session.add(s)
        db.session.commit()
        flash("Your screenshot has been added.", "success")
        return redirect(request.url)

    return render_template("jam/game/edit.html", jam=jam, game=game,
                           form=form, package_form=package_form, screenshot_form=screenshot_form)
Beispiel #8
0
 def __init__(self, team, title):
     self.team = team
     self.jam = team.jam
     self.title = title
     self.slug = get_slug(title)
     self.created = datetime.utcnow()
Beispiel #9
0
 def __init__(self, team, title):
     self.team = team
     self.jam = team.jam
     self.title = title
     self.slug = get_slug(title)
     self.created = datetime.utcnow()