Skip to content

Commit 352d7e9

Browse files
committed
Allow deletion by author
1 parent bea63b7 commit 352d7e9

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

src/app.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def uploadgame():
4747
fields = {'title': title, 'description': description, 'author':author}
4848
r = requests.post(app.config["DEVCADE_API_URI"] + "games/upload", files=file, data=fields)
4949
if r.status_code == 200:
50-
return flask.redirect('/')
50+
return flask.redirect('/catalog')
5151
return "<p>" + r.text + "</p>"
5252

5353
@app.route('/upload')
@@ -66,7 +66,12 @@ def uploadpage():
6666
@app.route('/admin/delete/<id>')
6767
@login_required
6868
def deleteGame(id):
69-
if(current_user.admin):
69+
games = requests.get(app.config['DEVCADE_API_URI'] + "games/gamelist").json()
70+
author = ""
71+
for i in games:
72+
if i['id'] == id:
73+
author = i['author']
74+
if(current_user.admin or current_user.id == author):
7075
r = requests.post(app.config["DEVCADE_API_URI"] + "games/delete/" + id)
7176
if r.status_code != 200:
7277
return r.text

src/static/css/devcade.css

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ body {
2424
width: 100%;
2525
min-height: 100vh;
2626
padding: 0 0;
27-
padding-bottom: 2em;
2827
font-family: Rubik, Roboto, sans-serif;
2928
font-size: calc(10pt + 1vmin);
3029
}
@@ -253,14 +252,6 @@ img.header {
253252
max-height: 100%;
254253
}
255254

256-
.std-button{
257-
display: inline-block;
258-
padding: .5em;
259-
border: solid white 2px;
260-
background-color: red;
261-
border-radius: 10px;
262-
}
263-
264255
@media screen and (max-width: 60em) {
265256
.card-wrapper {
266257
max-width: 100%;
@@ -285,6 +276,7 @@ a:hover {
285276
font-family: "Rubik Mono One", Rubik, Roboto, sans-serif;
286277
font-size: 0.6em;
287278
margin-top: 1em;
279+
border: solid black 2px;
288280
}
289281

290282
.btn-red:hover {
@@ -324,6 +316,7 @@ a:hover {
324316
width: 100%;
325317
background-color: var(--csh-tertiary);
326318
color: white;
319+
margin-top: 10px;
327320
}
328321

329322
.feet-flex {
@@ -334,6 +327,11 @@ a:hover {
334327
width: min(100%, 600px);
335328
}
336329

330+
#feet-quote{
331+
padding: 0;
332+
padding-bottom: 5px;
333+
}
334+
337335
.social>img {
338336
height: 2rem;
339337
filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(2deg) brightness(102%) contrast(104%);

src/templates/game.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h1>{{ gamelist[game].name }}</h1>
66
<p>{{ gamelist[game].description }}</p>
77
{% if current_user.admin %}
88
<div class="card-wrapper">
9-
<a href='/admin/delete/{{ gamelist[game].id }}'><div class="std-button">Delete</div></a>
10-
<div class="std-button">More Admin Stuff...</div>
9+
<a href='/admin/delete/{{ gamelist[game].id }}'><div class="btn btn-red">Delete</div></a>
10+
<div class="btn btn-red">More Admin Stuff...</div>
1111
</div>
1212
{% endif %} {% endblock %}

src/templates/upload.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ <h2>How to Upload:</h2>
2626
</ol>
2727
</div>
2828
</div>
29-
<h1>Your files:</h1>
30-
<div id="card-wrapper">
29+
<h1>Your games:</h1>
30+
<div class="card-wrapper">
3131
{% for i in gamelist %}
32-
<a href="/game/i.id }}">
32+
<a href="/game/{{ i.id }}">
3333
<div class="card">
3434
<h2>{{ i.name }}</h2>
3535
<p>{{ i.author }}</p>
36-
<img class="max" src="{{ url_for('static', filename='images/csh_tilted.png') }}" />
36+
<img class="max" src="{{ i.iconLink }}" />
3737
<p>{{ i.desc }}</p>
3838
<p></p>
3939
<a class="btn btn-red" href="/edit/{{ i.id }}">Edit</a>
40+
<a class="btn btn-red" href="/admin/delete/{{ i.id }}">Delete</a>
4041
</div>
4142
</a>
4243
{% endfor %}

0 commit comments

Comments
 (0)