Skip to content

Update from Dev #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ def getgame(id):
@login_required
def uploadgame():
if flask.request.method == 'POST':
f = flask.request.files['file']
game = flask.request.files['game']
banner = flask.request.files['banner']
icon = flask.request.files['icon']
title = flask.request.form['title']
description = flask.request.form['description']
author = current_user.id
file = {'file': ("game.zip", f.stream, "application/zip")}
file = {
'game': ("game.zip", game.stream, "application/zip"),
'banner': ("banner", banner.stream, banner.mimetype),
'icon': ("icon", icon.stream, icon.mimetype)
}
fields = {'title': title, 'description': description, 'author':author}
r = requests.post(app.config["DEVCADE_API_URI"] + "games/", files=file, data=fields, headers={"frontend_api_key":app.config["FRONTEND_API_KEY"]})
if r.status_code == 201:
Expand All @@ -53,7 +59,7 @@ def uploadpage():
try:
games = requests.get(app.config["DEVCADE_API_URI"] + "games/").json()
for i in games:
if i['author_username'] == current_user.id:
if i['author'] == current_user.id:
usergames.append(i)
except(Exception):
print("api offline")
Expand All @@ -70,7 +76,7 @@ def download(id):
@login_required
def deleteGame(id):
game = requests.get(app.config['DEVCADE_API_URI'] + "games/" + id).json()
author = game['author_username']
author = game['author']
if(current_user.admin or current_user.id == author):
r = requests.delete(app.config["DEVCADE_API_URI"] + "games/" + id, headers={"frontend_api_key":app.config["FRONTEND_API_KEY"]})
if r.status_code != 200:
Expand Down
3 changes: 2 additions & 1 deletion src/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ def wrapped_function(*args, **kwargs):
groups = flask.session["userinfo"].get("groups", [])
is_eboard = "eboard" in groups
is_rtp = "rtp" in groups
is_devcade_admin = "devcade" in groups
auth_dict = {
"uid": uid,
"first": first,
"last": last,
"picture": picture,
"admin": is_eboard or is_rtp or uid == "cinnamon"
"admin": is_eboard or is_rtp or is_devcade_admin
}
kwargs["auth_dict"] = auth_dict
return func(*args, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions src/templates/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
{%endblock %} {% block content %}
<div class="card-wrapper">{{ gamecard(game) }}</div>
<div class="card-wrapper">
<a class="btn btn-red" href="/download/{{ game.game_id }}">Download Game</a>
<a class="btn btn-red" href="/download/{{ game.id }}">Download Game</a>
</div>
{% if current_user.admin or current_user.id == game.author %}
<h2>Admin stuff:</h2>
<div class="card-wrapper">
<a class="btn btn-red" href="/edit/{{ game.game_id }}">Edit</a>
<a class="btn btn-red" href="/admin/delete/{{ game.game_id }}">Delete</a>
<a class="btn btn-red" href="/edit/{{ game.id }}">Edit</a>
<a class="btn btn-red" href="/admin/delete/{{ game.id }}">Delete</a>
</div>
{% endif %} {% endblock %}
6 changes: 3 additions & 3 deletions src/templates/header.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% macro gamecard(game) %}
<a href="/game/{{ game.game_id }}">
<div class="game-card" style="background-image: url({{ config['DEVCADE_API_URI'] }}games/{{ game.game_id }}/banner)">
<img class="game-icon" src="{{ config['DEVCADE_API_URI'] }}games/{{ game.game_id }}/icon" />
<a href="/game/{{ game.id }}">
<div class="game-card" style="background-image: url({{ config['DEVCADE_API_URI'] }}games/{{ game.id }}/banner)">
<img class="game-icon" src="{{ config['DEVCADE_API_URI'] }}games/{{ game.id }}/icon" />
<div class="game-name">
<div>
<h2>{{ game.name }}</h2>
Expand Down
17 changes: 13 additions & 4 deletions src/templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ <h2>Drop your files here:</h2>
placeholder="Description (max 1500 chars)"
name="description"
></textarea>
<input type="file" name="file" accept=".zip" />
<br>
<label for="game">Game Zip</label>
<input type="file" name="game" accept=".zip" />
<br>
<label for="banner">Banner Image</label>
<input type="file" name="banner" accept="*" />
<br>
<label for="icon">Icon Image</label>
<input type="file" name="icon" accept="*" />
<br>
<input class="btn btn-red" id="apply" value="Upload" type="submit" />
</form>
</div>
Expand All @@ -31,8 +40,7 @@ <h2>How to Upload:</h2>
</li>
<li>Navigate to the newly created publish folder.</li>
<li>
Create a zip archive containing this folder, a <code>banner.png</code>,
and a <code>icon.png</code>
Create a zip archive containing this folder
</li>
<li>
<strong
Expand All @@ -41,7 +49,8 @@ <h2>How to Upload:</h2>
(ex. If the title is `BrickBreaker`, the executable should be
`BrickBreaker`)
</li>
<li>Upload file</li>
<li>Upload zip file</li>
<li>Upload banner and icon images</li>
</ol>
</div>
</div>
Expand Down