final TOUCHESSS
This commit is contained in:
parent
9de29a0ab4
commit
1913e45328
reValuate
db.sqlite3
home
media
1
Against_Nature_20_second_Clip-uFutjAVqsdQ.mp4Against_Nature_20_second_Clip-uFutjAVqsdQ_2xZOfFS.mp4Against_Nature_20_second_Clip-uFutjAVqsdQ_85ktnm9.mp4Against_Nature_20_second_Clip-uFutjAVqsdQ_E7gQt5b.mp4Against_Nature_20_second_Clip-uFutjAVqsdQ_K58VDLu.mp4PngItem_1280311.pngpexels-mali-maeder-802221.jpgpexels-mali-maeder-802221_eeYIsOS.jpg
images/1
templates
upload
__pycache__
forms.pymigrations
0015_auto_20210315_1745.py0016_videos.py0017_auto_20210315_1838.py0018_auto_20210315_1839.py0019_auto_20210315_1841.py0020_auto_20210315_1847.py0021_auto_20210315_1848.py0022_auto_20210315_1852.py0023_auto_20210315_1901.py
models.pyviews.py__pycache__
0015_auto_20210315_1745.cpython-38.pyc0016_videos.cpython-38.pyc0017_auto_20210315_1838.cpython-38.pyc0018_auto_20210315_1839.cpython-38.pyc0019_auto_20210315_1841.cpython-38.pyc0020_auto_20210315_1847.cpython-38.pyc0021_auto_20210315_1848.cpython-38.pyc0022_auto_20210315_1852.cpython-38.pyc0023_auto_20210315_1901.cpython-38.pyc
users
website
Binary file not shown.
Binary file not shown.
@ -1,19 +1,27 @@
|
|||||||
from django.shortcuts import render
|
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
|
||||||
|
|
||||||
|
|
||||||
def homePage(request):
|
def homePage(request):
|
||||||
iter_var = 0
|
iter_var = 0
|
||||||
all_balance = []
|
all_balance = []
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
balObject = Balance.objects.filter(user=request.user.id)
|
balObject = Balance.objects.filter(user=request.user.id)
|
||||||
userBalance = balObject.values("balanceValue")
|
userBalance = balObject.values("balanceValue")
|
||||||
|
userQR = f"Name = {request.user.username}, Date Joined = {request.user.date_joined.date()}, ID = {request.user.id}, Balance = {userBalance[0]['balanceValue']}"
|
||||||
a = Balance.objects.all()
|
a = Balance.objects.all()
|
||||||
|
|
||||||
for user in a:
|
for user in a:
|
||||||
all_balance.append(user.balanceValue)
|
all_balance.append(user.balanceValue)
|
||||||
print(f"{all_balance}")
|
print(f"{all_balance}")
|
||||||
|
limited_coins = settings.ALL_COINS - sum(all_balance)
|
||||||
context = {
|
context = {
|
||||||
|
"userQR":userQR,
|
||||||
|
"fullbalance": limited_coins,
|
||||||
"currencyTotal": sum(all_balance),
|
"currencyTotal": sum(all_balance),
|
||||||
"userBalance": userBalance[0]["balanceValue"]
|
"userBalance": userBalance[0]["balanceValue"]
|
||||||
}
|
}
|
||||||
|
BIN
reValuate/media/1/Against_Nature_20_second_Clip-uFutjAVqsdQ.mp4
Normal file
BIN
reValuate/media/1/Against_Nature_20_second_Clip-uFutjAVqsdQ.mp4
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
reValuate/media/1/PngItem_1280311.png
Normal file
BIN
reValuate/media/1/PngItem_1280311.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 102 KiB |
BIN
reValuate/media/1/pexels-mali-maeder-802221.jpg
Normal file
BIN
reValuate/media/1/pexels-mali-maeder-802221.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 747 KiB |
BIN
reValuate/media/1/pexels-mali-maeder-802221_eeYIsOS.jpg
Normal file
BIN
reValuate/media/1/pexels-mali-maeder-802221_eeYIsOS.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 747 KiB |
BIN
reValuate/media/images/1/1259275.jpg
Normal file
BIN
reValuate/media/images/1/1259275.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 2.7 MiB |
BIN
reValuate/media/images/1/1259275_FOPUx7z.jpg
Normal file
BIN
reValuate/media/images/1/1259275_FOPUx7z.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 2.7 MiB |
BIN
reValuate/media/images/1/pexels-mali-maeder-802221.jpg
Normal file
BIN
reValuate/media/images/1/pexels-mali-maeder-802221.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 747 KiB |
BIN
reValuate/media/images/1/pexels-mali-maeder-802221_LhXpYHV.jpg
Normal file
BIN
reValuate/media/images/1/pexels-mali-maeder-802221_LhXpYHV.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 747 KiB |
BIN
reValuate/media/images/1/pexels-mali-maeder-802221_o7hSVlc.jpg
Normal file
BIN
reValuate/media/images/1/pexels-mali-maeder-802221_o7hSVlc.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 747 KiB |
BIN
reValuate/media/images/1/wp2058634-3840x1080-wallpapers.jpg
Normal file
BIN
reValuate/media/images/1/wp2058634-3840x1080-wallpapers.jpg
Normal file
Binary file not shown.
After ![]() (image error) Size: 44 KiB |
Binary file not shown.
After ![]() (image error) Size: 44 KiB |
@ -47,19 +47,23 @@
|
|||||||
{% if image %}
|
{% if image %}
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<p style="text-align: center;">Качено от: <br><p style="border:2px; border-color: #4CAF50; border-style: dashed; text-align: center;">{{username}}</p></p><br><br>
|
<p style="text-align: center;">Качено от: <br><p style="border:2px; border-color: #4CAF50; border-style: dashed; text-align: center;">{{username}}</p></p><br>
|
||||||
|
|
||||||
<div class="choice">
|
<div class="choice">
|
||||||
|
{% if is_video %}
|
||||||
|
<video style="display: block; margin: 0 auto; max-width:500px; max-height: 500px;" width="500" controls>
|
||||||
|
<source src="/media/{{ image }}" type="video/mp4">
|
||||||
|
</video>
|
||||||
|
{% else %}
|
||||||
<img src="/media/{{ image }}" width="500" width="500" ><br>
|
<img src="/media/{{ image }}" width="500" width="500" ><br>
|
||||||
|
{% endif %}
|
||||||
</div><br>
|
</div><br>
|
||||||
<p style="text-shadow: 0 0 2px #28a745; float: left;">{{time}} <p style="text-shadow: 0 0 2px #28a745; float: right;">{{date}}</p></p>
|
<p style="text-shadow: 0 0 2px #28a745; float: left;">{{time}} <p style="text-shadow: 0 0 2px #28a745; float: right;">{{date}}</p></p>
|
||||||
</div>
|
</div>
|
||||||
|
<br><br><br>
|
||||||
<div class="choiceButtons">
|
<div class="choiceButtons">
|
||||||
|
|
||||||
|
|
||||||
<input name="isValid" type="submit" value="Valid" class="Buttons">Валидна</input>
|
<input name="isValid" type="submit" value="Valid" class="Buttons">
|
||||||
<input name="isValid" type="submit" value="Invalid" class="Buttons">
|
<input name="isValid" type="submit" value="Invalid" class="Buttons">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{% block title %}reValuate{% endblock %}</title>
|
<title>{% block title %}reValuate{% endblock %}</title>
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load qr_code %}
|
||||||
{% block optionalParams %} {% endblock %}
|
{% block optionalParams %} {% endblock %}
|
||||||
|
|
||||||
<!-- Required meta tags -->
|
<!-- Required meta tags -->
|
||||||
@ -27,9 +28,11 @@
|
|||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item d-none d-md-block" >
|
<li class="nav-item d-none d-md-block" >
|
||||||
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<a class="nav-link" href="/upload/">Качи</a>
|
<a class="nav-link" href="/upload/">Качи</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item d-none d-md-block" >
|
<li class="nav-item d-none d-md-block" >
|
||||||
|
|
||||||
@ -38,8 +41,9 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto" style="right: 0; left: auto;">
|
||||||
<li class="nav-item dropdown " >
|
<li class="nav-item dropdown " >
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
@ -47,15 +51,14 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
Акaунт
|
Акaунт
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu animate slideIn" aria-labelledby="navbarDropdown" >
|
<div class="dropdown-menu animate slideIn dropdown-menu-right" style="text-align: center;" aria-labelledby="navbarDropdown" >
|
||||||
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<a class="dropdown-item "href="/view_media/">Прогрес</a>
|
<a class="dropdown-item "href="/view_media/">Прогрес</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
|
|
||||||
<a class="dropdown-item "href="{%url 'logout'%}">Излизане </a>
|
<a class="dropdown-item "href="{%url 'logout'%}">Излизане </a>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="dropdown-item" href="/users/signup"> Регистрация </a>
|
<a class="dropdown-item" href="/users/signup"> Регистрация </a>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load qr_code %}
|
||||||
<link rel="stylesheet" href="/static/home/css/main.css" />
|
<link rel="stylesheet" href="/static/home/css/main.css" />
|
||||||
<noscript><link rel="stylesheet" href="/static/home/css/noscript.css" /></noscript>
|
<noscript><link rel="stylesheet" href="/static/home/css/noscript.css" /></noscript>
|
||||||
<script src="http://github.hubspot.com/odometer/odometer.js"></script>
|
<script src="http://github.hubspot.com/odometer/odometer.js"></script>
|
||||||
@ -42,7 +43,7 @@
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto" style="right: 0; left: auto;">
|
||||||
<li class="nav-item dropdown " >
|
<li class="nav-item dropdown " >
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
@ -51,8 +52,10 @@
|
|||||||
Акaунт
|
Акaунт
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu animate slideIn" aria-labelledby="navbarDropdown" >
|
<div class="dropdown-menu animate slideIn dropdown-menu-right" style="text-align: center;" aria-labelledby="navbarDropdown" >
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
|
<div class="dropdown-item"> {% qr_from_text userQR size="T" %} </div>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item "href="/view_media/">Прогрес</a>
|
<a class="dropdown-item "href="/view_media/">Прогрес</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
|
|
||||||
@ -144,7 +147,7 @@
|
|||||||
<div class="row gtr-150">
|
<div class="row gtr-150">
|
||||||
<div class="col-6 col-12-medium">
|
<div class="col-6 col-12-medium">
|
||||||
<header class="major">
|
<header class="major">
|
||||||
<h2>Раздадени точки:<br />
|
<h2>Остават още:<br />
|
||||||
</h2>
|
</h2>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@ -156,7 +159,7 @@
|
|||||||
-moz-background-clip: text;
|
-moz-background-clip: text;
|
||||||
-moz-text-fill-color: transparent;
|
-moz-text-fill-color: transparent;
|
||||||
font-size:70px;
|
font-size:70px;
|
||||||
">{{ currencyTotal }}</div>
|
">{{ fullbalance }} reCoins</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
29
reValuate/templates/removeBalance.html
Normal file
29
reValuate/templates/removeBalance.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %} Update Balance {% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="centered">
|
||||||
|
|
||||||
|
{% if request.user.is_superuser %}
|
||||||
|
|
||||||
|
|
||||||
|
<p>Hello, {{ user.username }} !</p>
|
||||||
|
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input name="user_instance" id="user_instance" placeholder="Pencho Slaveikov"><br>
|
||||||
|
<input name="tokens" id="tokens" placeholder="523...">
|
||||||
|
<button type="submit">Upload</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
<h1>Unauthorized</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
@ -24,7 +24,13 @@
|
|||||||
|
|
||||||
{% for i in get_status reversed %}
|
{% for i in get_status reversed %}
|
||||||
<div class="slide" width=500px height=500px>
|
<div class="slide" width=500px height=500px>
|
||||||
|
{% if i.is_video %}
|
||||||
|
<video style="display: block; margin: 0 auto; max-width:500px; max-height: 500px;" width="500" controls>
|
||||||
|
<source src="/media/{{ i.image }}" type="video/mp4">
|
||||||
|
</video>
|
||||||
|
{% else %}
|
||||||
<img src="/media/{{ i.image }}" style=" display: block; margin: 0 auto; max-width:500px; max-height: 500px;"/>
|
<img src="/media/{{ i.image }}" style=" display: block; margin: 0 auto; max-width:500px; max-height: 500px;"/>
|
||||||
|
{% endif %}
|
||||||
<p style="text-shadow: 0 0 2px #28a745; float: left;">{{forloop.counter}}/{{img_number}} <p style="text-shadow: 0 0 2px #28a745; float: right;">{{i.date}}</p></p>
|
<p style="text-shadow: 0 0 2px #28a745; float: left;">{{forloop.counter}}/{{img_number}} <p style="text-shadow: 0 0 2px #28a745; float: right;">{{i.date}}</p></p>
|
||||||
<br><br>
|
<br><br>
|
||||||
{% if i.reason %}
|
{% if i.reason %}
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<label for="image" style="font-size: 32px;">Качи снимка! </label><br><br><br>
|
<label for="image" style="font-size: 32px;">Качи снимка! </label><br><br><br>
|
||||||
<input id="image" type="file" name="image" required><br><br><br><br>
|
<input id="image" style="margin: 0 auto;" type="file" name="image" required><br>
|
||||||
<br>
|
<br>
|
||||||
<button class="Buttons" type="submit">Качи!</button>
|
<button class="Buttons" type="submit">Качи!</button>
|
||||||
</form>
|
</form>
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,12 +1,12 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
from .models import Image
|
from .models import Media
|
||||||
|
|
||||||
|
|
||||||
class ImageForm(forms.ModelForm):
|
class ImageForm(forms.ModelForm):
|
||||||
"""Form for the image model"""
|
"""Form for the image model"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Image
|
model = Media
|
||||||
fields = ('image',)
|
fields = ['image']
|
||||||
|
|
||||||
# class VideoForm(forms.ModelForm):
|
# class VideoForm(forms.ModelForm):
|
||||||
# """Form for the image model"""
|
# """Form for the image model"""
|
||||||
|
20
reValuate/upload/migrations/0015_auto_20210315_1745.py
Normal file
20
reValuate/upload/migrations/0015_auto_20210315_1745.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-15 15:45
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import upload.models
|
||||||
|
import upload.validators
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('upload', '0014_image_time'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='image',
|
||||||
|
name='image',
|
||||||
|
field=models.ImageField(upload_to=upload.models.imagesPath, validators=[upload.validators.imageValidate]),
|
||||||
|
),
|
||||||
|
]
|
35
reValuate/upload/migrations/0016_videos.py
Normal file
35
reValuate/upload/migrations/0016_videos.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-15 16:14
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import upload.models
|
||||||
|
import upload.validators
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('upload', '0015_auto_20210315_1745'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Videos',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('video', models.FileField(upload_to=upload.models.videosPath, validators=[upload.validators.videoValidate])),
|
||||||
|
('tokenized', models.BooleanField(blank=True, default=None, max_length=3, null=True)),
|
||||||
|
('reason', models.CharField(max_length=120)),
|
||||||
|
('date', models.DateField(default=datetime.date.today)),
|
||||||
|
('time', models.TimeField(auto_now=True)),
|
||||||
|
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'video',
|
||||||
|
'verbose_name_plural': 'videos',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
23
reValuate/upload/migrations/0017_auto_20210315_1838.py
Normal file
23
reValuate/upload/migrations/0017_auto_20210315_1838.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-15 16:38
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import upload.models
|
||||||
|
import upload.validators
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('upload', '0016_videos'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='image',
|
||||||
|
name='video',
|
||||||
|
field=models.FileField(default=None, upload_to=upload.models.videosPath, validators=[upload.validators.videoValidate]),
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Videos',
|
||||||
|
),
|
||||||
|
]
|
20
reValuate/upload/migrations/0018_auto_20210315_1839.py
Normal file
20
reValuate/upload/migrations/0018_auto_20210315_1839.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-15 16:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import upload.models
|
||||||
|
import upload.validators
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('upload', '0017_auto_20210315_1838'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='image',
|
||||||
|
name='video',
|
||||||
|
field=models.FileField(blank=True, default=None, null=True, upload_to=upload.models.videosPath, validators=[upload.validators.videoValidate]),
|
||||||
|
),
|
||||||
|
]
|
20
reValuate/upload/migrations/0019_auto_20210315_1841.py
Normal file
20
reValuate/upload/migrations/0019_auto_20210315_1841.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-15 16:41
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import upload.models
|
||||||
|
import upload.validators
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('upload', '0018_auto_20210315_1839'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='image',
|
||||||
|
name='image',
|
||||||
|
field=models.ImageField(blank=True, null=True, upload_to=upload.models.imagesPath, validators=[upload.validators.imageValidate]),
|
||||||
|
),
|
||||||
|
]
|
20
reValuate/upload/migrations/0020_auto_20210315_1847.py
Normal file
20
reValuate/upload/migrations/0020_auto_20210315_1847.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-15 16:47
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import upload.models
|
||||||
|
import upload.validators
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('upload', '0019_auto_20210315_1841'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='image',
|
||||||
|
name='image',
|
||||||
|
field=models.FileField(blank=True, null=True, upload_to=upload.models.imagesPath, validators=[upload.validators.imageValidate]),
|
||||||
|
),
|
||||||
|
]
|
24
reValuate/upload/migrations/0021_auto_20210315_1848.py
Normal file
24
reValuate/upload/migrations/0021_auto_20210315_1848.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-15 16:48
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import upload.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('upload', '0020_auto_20210315_1847'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='image',
|
||||||
|
name='image',
|
||||||
|
field=models.FileField(blank=True, null=True, upload_to=upload.models.imagesPath),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='image',
|
||||||
|
name='video',
|
||||||
|
field=models.FileField(blank=True, default=None, null=True, upload_to=upload.models.videosPath),
|
||||||
|
),
|
||||||
|
]
|
22
reValuate/upload/migrations/0022_auto_20210315_1852.py
Normal file
22
reValuate/upload/migrations/0022_auto_20210315_1852.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-15 16:52
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('upload', '0021_auto_20210315_1848'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='image',
|
||||||
|
name='video',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='image',
|
||||||
|
name='is_video',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
19
reValuate/upload/migrations/0023_auto_20210315_1901.py
Normal file
19
reValuate/upload/migrations/0023_auto_20210315_1901.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 3.1.6 on 2021-03-15 17:01
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('upload', '0022_auto_20210315_1852'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name='Image',
|
||||||
|
new_name='Media',
|
||||||
|
),
|
||||||
|
]
|
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.
@ -13,14 +13,15 @@ from datetime import date
|
|||||||
|
|
||||||
def imagesPath(instance, filename):
|
def imagesPath(instance, filename):
|
||||||
# file will be uploaded to MEDIA_ROOT/user_<id>/<filename>
|
# file will be uploaded to MEDIA_ROOT/user_<id>/<filename>
|
||||||
return 'images/{0}/{1}'.format(instance.user.id, filename)
|
return '{0}/{1}'.format(instance.user.id, filename)
|
||||||
|
|
||||||
def videosPath(instance,filename):
|
def videosPath(instance,filename):
|
||||||
return f"videos/{instance.user.id}/{filename}"
|
return f"{instance.user.id}/videos/{filename}"
|
||||||
|
|
||||||
class Image(models.Model):
|
class Media(models.Model):
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
|
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
|
||||||
image = models.ImageField(upload_to=imagesPath,validators=[imageValidate], unique=True)
|
image = models.FileField(upload_to=imagesPath, blank=True, null=True,)
|
||||||
|
is_video = models.BooleanField(default=False)
|
||||||
tokenized = models.BooleanField(blank=True, null=True, default=None, max_length=3)
|
tokenized = models.BooleanField(blank=True, null=True, default=None, max_length=3)
|
||||||
reason = models.CharField(max_length=120)
|
reason = models.CharField(max_length=120)
|
||||||
date = models.DateField(default=date.today)
|
date = models.DateField(default=date.today)
|
||||||
@ -31,12 +32,14 @@ class Image(models.Model):
|
|||||||
verbose_name = 'image'
|
verbose_name = 'image'
|
||||||
verbose_name_plural = 'images'
|
verbose_name_plural = 'images'
|
||||||
|
|
||||||
|
|
||||||
# class Videos(models.Model):
|
# class Videos(models.Model):
|
||||||
# user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
|
# user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
|
||||||
# video = models.FileField(upload_to=videosPath, validators=[videoValidate])
|
# video = models.FileField(upload_to=videosPath, validators=[videoValidate])
|
||||||
# tokenized = models.BooleanField(blank=True, null=True, default=None, max_length=3)
|
# tokenized = models.BooleanField(blank=True, null=True, default=None, max_length=3)
|
||||||
# reason = models.CharField(max_length=120)
|
# reason = models.CharField(max_length=120)
|
||||||
|
# date = models.DateField(default=date.today)
|
||||||
|
# time = models.TimeField(auto_now=True)
|
||||||
|
|
||||||
|
|
||||||
# class Meta:
|
# class Meta:
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
import os.path
|
import os.path
|
||||||
import os
|
import os
|
||||||
from .forms import ImageForm
|
|
||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import FileSystemStorage
|
||||||
from .models import Image
|
from .models import Media
|
||||||
|
from .forms import ImageForm
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
def uploadContent(request):
|
def uploadContent(request):
|
||||||
@ -27,14 +27,31 @@ def imageUpload(request):
|
|||||||
|
|
||||||
print(request.user.id)
|
print(request.user.id)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
||||||
|
if "image" in request.FILES['image'].content_type:
|
||||||
|
print("Image")
|
||||||
form = ImageForm(request.POST, request.FILES)
|
form = ImageForm(request.POST, request.FILES)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
userIdModel = Image.objects.filter(user=request.user.id)
|
|
||||||
img_obj = form.instance
|
img_obj = form.instance
|
||||||
img_obj.user = request.user
|
img_obj.user = request.user
|
||||||
form.save()
|
form.save()
|
||||||
return render(request, 'uploadImage.html', {'form': form, 'img_obj': img_obj})
|
return render(request, 'uploadImage.html', {'form': form, 'img_obj': img_obj})
|
||||||
|
|
||||||
|
elif "video" in request.FILES['image'].content_type:
|
||||||
|
form = ImageForm(request.POST, request.FILES)
|
||||||
|
print("Video")
|
||||||
|
print(request.FILES['image'])
|
||||||
|
if form.is_valid():
|
||||||
|
video_obj = form.instance
|
||||||
|
video_obj.user = request.user
|
||||||
|
video_obj.is_video = True
|
||||||
|
form.save()
|
||||||
|
return render(request, 'uploadImage.html', {'form': form, 'img_obj': video_obj})
|
||||||
|
else:
|
||||||
|
raise Exception("What")
|
||||||
|
else:
|
||||||
|
raise TypeError("Invalid File")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = ImageForm()
|
form = ImageForm()
|
||||||
return render(request, 'uploadImage.html', {'form': form})
|
return render(request, 'uploadImage.html', {'form': form})
|
||||||
@ -56,8 +73,9 @@ def imageUpload(request):
|
|||||||
|
|
||||||
|
|
||||||
def viewMedia(request):
|
def viewMedia(request):
|
||||||
get_status = Image.objects.filter(user_id=request.user.id)
|
get_status = Media.objects.filter(user_id=request.user.id)
|
||||||
img_list = os.listdir(settings.MEDIA_ROOT + f"images/{request.user.id}/")
|
img_list = os.listdir(settings.MEDIA_ROOT + f"{request.user.id}/")
|
||||||
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"id":request.user.id,
|
"id":request.user.id,
|
||||||
|
Binary file not shown.
@ -5,7 +5,7 @@ from .models import Balance
|
|||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from upload.models import Image
|
from upload.models import Media
|
||||||
|
|
||||||
# need to make oauth facebook login
|
# need to make oauth facebook login
|
||||||
class SignUpView(generic.CreateView):
|
class SignUpView(generic.CreateView):
|
||||||
@ -40,17 +40,18 @@ def removeBalance(request):
|
|||||||
balRem = None
|
balRem = None
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
tokens = request.POST["tokens"]
|
tokens = request.POST["tokens"]
|
||||||
tokens = int(tokens)
|
tokens = int(tokens) * -1
|
||||||
user_given = request.POST["user_instance"]
|
user_given = request.POST["user_instance"]
|
||||||
try:
|
try:
|
||||||
user_instance = Balance.objects.get(user=user_given)
|
user_instance = Balance.objects.get(user=user_given)
|
||||||
sum_balance = user_instance.balanceValue - tokens
|
sum_balance = user_instance.balanceValue + tokens
|
||||||
balAdd = Balance(balanceValue=sum_balance, user_id=user_instance)
|
balRem = Balance(balanceValue=sum_balance, user_id=user_instance)
|
||||||
balAdd.save()
|
balRem.save()
|
||||||
print(balAdd)
|
print(balRem)
|
||||||
except Balance.DoesNotExist:
|
except Balance.DoesNotExist:
|
||||||
messages.error(request, f"User{user_given} doesn't have balance")
|
balRem = Balance(balanceValue=tokens, user_id=user_given)
|
||||||
return render(request,"getBalance.html", {"userBalance":balAdd})
|
balRem.save()
|
||||||
|
return render(request,"getBalance.html", {"userBalance":balRem})
|
||||||
else:
|
else:
|
||||||
return render(request,"removeBalance.html")
|
return render(request,"removeBalance.html")
|
||||||
|
|
||||||
@ -65,9 +66,10 @@ def getBalance(request):
|
|||||||
|
|
||||||
def adminView(request):
|
def adminView(request):
|
||||||
try:
|
try:
|
||||||
latestPicture = Image.objects.filter(tokenized=None)
|
latestPicture = Media.objects.filter(tokenized=None)
|
||||||
latestPicture, userId, date, time = latestPicture.values("image")[0]["image"], latestPicture.values("user_id")[0]["user_id"], latestPicture.values("date")[0]["date"], latestPicture.values("time")[0]["time"]
|
latestPicture, userId, date, time, is_video = latestPicture.values("image")[0]["image"], latestPicture.values("user_id")[0]["user_id"], latestPicture.values("date")[0]["date"], latestPicture.values("time")[0]["time"], latestPicture.values("is_video")[0]["is_video"]
|
||||||
username = User.objects.get(pk=userId)
|
username = User.objects.get(pk=userId)
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if request.POST['isValid'] == "Valid":
|
if request.POST['isValid'] == "Valid":
|
||||||
try:
|
try:
|
||||||
@ -80,21 +82,21 @@ def adminView(request):
|
|||||||
balAdd = Balance(balanceValue=5, user_id=userId)
|
balAdd = Balance(balanceValue=5, user_id=userId)
|
||||||
balAdd.save()
|
balAdd.save()
|
||||||
|
|
||||||
imageObj = Image.objects.get(image=latestPicture, user_id=userId)
|
imageObj = Media.objects.get(image=latestPicture, user_id=userId)
|
||||||
imageObj.tokenized = True
|
imageObj.tokenized = True
|
||||||
imageObj.save()
|
imageObj.save()
|
||||||
|
|
||||||
return redirect("/admin/")
|
return redirect("/admin/")
|
||||||
elif request.POST['isValid'] == "Invalid":
|
elif request.POST['isValid'] == "Invalid":
|
||||||
imageObj = Image.objects.get(image=latestPicture, user_id=userId)
|
imageObj = Media.objects.get(image=latestPicture, user_id=userId)
|
||||||
imageObj.tokenized=True
|
imageObj.tokenized=False
|
||||||
imageObj.reason="Invalid"
|
imageObj.reason="Invalid"
|
||||||
imageObj.save()
|
imageObj.save()
|
||||||
return render(request, "adminView.html", {"time":time, "date":date,"image":latestPicture, "userId":userId, "username":username})
|
return render(request, "adminView.html", {"time":time, "date":date,"image":latestPicture, "userId":userId, "username":username, "is_video":is_video})
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return render(request, "adminView")
|
return render(request, "adminView")
|
||||||
return render(request, "adminView.html", {"time":time, "date":date,"image":latestPicture, "userId":userId, "username":username})
|
return render(request, "adminView.html", {"time":time, "date":date,"image":latestPicture, "userId":userId, "username":username, "is_video":is_video})
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return render(request, "adminView.html")
|
return render(request, "adminView.html")
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -47,6 +47,7 @@ INSTALLED_APPS = [
|
|||||||
'home',
|
'home',
|
||||||
'users',
|
'users',
|
||||||
'upload',
|
'upload',
|
||||||
|
'qr_code',
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -140,6 +141,7 @@ LOGOUT_REDIRECT_URL = "/"
|
|||||||
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
|
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
|
||||||
EMAIL_FILE_PATH = str(BASE_DIR.joinpath('sent_emails'))
|
EMAIL_FILE_PATH = str(BASE_DIR.joinpath('sent_emails'))
|
||||||
|
|
||||||
|
ALL_COINS = 1000000
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
|
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from django.conf.urls.static import static
|
|||||||
from django.contrib.auth import views
|
from django.contrib.auth import views
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from upload.views import uploadContent, imageUpload, viewMedia
|
from upload.views import uploadContent, imageUpload, viewMedia
|
||||||
from users.views import getBalance, addToBalance, adminView
|
from users.views import getBalance, addToBalance, adminView, removeBalance
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", homePage, name='home'),
|
path("", homePage, name='home'),
|
||||||
|
|
||||||
@ -33,6 +33,7 @@ urlpatterns = [
|
|||||||
path("view_media/", viewMedia, name="All Media"),
|
path("view_media/", viewMedia, name="All 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("admin/", adminView, name="admin")
|
path("admin/", adminView, name="admin")
|
||||||
]
|
]
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
Reference in New Issue
Block a user