Compare commits
88 Commits
vass-page-
...
main
Author | SHA1 | Date | |
---|---|---|---|
fe7d2101e2 | |||
d36405c0a8 | |||
8d928873a6 | |||
0ed9c2daed | |||
39700082e1 | |||
53c35377c6 | |||
2e4f3efe7d | |||
a6241563c7 | |||
88d8de76ec | |||
a1e8c902e2 | |||
4a279e0161 | |||
31f5eaa66b | |||
bfbf4fe5f7 | |||
bb221f7ee0 | |||
46256d328e | |||
9c4b37d775 | |||
5cf410c03e | |||
6170cf9d05 | |||
4a1ab4bed5 | |||
2687233eda | |||
cbe88e2ec6 | |||
ce7bfa15a4 | |||
31479d2fc5 | |||
54635a9f53 | |||
c6cdff7e74 | |||
e48ebb4a31 | |||
a3587a27b8 | |||
7dbab97c06 | |||
5eab487307 | |||
d43a2d4cf2 | |||
0e40040729 | |||
838a5d58d6 | |||
7e87b12812 | |||
696747d0e9 | |||
d13c9bd178 | |||
2239a03c76 | |||
c9734edd87 | |||
7fe675b3bd | |||
009e6ba203 | |||
8e34d55972 | |||
786a4e4902 | |||
d007ab0997 | |||
1913e45328 | |||
9de29a0ab4 | |||
2a8fe5c3f5 | |||
b74f05ba6a | |||
a33a7898a3 | |||
2ebe58c511 | |||
ef87f0ec24 | |||
b9d91ad7dc | |||
d5a3d4b3c8 | |||
dd32fcb04b | |||
aedbb6be6e | |||
c2afe6c93e | |||
2d467f1a12 | |||
c1d7b01e4e | |||
4ccf93f447 | |||
94ea7ecce9 | |||
ac61698d51 | |||
06f6f0d473 | |||
00748020be | |||
4bea179ad4 | |||
c851efa366 | |||
3e37c1ca20 | |||
83fecc9d6f | |||
ab35c01e17 | |||
ddfd4d0d5c | |||
a0437cfba1 | |||
51ce05ce71 | |||
8e3ee3c6c5 | |||
f81dfd6b45 | |||
cad4180301 | |||
4590e715b1 | |||
01d0767a31 | |||
bac4803fb4 | |||
9524a239d8 | |||
a25538a5fe | |||
7139c12617 | |||
3d92673b9f | |||
8dc53754f5 | |||
49a317af92 | |||
6cc32e3b12 | |||
303cd13b3c | |||
8a7242e374 | |||
00514ee175 | |||
bd42bf4215 | |||
7f890dceba | |||
db511a8f7d |
5
.editorconfig
Normal file
@ -0,0 +1,5 @@
|
||||
root = true
|
||||
|
||||
[*.{js,css}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
5
.gitignore
vendored
@ -1 +1,6 @@
|
||||
__django
|
||||
reValuate/db.sqlite3
|
||||
*.sqlite3
|
||||
*/media/*
|
||||
*.pyc
|
||||
*.sqlite3
|
||||
|
24
README.md
@ -1,2 +1,24 @@
|
||||
# CurrencySite
|
||||
# reValuate
|
||||
|
||||
[](#contributors-) [](https://revaluate.eduteh.eu) [](https://discord.gg/eX5wmJuMVp)
|
||||
|
||||
|
||||
School project for helping people consider throwing their trash out in the right bins, in order to help out with recycling.
|
||||
Check out my blog post over [here](https://yamozha.xyz/revaluate/)
|
||||
## Contributors ✨
|
||||
|
||||
Thanks goes to these wonderful people :
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
✨
|
||||
<td align="center"><a href="http://yamozha.github.io"><img src="https://avatars.githubusercontent.com/u/36108495?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yamozha</b></sub></a><br /><a href="https://github.com/yamozha/reValuate/commits?author=yamozha" title="Code">💻</a> <a href="https://github.com/yamozha/reValuate/commits?author=yamozha" title="Tests">⚠️</a></td>
|
||||
✨
|
||||
<td align="center"><a href="https://github.com/vassdeniss"><img src="https://avatars.githubusercontent.com/u/72888249?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vassdeniss</b></sub></a><br /><a href="#design-vassdeniss" title="Design">🎨</a> <a href="https://github.com/yamozha/reValuate/commits?author=vassdeniss" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/pepelen21"><img src="https://avatars.githubusercontent.com/u/61829825?v=4?s=100" width="100px;" alt=""/><br /><sub><b>pepelen21</b></sub></a><br /><a href="#ideas-pepelen21" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
5
reValuate/api/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ApiConfig(AppConfig):
|
||||
name = 'api'
|
15
reValuate/api/serializers.py
Normal file
@ -0,0 +1,15 @@
|
||||
from rest_framework import serializers
|
||||
from users.models import Balance
|
||||
from upload.models import Media
|
||||
|
||||
|
||||
class BalanceSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Balance
|
||||
fields = ("user", "balanceValue")
|
||||
|
||||
class ImageSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Media
|
||||
fields = ("user", "image", "tokenized", "reason", "date", "managed_by")
|
||||
|
31
reValuate/api/views.py
Normal file
@ -0,0 +1,31 @@
|
||||
from rest_framework import status, viewsets, authentication, permissions
|
||||
from rest_framework.decorators import api_view, action
|
||||
from rest_framework.response import Response
|
||||
|
||||
from users.models import Balance
|
||||
from upload.models import Media
|
||||
from .serializers import BalanceSerializer, ImageSerializer
|
||||
|
||||
class AllBalance(viewsets.ModelViewSet):
|
||||
serializer_class = BalanceSerializer
|
||||
http_method_names = ['get']
|
||||
|
||||
def get_queryset(self):
|
||||
return Balance.objects.all()
|
||||
|
||||
|
||||
class BalanceView(viewsets.ModelViewSet):
|
||||
serializer_class = BalanceSerializer
|
||||
http_method_names = ['get']
|
||||
|
||||
def get_queryset(self):
|
||||
return Balance.objects.filter(user=self.request.user)
|
||||
|
||||
|
||||
class ImageView(viewsets.ModelViewSet):
|
||||
serializer_class = ImageSerializer
|
||||
http_method_names = ['get','post']
|
||||
|
||||
def get_queryset(self):
|
||||
return Media.objects.filter(user=self.request.user)
|
||||
|
127
reValuate/home/static/home/css/gallery.css
Normal file
@ -0,0 +1,127 @@
|
||||
.popup {
|
||||
width: 900px;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.popup img {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.show {
|
||||
z-index: 999;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.show .overlay {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0,0,0,.66);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.show .img-show {
|
||||
width: 600px;
|
||||
height: 400px;
|
||||
background: #FFF;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%,-50%);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.img-show span {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
z-index: 99;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.img-show img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Raleway;
|
||||
background-color: #202125;
|
||||
}
|
||||
|
||||
.heading {
|
||||
text-align: center;
|
||||
font-size: 2.0em;
|
||||
letter-spacing: 1px;
|
||||
padding: 40px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.gallery-image {
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.gallery-image img {
|
||||
height: 250px;
|
||||
width: 350px;
|
||||
transform: scale(1.0);
|
||||
transition: transform 0.4s ease;
|
||||
}
|
||||
|
||||
.img-box {
|
||||
box-sizing: content-box;
|
||||
margin: 10px;
|
||||
height: 250px;
|
||||
width: 350px;
|
||||
overflow: hidden;
|
||||
display: inline-block;
|
||||
color: white;
|
||||
position: relative;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.caption {
|
||||
position: absolute;
|
||||
bottom: 5px;
|
||||
left: 20px;
|
||||
opacity: 0.0;
|
||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.transparent-box {
|
||||
height: 250px;
|
||||
width: 350px;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.img-box:hover img { transform: scale(1.1); }
|
||||
.img-box:hover .transparent-box { background-color: rgba(0, 0, 0, 0.5); }
|
||||
|
||||
.img-box:hover .caption {
|
||||
transform: translateY(-20px);
|
||||
opacity: 1.0;
|
||||
}
|
||||
|
||||
.img-box:hover { cursor: pointer; }
|
||||
.caption > p:nth-child(2) { font-size: 0.8em; }
|
||||
.opacity-low { opacity: 0.5; }
|
323
reValuate/home/static/home/css/style.css
Normal file
@ -0,0 +1,323 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
#page-wrap {
|
||||
max-width: 1200px;
|
||||
margin: 50px auto;
|
||||
padding: 20px;
|
||||
background: white;
|
||||
-moz-box-shadow: 0 0 20px #469330;
|
||||
-webkit-box-shadow: 0 0 20px #469330;
|
||||
box-shadow: 0 0 20px #469330;
|
||||
text-align: center;
|
||||
border-radius: 25px;
|
||||
}
|
||||
header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30px 10%;
|
||||
background-color: #469330;
|
||||
position: sticky;
|
||||
}
|
||||
|
||||
.logo {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nav__links a,
|
||||
.cta,
|
||||
.overlay__content a {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-weight: 500;
|
||||
font-size:30px;
|
||||
color: #edf0f1;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav__links {
|
||||
list-style: none;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.nav__links li {
|
||||
padding: 0px 20px;
|
||||
}
|
||||
|
||||
.nav__links li a {
|
||||
transition: color 0.3s ease 0s;
|
||||
}
|
||||
|
||||
.nav__links li a:hover {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.cta {
|
||||
padding: 9px 25px;
|
||||
color: #469330;
|
||||
background-color: white;
|
||||
border: none;
|
||||
border-radius: 50px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s ease 0s;
|
||||
}
|
||||
|
||||
.cta:hover {
|
||||
color: white;
|
||||
background-color: darkgreen;
|
||||
}
|
||||
|
||||
/* Mobile Nav */
|
||||
|
||||
.menu {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.overlay {
|
||||
height: 100%;
|
||||
width: 0;
|
||||
position: fixed;
|
||||
z-index: 99;
|
||||
left: 0;
|
||||
top: 0;
|
||||
background-color: #469330;
|
||||
overflow-x: hidden;
|
||||
transition: width 0.5s ease 0s;
|
||||
}
|
||||
|
||||
.overlay--active {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.overlay__content {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.overlay a {
|
||||
padding: 15px;
|
||||
font-size: 36px;
|
||||
display: block;
|
||||
transition: color 0.3s ease 0s;
|
||||
}
|
||||
|
||||
.overlay a:hover,
|
||||
.overlay a:focus {
|
||||
color: darkgreen;
|
||||
}
|
||||
.overlay .close {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 45px;
|
||||
font-size: 60px;
|
||||
color: #edf0f1;
|
||||
}
|
||||
|
||||
@media screen and (max-height: 450px) {
|
||||
.overlay a {
|
||||
font-size: 20px;
|
||||
}
|
||||
.overlay .close {
|
||||
font-size: 40px;
|
||||
top: 15px;
|
||||
right: 35px;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 1024px) {
|
||||
.nav__links,
|
||||
.cta {
|
||||
display: none;
|
||||
}
|
||||
.menu {
|
||||
display: initial;
|
||||
}
|
||||
}
|
||||
|
||||
html{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
p {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
|
||||
margin: 0 0 30px 0;
|
||||
}
|
||||
|
||||
h1.heading{
|
||||
color: white;
|
||||
font-size: 50px;
|
||||
text-shadow: -1px 0 black, 0 2px black, 2px 0 black, 0 -1px black;
|
||||
}
|
||||
|
||||
ul.emoji{
|
||||
list-style-type: "♻️";
|
||||
}
|
||||
|
||||
.question{
|
||||
color: gray;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
ul.nothing{
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
a.footer{
|
||||
/* background:radial-gradient(circle, rgba(0,159,12,1) 0%, rgba(8,96,0,1) 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent; */
|
||||
color: lightgreen;
|
||||
}
|
||||
footer{
|
||||
font-size: small;
|
||||
text-align: center;
|
||||
left:50%;
|
||||
}
|
||||
|
||||
.centered{
|
||||
display:flex;
|
||||
}
|
||||
|
||||
@-webkit-keyframes text-shadow-pop-right {
|
||||
0% {
|
||||
text-shadow: 0 0 #555,0 0 #555,0 0 #555,0 0 #555,0 0 #555,0 0 #555,0 0 #555,0 0 #555;
|
||||
-webkit-transform: translateX(0);
|
||||
transform: translateX(0)
|
||||
}
|
||||
|
||||
100% {
|
||||
text-shadow: 1px 0 #555,2px 0 #555,3px 0 #555,4px 0 #555,5px 0 #555,6px 0 #555,7px 0 #555,8px 0 #555;
|
||||
-webkit-transform: translateX(-8px);
|
||||
transform: translateX(-8px)
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes text-shadow-pop-right {
|
||||
0% {
|
||||
text-shadow: 0 0 #555,0 0 #555,0 0 #555,0 0 #555,0 0 #555,0 0 #555,0 0 #555,0 0 #555;
|
||||
-webkit-transform: translateX(0);
|
||||
transform: translateX(0)
|
||||
}
|
||||
|
||||
100% {
|
||||
text-shadow: 1px 0 #555,2px 0 #555,3px 0 #555,4px 0 #555,5px 0 #555,6px 0 #555,7px 0 #555,8px 0 #555;
|
||||
-webkit-transform: translateX(-8px);
|
||||
transform: translateX(-8px)
|
||||
}
|
||||
}
|
||||
|
||||
.text-shadow-pop-right{-webkit-animation:text-shadow-pop-right .6s both;animation:text-shadow-pop-right .6s both}
|
||||
|
||||
@-webkit-keyframes scale-in-center {
|
||||
0% {
|
||||
-webkit-transform: scale(0);
|
||||
transform: scale(0);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes scale-in-center {
|
||||
0% {
|
||||
-webkit-transform: scale(0);
|
||||
transform: scale(0);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: scale(1);
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.scale-in-center {
|
||||
-webkit-animation: scale-in-center 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
||||
animation: scale-in-center 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
@-webkit-keyframes tracking-in-expand {
|
||||
0% {
|
||||
letter-spacing: -0.5em;
|
||||
opacity: 0;
|
||||
}
|
||||
40% {
|
||||
opacity: 0.6;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes tracking-in-expand {
|
||||
0% {
|
||||
letter-spacing: -0.5em;
|
||||
opacity: 0;
|
||||
}
|
||||
40% {
|
||||
opacity: 0.6;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.tracking-in-expand {
|
||||
-webkit-animation: tracking-in-expand 0.7s cubic-bezier(0.215, 0.610, 0.355, 1.000) both;
|
||||
animation: tracking-in-expand 0.7s cubic-bezier(0.215, 0.610, 0.355, 1.000) both;
|
||||
animation-delay: .3s;
|
||||
}
|
||||
|
||||
@-webkit-keyframes fade-in-bck {
|
||||
0% {
|
||||
-webkit-transform: translateZ(80px);
|
||||
transform: translateZ(80px);
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: translateZ(0);
|
||||
transform: translateZ(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fade-in-bck {
|
||||
0% {
|
||||
-webkit-transform: translateZ(80px);
|
||||
transform: translateZ(80px);
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: translateZ(0);
|
||||
transform: translateZ(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.fade-in-bck {
|
||||
-webkit-animation: fade-in-bck 0.6s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
|
||||
animation: fade-in-bck 0.6s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
|
||||
}
|
BIN
reValuate/home/static/home/img/Discord-Logo.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
reValuate/home/static/home/img/approved.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
reValuate/home/static/home/img/cross.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
reValuate/home/static/home/img/loading.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
reValuate/home/static/home/img/logo.png
Normal file
After Width: | Height: | Size: 145 KiB |
BIN
reValuate/home/static/home/img/mail.png
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
reValuate/home/static/home/img/question.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
reValuate/home/static/home/img/youtube.png
Normal file
After Width: | Height: | Size: 71 KiB |
12
reValuate/home/static/home/js/mobile.js
Normal file
@ -0,0 +1,12 @@
|
||||
const doc = document;
|
||||
const menuOpen = doc.querySelector(".menu");
|
||||
const menuClose = doc.querySelector(".close");
|
||||
const overlay = doc.querySelector(".overlay");
|
||||
|
||||
menuOpen.addEventListener("click", () => {
|
||||
overlay.classList.add("overlay--active");
|
||||
});
|
||||
|
||||
menuClose.addEventListener("click", () => {
|
||||
overlay.classList.remove("overlay--active");
|
||||
});
|
127
reValuate/home/views.py
Normal file
@ -0,0 +1,127 @@
|
||||
from django.shortcuts import render
|
||||
import os.path
|
||||
from users.models import Balance
|
||||
from django.conf import settings
|
||||
from users.models import User
|
||||
import operator
|
||||
from upload.models import Media
|
||||
import requests
|
||||
from django.db.models import Sum
|
||||
|
||||
|
||||
def homePage(request):
|
||||
iter_var = 0
|
||||
all_balance = 0
|
||||
Cashier = False
|
||||
Processor = False
|
||||
|
||||
|
||||
balObject = Balance.objects.filter(user=request.user.id)
|
||||
userBalance = balObject.values("balanceValue")
|
||||
try:
|
||||
userBalance = userBalance[0]['balanceValue']
|
||||
except IndexError:
|
||||
userBalance = None
|
||||
if request.user.groups.filter(name='Cashier').exists():
|
||||
Cashier = True
|
||||
elif request.user.groups.filter(name='Processor').exists():
|
||||
Processor = True
|
||||
else:
|
||||
pass
|
||||
if request.user.is_authenticated:
|
||||
userQR = f"Name = {request.user.username}, Date Joined = {request.user.date_joined.date()}, ID = {request.user.id}, isCashier={Cashier}, isProcessor={Processor}, Balance = {userBalance}"
|
||||
else:
|
||||
userQR=None
|
||||
|
||||
# Use aggregation that can be calculated in database (fast)
|
||||
all_balance = Balance.objects.all().aggregate(s=Sum("balanceValue"))['s']
|
||||
# print(f"{all_balance}")
|
||||
try:
|
||||
limited_coins = settings.ALL_COINS - all_balance
|
||||
except TypeError:
|
||||
limited_coins = settings.ALL_COINS
|
||||
|
||||
github = requests.get("https://api.github.com/user/36108495").json()
|
||||
|
||||
context = {
|
||||
"isCashier": Cashier,
|
||||
"isProcessor": Processor,
|
||||
"userQR":userQR,
|
||||
"fullbalance": limited_coins,
|
||||
"currencyTotal": all_balance,
|
||||
"userBalance": userBalance,
|
||||
"github": f"https://github.com/podput",
|
||||
}
|
||||
|
||||
|
||||
return render(request, "home.html", context)
|
||||
|
||||
|
||||
def leaderboard(request):
|
||||
users = User.objects.all()
|
||||
leaderboard = {}
|
||||
for i in users:
|
||||
try:
|
||||
username = i.username
|
||||
balance = i.balance.balanceValue
|
||||
# add media counter and other stuff
|
||||
if f"{username}" in leaderboard.keys():
|
||||
leaderboard[username] = balance + leaderboard[username]
|
||||
else:
|
||||
leaderboard[username] = balance
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
leaderboard = dict(sorted(leaderboard.items(), key=operator.itemgetter(0)))
|
||||
leaderboard = dict(reversed(list(leaderboard.items())))
|
||||
|
||||
while len(leaderboard) > 5:
|
||||
leaderboard.pop()
|
||||
|
||||
|
||||
media = Media.objects.all()
|
||||
user_media = {}
|
||||
for i in media:
|
||||
username = i.user.username
|
||||
if f"{username}" in user_media.keys():
|
||||
user_media[username] += 1
|
||||
else:
|
||||
user_media[username] = 1
|
||||
|
||||
user_media = dict(sorted(user_media.items(), key=operator.itemgetter(0)))
|
||||
user_media = dict(reversed(list(user_media.items())))
|
||||
users = {}
|
||||
for i in user_media.keys():
|
||||
iter_user = User.objects.get(username=i)
|
||||
iter_user_media = Media.objects.filter(user=iter_user)
|
||||
if iter_user_media.filter(is_video=True):
|
||||
user_data = {i:{"Videos":len(iter_user_media.filter(is_video=True)),
|
||||
"Images":len(iter_user_media.filter(is_video=False))}}
|
||||
else:
|
||||
user_data = {i:{"Images":len(iter_user_media.filter(is_video=False))}}
|
||||
|
||||
while len(user_media) > 5:
|
||||
user_media.pop()
|
||||
|
||||
# for i in media:
|
||||
# username = i.user.username
|
||||
# image = i.image
|
||||
|
||||
# if f"{username}" in media_count.values():
|
||||
# media_count[username] = image + media_count[username].value
|
||||
# else:
|
||||
# media_count[username] = image
|
||||
|
||||
# print(media_count)
|
||||
|
||||
context = {
|
||||
"leaderboard":leaderboard,
|
||||
"user_media":user_media
|
||||
}
|
||||
|
||||
return render(request, 'leaderboard.html', context)
|
||||
|
||||
|
||||
def about(request):
|
||||
|
||||
return render(request, "about.html")
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 331 B |
Before Width: | Height: | Size: 504 B After Width: | Height: | Size: 504 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 380 B After Width: | Height: | Size: 380 B |
Before Width: | Height: | Size: 677 B After Width: | Height: | Size: 677 B |
Before Width: | Height: | Size: 392 B After Width: | Height: | Size: 392 B |
Before Width: | Height: | Size: 560 B After Width: | Height: | Size: 560 B |
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
Before Width: | Height: | Size: 581 B After Width: | Height: | Size: 581 B |
Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 436 B |
Before Width: | Height: | Size: 560 B After Width: | Height: | Size: 560 B |
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 331 B |
Before Width: | Height: | Size: 280 B After Width: | Height: | Size: 280 B |