Compare commits

..

No commits in common. "feature/ui" and "master" have entirely different histories.

15 changed files with 62 additions and 10897 deletions

23
app.py
View file

@ -1,25 +1,6 @@
import os from flask import Flask
from flask import Flask, send_from_directory
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__, static_url_path='/public') app = Flask(__name__)
app.config.from_object('config.Configuration') app.config.from_object('config.Configuration')
db = SQLAlchemy(app) db = SQLAlchemy(app)
@app.route('/js/<path:path>')
def send_js(path):
return send_from_directory('public/js', path)
@app.route('/css/<path:path>')
def send_css(path):
return send_from_directory('public/css', path)
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'public', 'img'),
'favicon.ico',
mimetype='image/vnd.microsoft.icon')

10599
public/css/bulma.css vendored

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,3 +0,0 @@
a {
color: #ff9f00;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 KiB

View file

@ -1,24 +0,0 @@
document.addEventListener('DOMContentLoaded', () => {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach( el => {
el.addEventListener('click', () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});

View file

@ -1,27 +0,0 @@
function searchUser(search) {
matches = [];
users.forEach(user => {
if (user.id.toLowerCase().includes(search.toLowerCase())) {
matches.push(user);
}
});
if (matches.length === 0) {
document.getElementById("users-parent").innerHTML = "<p>No matches found</p>";
} else {
var html = "";
matches.forEach(match => {
html += `
<a href="/users/${match.id}" class="tile is-child box is-4">
<!-- The magical tile element! -->
<p class="title">${ match.id }</p>
<div class="content">
${ match.achievements.length } achievement${(match.achievements.length != 1) ? "s" : "" }
</div>
</a>
`
});
document.getElementById("users-parent").innerHTML = html;
}
}

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
FLASK_APP="endorsement.py" FLASK_DEBUG=true flask run FLASK_APP="endorsement.py" flask run

View file

@ -1,36 +1,21 @@
{% extends 'base.html' %} <html>
<body>
<h2>{{data.name}} by <a href="{{url_for('get_user', id=data.achieved_by)}}">{{ data.achieved_by }} </a></h2>
{% block content %} <ul>
{% for endorser in data.endorsed_by -%}
<div class="section">
<div class="container">
<h2 class="title is-2">Achievement: {{data.name}}</h2>
<h4 class="subtitle is-4">by <a href="{{url_for('get_user', id=data.achieved_by)}}">{{ data.achieved_by }} </a></h4>
<div class="menu">
<p></p>
<ul>
<li>
{% if endorsed -%}
<a href="{{url_for('unendorse_achievement', id=data.id)}}" class="has-text-danger">Unendorse</a>
{% else -%}
<a href="{{url_for('endorse_achievement', id=data.id)}}" class="has-text-success">Endorse</a>
{% endif -%}
</li>
</ul>
<p class="menu-label">Endorsed by</p>
<ul class="menu-list">
{% for endorser in data.endorsed_by -%}
<li> <li>
<a href="{{url_for('get_user', id=endorser.id)}}">{{ endorser.id }} </a> <a href="{{url_for('get_user', id=endorser.id)}}">{{ endorser.id }} </a>
</li> </li>
{% endfor -%} {% endfor -%}
</ul> {% if endorsed -%}
</div> <li>
</div> <a href="{{url_for('unendorse_achievement', id=data.id)}}">Unendorse</a>
</div> </li>
{% else -%}
{% endblock %} <li>
<a href="{{url_for('endorse_achievement', id=data.id)}}">Endorse</a>
</li>
{% endif -%}
</ul>
</body>
</html>

View file

@ -1,42 +1,12 @@
{% extends 'base.html' %} <html>
<body>
<h2>Insert cool name here</h2>
{% block head %} <ul>
<script src="/js/users.js"></script> {% for user in data -%}
{% endblock %} <li>
<a href="{{url_for('get_user', id=user.id)}}">{{ user.id }}</a>: {{ user.achievements|length }} achievement{{ "s" if (user.achievements|length != 1) else "" }}
{% block content %} </li>
<div class="section"> {% endfor -%}
<div class="container"> </ul>
<h1 class="title is-2">Endorsements</h1> </body>
</html>
<div class="field">
<p class="control has-icons-left has-icons-right">
<input oninput="searchUser(this.value)" class="input" type="text" placeholder="Search">
<span class="icon is-small is-left">
<i class="fas fa-search"></i>
</span>
</p>
</div>
<div class="tile is-ancestor">
<div id="users-parent" class="tile is-parent is-vertical">
{% for user in data -%}
<!-- If you update this block, update it also in the js search function -->
<a href="{{url_for('get_user', id=user.id)}}" class="tile is-child box is-4">
<!-- The magical tile element! -->
<p class="title">{{ user.id }}</p>
<div class="content">
{{ user.achievements|length }} achievement{{ "s" if (user.achievements|length != 1) else "" }}
</div>
</a>
{% endfor -%}
</div>
</div>
</div>
</div>
<script>
var users = {{ data|safe }};
</script>
{% endblock %}

View file

@ -1,62 +0,0 @@
<html>
<head>
<link rel="stylesheet" href="/css/bulma.css" type="text/css">
<link rel="stylesheet" href="/css/index.css" type="text/css">
<script src="/js/index.js"></script>
{% block head %}
{% endblock %}
</head>
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="https://bulma.io">
<img src="https://bulma.io/images/bulma-logo.png" width="112" height="28">
</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a href="/" class="navbar-item">
Endorsements
</a>
<a href="/graph" class="navbar-item" disabled>
Graph
</a>
</div>
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<a class="button is-primary">
<strong>Log in</strong>
</a>
</div>
</div>
</div>
</div>
</nav>
<body>
{% block content %}
No content yet.
{% endblock %}
</body>
</html>

View file

@ -1,34 +1,15 @@
{% extends 'base.html' %} <html>
<body>
<form action="" method="post">
{% block content %} {{ form.csrf }}
<div class="section"><div class="container"> <div class="input text">
{{ form.name.label }} {{ form.name }}
<h1 class="title">New achievement</h1> </div>
<form action="" method="post">
{{ form.csrf }} <div class="input submit">
<input type="submit" value="Add" />
<div class="field"> </div>
<label class="label" for="{{form.name.label.for}}">Name</label> </form>
<div class="control has-icons-left has-icons-right"> </body>
<input id="{{form.name.id}}" name="{{form.name.name}}" type="{{form.name.type}}" value="{{form.name.value}}" required="{{form.name.required}}" class="input" placeholder="the bestest boi" > </html>
<span class="icon is-small is-left">
<i class="fas fa-user"></i>
</span>
<span class="icon is-small is-right">
<i class="fas fa-check"></i>
</span>
</div>
</div>
<div class="field">
<div class="control">
<button class="button is-link">Add</button>
</div>
</div>
</form>
</div></div>
{% endblock %}

View file

@ -1,29 +1,13 @@
{% extends 'base.html' %} <html>
<body>
<h2>{{data.id}}</h2>
{% block content %} <ul>
<div class="section"> {% for achievement in data.achievements -%}
<div class="container"> <li>
<a href="{{url_for('get_achievement', id=achievement.id)}}">{{ achievement.name }}</a>: {{ achievement.endorsed_by|length }} endorsement{{ "s" if (achievement.endorsed_by|length != 1) else "" }}
<h1 class="title is-1">User: {{data.id}}</h1> </li>
<h3 class="subtitle is-3">Achievements</h3> {% endfor -%}
<div class="tile is-ancestor"> <li> <a href="{{url_for('add_achievement', id=data.id)}}">Add achievement</a></li>
<div class="tile is-parent is-vertical"> </ul>
{% for achievement in data.achievements -%} </body>
<a href="{{url_for('get_achievement', id=achievement.id)}}" class="tile is-child box is-4"> </html>
<!-- The magical tile element! -->
<p class="title">{{ achievement.name }}</p>
<div class="content">
{{ achievement.endorsed_by|length }} endorsement{{ "s" if (achievement.endorsed_by|length != 1) else "" }}
</div>
</a>
{% else %}
<h5 class="subtitle is-5">No achievements</h5>
{% endfor -%}
</div>
</div>
<a class="button" href="{{url_for('add_achievement', id=data.id)}}">Add achievement</a>
</div>
</div>
{% endblock %}

21
test.py
View file

@ -1,8 +1,5 @@
import random from models import User, Achievement
import string
from app import db from app import db
from models import Achievement, User
db.drop_all() db.drop_all()
db.create_all() db.create_all()
@ -16,22 +13,6 @@ achievementB = Achievement(name="BB", achieved_by=persoonB.id)
achievementA.endorsed_by.append(persoonC) achievementA.endorsed_by.append(persoonC)
# Long generated lists
for i in range(30):
achievement = Achievement(name=''.join(
random.choices(string.ascii_uppercase + string.digits, k=6)),
achieved_by=persoonA.id)
db.session.add(achievement)
people = [
User(id=''.join(random.choices(string.ascii_uppercase +
string.digits, k=6))) for i in range(30)
]
for person in people:
db.session.add(person)
achievementA.endorsed_by.append(person)
db.session.add(persoonA) db.session.add(persoonA)
db.session.add(persoonB) db.session.add(persoonB)
db.session.add(persoonC) db.session.add(persoonC)