added leaderboard and tweaked a bunch of other things
This commit is contained in:
parent
4a1ab4bed5
commit
6170cf9d05
BIN
reValuate/api/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
reValuate/api/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/api/__pycache__/serializers.cpython-39.pyc
Normal file
BIN
reValuate/api/__pycache__/serializers.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/api/__pycache__/views.cpython-39.pyc
Normal file
BIN
reValuate/api/__pycache__/views.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
reValuate/home/__pycache__/admin.cpython-39.pyc
Normal file
BIN
reValuate/home/__pycache__/admin.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/home/__pycache__/models.cpython-39.pyc
Normal file
BIN
reValuate/home/__pycache__/models.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/home/__pycache__/views.cpython-39.pyc
Normal file
BIN
reValuate/home/__pycache__/views.cpython-39.pyc
Normal file
Binary file not shown.
@ -2,7 +2,8 @@ from django.shortcuts import render
|
|||||||
import os.path
|
import os.path
|
||||||
from users.models import Balance
|
from users.models import Balance
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from users.models import User
|
||||||
|
import operator
|
||||||
|
|
||||||
def homePage(request):
|
def homePage(request):
|
||||||
iter_var = 0
|
iter_var = 0
|
||||||
@ -46,3 +47,22 @@ def homePage(request):
|
|||||||
return render(request, "home.html", context)
|
return render(request, "home.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
def leaderboard(request):
|
||||||
|
users = User.objects.all()
|
||||||
|
leaderboard = {}
|
||||||
|
for i in users:
|
||||||
|
username = i.username
|
||||||
|
balance = i.balance.balanceValue
|
||||||
|
# add media counter
|
||||||
|
if f"{username}" in leaderboard.values():
|
||||||
|
leaderboard[username] = balance + leaderboard[username].value
|
||||||
|
else:
|
||||||
|
leaderboard[username] = balance
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
context = {
|
||||||
|
"leaderboard":dict(sorted(leaderboard.items(), key=operator.itemgetter(0))),
|
||||||
|
}
|
||||||
|
return render(request, 'leaderboard.html', context)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<a class="logo" href="/"><img src="{% static 'home/img/logo.png' %}" style="max-height: 100px;" alt="logo"></a>
|
<a class="logo" href="/"><img src="{% static 'home/img/logo.png' %}" style="max-height: 100px;" alt="logo"></a>
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="nav__links">
|
<ul class="nav__links">
|
||||||
<li><a href="#"><u>Класация</u></a></li>
|
<li><a href="{% url 'leaderboard' %}"><u>Класация</u></a></li>
|
||||||
<li><a href="#"><u>За нас</u></a></li>
|
<li><a href="#"><u>За нас</u></a></li>
|
||||||
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
@ -30,6 +30,14 @@
|
|||||||
<li><a href="{% url 'Media' %}"><u>Прогрес</u></a></li>
|
<li><a href="{% url 'Media' %}"><u>Прогрес</u></a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if isProcessor %}
|
||||||
|
<li><a href="{% url 'admin' %}"><u>Админ</u></a></li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if isCashier %}
|
||||||
|
<li><a href="{% url 'cashier' %}"><u>Качи</u></a></li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
@ -43,9 +51,13 @@
|
|||||||
<div class="overlay">
|
<div class="overlay">
|
||||||
<a class="close">×</a>
|
<a class="close">×</a>
|
||||||
<div class="overlay__content">
|
<div class="overlay__content">
|
||||||
<a href="#">Класация</a>
|
<a href="{% url 'leaderboard' %}">Класация</a>
|
||||||
<a href="#">За нас</a>
|
<a href="#">За нас</a>
|
||||||
<a href="#">Влез!</a>
|
{% if user.is_authenticated %}
|
||||||
|
<a href="{% url 'logout' %}">Излез!</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'login' %}">Влез!</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<p style="color:white;">___</p>
|
<p style="color:white;">___</p>
|
||||||
|
|
||||||
|
@ -17,11 +17,12 @@
|
|||||||
<div id="page-wrap">
|
<div id="page-wrap">
|
||||||
<h1 class="heading">reValuate</h1>
|
<h1 class="heading">reValuate</h1>
|
||||||
<h3>Остават ни още:<br>{{ fullbalance }} reCoins</h3><br>
|
<h3>Остават ни още:<br>{{ fullbalance }} reCoins</h3><br>
|
||||||
|
{% if user.is_authenticated %}
|
||||||
<h3> Ти притежаваш <u>{{ userBalance }}</u> от тях.</h3>
|
<h3> Ти притежаваш <u>{{ userBalance }}</u> от тях.</h3>
|
||||||
<br>
|
<br>
|
||||||
<h3>Твоят QR код:</h3>
|
<h3>Твоят QR код:</h3>
|
||||||
<div id="qr" >{% qr_from_text userQR size="M" %} </div>
|
<div id="qr" >{% qr_from_text userQR size="M" %} </div>
|
||||||
|
{% endif %}
|
||||||
<br>
|
<br>
|
||||||
<hr>
|
<hr>
|
||||||
<br>
|
<br>
|
||||||
|
13
reValuate/templates/leaderboard.html
Normal file
13
reValuate/templates/leaderboard.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Класация{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="centered">
|
||||||
|
|
||||||
|
{% for i, z in leaderboard.items reversed %}
|
||||||
|
|
||||||
|
<h1>{{ forloop.counter }}. {{i}} has {{z}} reCoins </h1><br>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -1,15 +1,35 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block title %}Login{% endblock %}
|
{% block title %}Login{% endblock %}
|
||||||
|
{% block optionalParams %}
|
||||||
|
<style>
|
||||||
|
.buttons{
|
||||||
|
background-color: #469330;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
padding: 15px 32px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 4px 2px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.centered{
|
||||||
|
max-height: 20%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="centered" style="text-align:center;">
|
<div class="centered" style="text-align:center;">
|
||||||
<h2>Log In</h2>
|
<h2>Влез в акаунта си</h2><br>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<button type="submit">Log In</button>
|
<button type="submit" class="buttons">Влез</button><br><br>
|
||||||
|
<a href="{% url 'signup' %}">Нямаш акаунт? Регистрирай се.</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,15 +1,33 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block title %}Sign Up{% endblock %}
|
{% block title %}Sign Up{% endblock %}
|
||||||
|
{% block optionalParams %}
|
||||||
|
<style>
|
||||||
|
.buttons{
|
||||||
|
background-color: #469330;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
padding: 15px 32px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 4px 2px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.centered{
|
||||||
|
max-height: 20%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="centered" >
|
<div class="centered" >
|
||||||
|
|
||||||
<h2>Sign up</h2>
|
<h2>Регистрирай се</h2><br><br>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<button type="submit" style="position:absolute; left:50%; right:50%;">Sign Up</button>
|
<button type="submit" class="buttons" style="position:absolute; left:50%; right:50%;">Регистрация</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -3,29 +3,21 @@
|
|||||||
{% block title %} My Images {% endblock %}
|
{% block title %} My Images {% endblock %}
|
||||||
{% block optionalParams %}
|
{% block optionalParams %}
|
||||||
<link rel="stylesheet" href="{% static 'home/css/gallery.css' %}">
|
<link rel="stylesheet" href="{% static 'home/css/gallery.css' %}">
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
<style>
|
||||||
<script>
|
header{
|
||||||
$(function () {
|
width: 100%;
|
||||||
"use strict";
|
}
|
||||||
|
container{
|
||||||
$(".popup img").click(function () {
|
display: flex;
|
||||||
var $src = $(this).attr("src");
|
align-items: center;
|
||||||
$(".show").fadeIn();
|
}
|
||||||
$(".img-show img").attr("src", $src);
|
</style>
|
||||||
});
|
|
||||||
|
|
||||||
$("span, .overlay").click(function () {
|
|
||||||
$(".show").fadeOut();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
|
|
||||||
<p class="heading">Твоята медия</p>
|
<p class="heading">Твоята медия</p>
|
||||||
|
<div class="container">
|
||||||
{% for i in get_status reversed %}
|
{% for i in get_status reversed %}
|
||||||
{% if i.is_video %}
|
{% if i.is_video %}
|
||||||
<div class="gallery-image popup">
|
<div class="gallery-image popup">
|
||||||
@ -78,6 +70,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="show">
|
<div class="show">
|
||||||
<div class="overlay"></div>
|
<div class="overlay"></div>
|
||||||
<div class="img-show">
|
<div class="img-show">
|
||||||
|
@ -53,6 +53,8 @@
|
|||||||
|
|
||||||
.centered{
|
.centered{
|
||||||
font-size: 50px;
|
font-size: 50px;
|
||||||
|
max-height: 20%;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert {
|
.alert {
|
||||||
@ -75,7 +77,6 @@
|
|||||||
.closebtn:hover {
|
.closebtn:hover {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
BIN
reValuate/upload/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
reValuate/upload/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/upload/__pycache__/admin.cpython-39.pyc
Normal file
BIN
reValuate/upload/__pycache__/admin.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/upload/__pycache__/forms.cpython-39.pyc
Normal file
BIN
reValuate/upload/__pycache__/forms.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/upload/__pycache__/models.cpython-39.pyc
Normal file
BIN
reValuate/upload/__pycache__/models.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/upload/__pycache__/validators.cpython-39.pyc
Normal file
BIN
reValuate/upload/__pycache__/validators.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/upload/__pycache__/views.cpython-39.pyc
Normal file
BIN
reValuate/upload/__pycache__/views.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
reValuate/upload/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
reValuate/upload/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/users/__pycache__/admin.cpython-39.pyc
Normal file
BIN
reValuate/users/__pycache__/admin.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/users/__pycache__/models.cpython-39.pyc
Normal file
BIN
reValuate/users/__pycache__/models.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/users/__pycache__/urls.cpython-39.pyc
Normal file
BIN
reValuate/users/__pycache__/urls.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/users/__pycache__/views.cpython-39.pyc
Normal file
BIN
reValuate/users/__pycache__/views.cpython-39.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
reValuate/users/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
reValuate/users/migrations/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/website/__pycache__/settings.cpython-39.pyc
Normal file
BIN
reValuate/website/__pycache__/settings.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/website/__pycache__/urls.cpython-39.pyc
Normal file
BIN
reValuate/website/__pycache__/urls.cpython-39.pyc
Normal file
Binary file not shown.
BIN
reValuate/website/__pycache__/wsgi.cpython-39.pyc
Normal file
BIN
reValuate/website/__pycache__/wsgi.cpython-39.pyc
Normal file
Binary file not shown.
@ -15,7 +15,7 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from home.views import homePage
|
from home.views import homePage, leaderboard
|
||||||
from rest_framework import routers, urls
|
from rest_framework import routers, urls
|
||||||
from api.views import BalanceView, ImageView
|
from api.views import BalanceView, ImageView
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -41,9 +41,10 @@ urlpatterns = [
|
|||||||
path("view_media/", viewMedia, name="Media"),
|
path("view_media/", viewMedia, name="Media"),
|
||||||
path("get_balance/",getBalance, name="Balance" ),
|
path("get_balance/",getBalance, name="Balance" ),
|
||||||
path("add_balance/", addToBalance, name="Add"),
|
path("add_balance/", addToBalance, name="Add"),
|
||||||
path("remove_balance/", removeBalance, name="Add"),
|
path("remove_balance/", removeBalance, name="cashier"),
|
||||||
path("admin/", adminView, name="admin"),
|
path("admin/", adminView, name="admin"),
|
||||||
path('api/', include(router.urls))
|
path('api/', include(router.urls)),
|
||||||
|
path("leaderboard/", leaderboard, name="leaderboard")
|
||||||
|
|
||||||
]
|
]
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
Reference in New Issue
Block a user