progress section shows status of the picture(approved or not), admin works fully

This commit is contained in:
Yamozha 2021-03-13 00:40:10 +02:00
parent aedbb6be6e
commit dd32fcb04b
62 changed files with 108 additions and 24 deletions

Binary file not shown.

View File

@ -7,13 +7,18 @@ def homePage(request):
all_balance = [] all_balance = []
try: try:
balObject = Balance.objects.filter(user=request.user.id)
userBalance = balObject.values("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}")
context = { context = {
"currencyTotal":sum(all_balance) "currencyTotal": sum(all_balance),
"userBalance": userBalance[0]["balanceValue"]
} }
return render(request, "home.html", context) return render(request, "home.html", context)
@ -23,4 +28,3 @@ def homePage(request):
"currencyTotal":e "currencyTotal":e
} }
return render(request, "home.html", context) return render(request, "home.html", context)

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -14,7 +14,7 @@
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<input name="user_instance" id="user_instance" placeholder="Pencho Slaveikov"><br> <input name="user_instance" id="user_instance" placeholder="Pencho Slaveikov"><br>
<input name="tokens", id="tokens", placeholder="523..."> <input name="tokens" id="tokens" placeholder="523...">
<button type="submit">Upload</button> <button type="submit">Upload</button>
</form> </form>

View File

@ -54,8 +54,8 @@
</div> </div>
<div class="choiceButtons"> <div class="choiceButtons">
<input type="submit" value="Valid"> <input name="isValid" type="submit" value="Valid">
<input type="submit" value="Invalid"> <input name="isValid" type="submit" value="Invalid">
</form> </form>
@ -67,6 +67,7 @@
<h1 class="emoji">🥳</h1> <h1 class="emoji">🥳</h1>
<h1 class="emoji">🎉</h1> <h1 class="emoji">🎉</h1>
</div> </div>
{% endif %} {% endif %}

View File

@ -83,7 +83,8 @@
<h1><strong>reValuate</strong><br /> <h1><strong>reValuate</strong><br />
</h1> </h1>
{% if user.is_authenticated %} {% if user.is_authenticated %}
<p>Здравей, {{ user.username }}!</p> <p>Здравей, {{ user.username }}!</p><br>
<p>Баланса ти е: {{ userBalance }} reCoins</p>
<ul class="actions special"> <ul class="actions special">
<li><a href="/upload/" class="button scrolly">Качи!</a></li> <li><a href="/upload/" class="button scrolly">Качи!</a></li>
<li><a href="/view_media/" class="button scrolly">Виж прогреса си!</a></li> <li><a href="/view_media/" class="button scrolly">Виж прогреса си!</a></li>

View File

@ -6,8 +6,16 @@
{% if user.is_authenticated %} {% if user.is_authenticated %}
Hi {{ user.username }}!<br> Hi {{ user.username }}!<br>
{% for image in images %} {% for i in get_status reversed %}
<img src="/media/images/{{ id }}/{{ image }}" style="max-width:500px"/> <img src="/media/{{ i.image }}" style="max-width:500px"/>
{% if i.reason %}
<span> cross</span>
{% elif i.tokenized %}
<span>checkmark</span>
{% else %}
<span> Processing </span>
{% endif %}
<br><br>
{% endfor %} {% endfor %}

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.6 on 2021-03-12 21:39
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('upload', '0009_auto_20210311_1910'),
]
operations = [
migrations.AlterField(
model_name='videos',
name='tokenized',
field=models.BooleanField(blank=True, default=None, null=True),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.6 on 2021-03-12 21:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('upload', '0010_auto_20210312_2339'),
]
operations = [
migrations.AlterField(
model_name='videos',
name='tokenized',
field=models.BooleanField(blank=True, default=None, max_length=3, null=True),
),
]

View File

@ -0,0 +1,25 @@
# Generated by Django 3.1.6 on 2021-03-12 21:47
from django.db import migrations, models
import upload.models
import upload.validators
class Migration(migrations.Migration):
dependencies = [
('upload', '0011_auto_20210312_2341'),
]
operations = [
migrations.AlterField(
model_name='image',
name='image',
field=models.ImageField(unique=True, upload_to=upload.models.imagesPath, validators=[upload.validators.imageValidate]),
),
migrations.AlterField(
model_name='image',
name='tokenized',
field=models.BooleanField(blank=True, default=None, max_length=3, null=True),
),
]

View File

@ -19,8 +19,8 @@ def videosPath(instance,filename):
class Image(models.Model): class Image(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]) image = models.ImageField(upload_to=imagesPath,validators=[imageValidate], unique=True)
tokenized = models.BooleanField(default=False) tokenized = models.BooleanField(blank=True, null=True, default=None, max_length=3)
reason = models.CharField(max_length=120) reason = models.CharField(max_length=120)
class Meta: class Meta:
@ -30,7 +30,7 @@ class Image(models.Model):
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(default=False) tokenized = models.BooleanField(blank=True, null=True, default=None, max_length=3)
reason = models.CharField(max_length=120) reason = models.CharField(max_length=120)

View File

@ -58,9 +58,12 @@ def videoUpload(request):
def viewMedia(request): def viewMedia(request):
path = settings.MEDIA_ROOT path = settings.MEDIA_ROOT
img_list = os.listdir(path + f"images/{request.user.id}/") img_list = os.listdir(path + f"images/{request.user.id}/")
get_status = Image.objects.filter(user_id=request.user.id)
context = { context = {
"images": img_list, "images": img_list,
"id":request.user.id, "id":request.user.id,
"get_status":get_status,
} }
return render (request, 'showAllImage.html', context) return render (request, 'showAllImage.html', context)

View File

@ -64,17 +64,12 @@ def getBalance(request):
return render(request,"getBalance.html", {"userBalance":userBalance} ) return render(request,"getBalance.html", {"userBalance":userBalance} )
def adminView(request): def adminView(request):
congrats = None
try: try:
latestPicture = Image.objects.filter(tokenized=False) latestPicture = Image.objects.filter(tokenized=None)
latestPicture, userId = latestPicture.values("image")[0]["image"], latestPicture.values("user_id")[0]["user_id"] latestPicture, userId = latestPicture.values("image")[0]["image"], latestPicture.values("user_id")[0]["user_id"]
if request.method == "POST": if request.method == "POST":
if request.POST.get('Valid','True'): if request.POST['isValid'] == "Valid":
imageObj = Image.objects.get(image=latestPicture, user_id=userId)
imageObj.tokenized = True
imageObj.save()
addBal = Balance.objects.get(user_id=userId)
try: try:
user_instance = Balance.objects.get(user=userId) user_instance = Balance.objects.get(user=userId)
sum_balance = 5 + user_instance.balanceValue sum_balance = 5 + user_instance.balanceValue
@ -85,10 +80,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.tokenized = True
imageObj.save()
return redirect("/admin/") return redirect("/admin/")
elif request.POST['isValid'] == "Invalid":
imageObj = Image.objects.get(image=latestPicture, user_id=userId)
imageObj.tokenized=True
imageObj.reason="Invalid"
imageObj.save()
return render(request, "adminView.html", {"image":latestPicture, "userId":userId})
else: else:
Image.objects.get(image=latestPicture, user_id=userId).delete() return render(request, "adminView")
return render(request, "adminView.html", {"image":latestPicture, "userId":userId}) return render(request, "adminView.html", {"image":latestPicture, "userId":userId})
except IndexError: except IndexError:
return render(request, "adminView.html") return render(request, "adminView.html")
return render(request, "adminView.html")