Skip to content

Create Admin views #10

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 2 commits into from
Nov 14, 2022
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
12 changes: 12 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def uploadgame():
f = flask.request.files['file']
title = flask.request.form['title']
description = flask.request.form['description']
author = current_user.uid
file = {'file': ("game.zip", f.stream, "application/zip")}
fields = {'title': title, 'description': description}
r = requests.post(app.config["DEVCADE_API_URI"] + "games/upload", files=file, data=fields)
Expand All @@ -62,6 +63,17 @@ def uploadpage():
print("api offline")
return flask.render_template('upload.html', title='Devcade - Upload', gamelist=usergames)

@app.route('/admin/delete/<id>')
@login_required
def deleteGame(id):
if(current_user.admin):
r = requests.post(app.config["DEVCADE_API_URI"] + "games/delete/" + id)
if r.status_code != 200:
return r.text
else:
return "<p>Stop hacking</p>"
return flask.redirect('/catalog')

@app.errorhandler(Exception)
def page404(e):
eCode = 500
Expand Down
5 changes: 4 additions & 1 deletion src/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ def csh_auth(auth_dict=None):
goto = flask.request.args.get('goto')
if goto == None:
goto = 'homepage'
goto = flask.url_for(goto)
try:
goto = flask.url_for(goto)
except:
goto = flask.url_for('homepage')
return flask.redirect(goto)


Expand Down
8 changes: 8 additions & 0 deletions src/static/css/devcade.css
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ img.header {
max-height: 100%;
}

.std-button{
display: inline-block;
padding: .5em;
border: solid white 2px;
background-color: red;
border-radius: 10px;
}

@media screen and (max-width: 60em) {
.card-wrapper {
max-width: 100%;
Expand Down
18 changes: 11 additions & 7 deletions src/templates/game.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{% extends "header.html" %}
{% block title %}Devcade - {{gamelist[game].name}}{% endblock %}
{% block content %}
{% extends "header.html" %} {% block title %}Devcade - {{gamelist[game].name}}
{%endblock %} {% block content %}
<h1>{{ gamelist[game].name }}</h1>
<p>{{ gamelist[game].author }}</p>
<img class="max" src="{{ gamelist[game].bannerLink }}" />
<p>{{ gamelist[game].description }}</p>
{% endblock %}
<p>{{ gamelist[game].author }}</p>
<img class="max" src="{{ gamelist[game].bannerLink }}" />
<p>{{ gamelist[game].description }}</p>
{% if current_user.admin %}
<div class="card-wrapper">
<a href='/admin/delete/{{ gamelist[game].id }}'><div class="std-button">Delete</div></a>
<div class="std-button">More Admin Stuff...</div>
</div>
{% endif %} {% endblock %}