Skip to content

Commit ff4664f

Browse files
authored
Merge pull request #37 from ComputerScienceHouse/dev
Update from Dev
2 parents 444e264 + 843c43d commit ff4664f

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

src/app.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ def getgame(id):
3535
@login_required
3636
def uploadgame():
3737
if flask.request.method == 'POST':
38-
f = flask.request.files['file']
38+
game = flask.request.files['game']
39+
banner = flask.request.files['banner']
40+
icon = flask.request.files['icon']
3941
title = flask.request.form['title']
4042
description = flask.request.form['description']
4143
author = current_user.id
42-
file = {'file': ("game.zip", f.stream, "application/zip")}
44+
file = {
45+
'game': ("game.zip", game.stream, "application/zip"),
46+
'banner': ("banner", banner.stream, banner.mimetype),
47+
'icon': ("icon", icon.stream, icon.mimetype)
48+
}
4349
fields = {'title': title, 'description': description, 'author':author}
4450
r = requests.post(app.config["DEVCADE_API_URI"] + "games/", files=file, data=fields, headers={"frontend_api_key":app.config["FRONTEND_API_KEY"]})
4551
if r.status_code == 201:
@@ -53,7 +59,7 @@ def uploadpage():
5359
try:
5460
games = requests.get(app.config["DEVCADE_API_URI"] + "games/").json()
5561
for i in games:
56-
if i['author_username'] == current_user.id:
62+
if i['author'] == current_user.id:
5763
usergames.append(i)
5864
except(Exception):
5965
print("api offline")
@@ -70,7 +76,7 @@ def download(id):
7076
@login_required
7177
def deleteGame(id):
7278
game = requests.get(app.config['DEVCADE_API_URI'] + "games/" + id).json()
73-
author = game['author_username']
79+
author = game['author']
7480
if(current_user.admin or current_user.id == author):
7581
r = requests.delete(app.config["DEVCADE_API_URI"] + "games/" + id, headers={"frontend_api_key":app.config["FRONTEND_API_KEY"]})
7682
if r.status_code != 200:

src/auth.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ def wrapped_function(*args, **kwargs):
1616
groups = flask.session["userinfo"].get("groups", [])
1717
is_eboard = "eboard" in groups
1818
is_rtp = "rtp" in groups
19+
is_devcade_admin = "devcade" in groups
1920
auth_dict = {
2021
"uid": uid,
2122
"first": first,
2223
"last": last,
2324
"picture": picture,
24-
"admin": is_eboard or is_rtp or uid == "cinnamon"
25+
"admin": is_eboard or is_rtp or is_devcade_admin
2526
}
2627
kwargs["auth_dict"] = auth_dict
2728
return func(*args, **kwargs)

src/templates/game.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
{%endblock %} {% block content %}
33
<div class="card-wrapper">{{ gamecard(game) }}</div>
44
<div class="card-wrapper">
5-
<a class="btn btn-red" href="/download/{{ game.game_id }}">Download Game</a>
5+
<a class="btn btn-red" href="/download/{{ game.id }}">Download Game</a>
66
</div>
77
{% if current_user.admin or current_user.id == game.author %}
88
<h2>Admin stuff:</h2>
99
<div class="card-wrapper">
10-
<a class="btn btn-red" href="/edit/{{ game.game_id }}">Edit</a>
11-
<a class="btn btn-red" href="/admin/delete/{{ game.game_id }}">Delete</a>
10+
<a class="btn btn-red" href="/edit/{{ game.id }}">Edit</a>
11+
<a class="btn btn-red" href="/admin/delete/{{ game.id }}">Delete</a>
1212
</div>
1313
{% endif %} {% endblock %}

src/templates/header.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% macro gamecard(game) %}
2-
<a href="/game/{{ game.game_id }}">
3-
<div class="game-card" style="background-image: url({{ config['DEVCADE_API_URI'] }}games/{{ game.game_id }}/banner)">
4-
<img class="game-icon" src="{{ config['DEVCADE_API_URI'] }}games/{{ game.game_id }}/icon" />
2+
<a href="/game/{{ game.id }}">
3+
<div class="game-card" style="background-image: url({{ config['DEVCADE_API_URI'] }}games/{{ game.id }}/banner)">
4+
<img class="game-icon" src="{{ config['DEVCADE_API_URI'] }}games/{{ game.id }}/icon" />
55
<div class="game-name">
66
<div>
77
<h2>{{ game.name }}</h2>

src/templates/upload.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ <h2>Drop your files here:</h2>
1616
placeholder="Description (max 1500 chars)"
1717
name="description"
1818
></textarea>
19-
<input type="file" name="file" accept=".zip" />
19+
<br>
20+
<label for="game">Game Zip</label>
21+
<input type="file" name="game" accept=".zip" />
22+
<br>
23+
<label for="banner">Banner Image</label>
24+
<input type="file" name="banner" accept="*" />
25+
<br>
26+
<label for="icon">Icon Image</label>
27+
<input type="file" name="icon" accept="*" />
28+
<br>
2029
<input class="btn btn-red" id="apply" value="Upload" type="submit" />
2130
</form>
2231
</div>
@@ -31,8 +40,7 @@ <h2>How to Upload:</h2>
3140
</li>
3241
<li>Navigate to the newly created publish folder.</li>
3342
<li>
34-
Create a zip archive containing this folder, a <code>banner.png</code>,
35-
and a <code>icon.png</code>
43+
Create a zip archive containing this folder
3644
</li>
3745
<li>
3846
<strong
@@ -41,7 +49,8 @@ <h2>How to Upload:</h2>
4149
(ex. If the title is `BrickBreaker`, the executable should be
4250
`BrickBreaker`)
4351
</li>
44-
<li>Upload file</li>
52+
<li>Upload zip file</li>
53+
<li>Upload banner and icon images</li>
4554
</ol>
4655
</div>
4756
</div>

0 commit comments

Comments
 (0)