progress section shows status of the picture(approved or not), admin works fully
@ -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)
|
||||||
|
|
BIN
reValuate/media/images/1/Firefox_wallpaper.png
Normal file
After Width: | Height: | Size: 466 KiB |
BIN
reValuate/media/images/2/Firefox_wallpaper.png
Normal file
After Width: | Height: | Size: 466 KiB |
BIN
reValuate/media/images/2/Firefox_wallpaper_EP5MTwL.png
Normal file
After Width: | Height: | Size: 466 KiB |
BIN
reValuate/media/images/2/pexels-mali-maeder-802221.jpg
Normal file
After Width: | Height: | Size: 747 KiB |
BIN
reValuate/media/images/3/1170723.jpg
Normal file
After Width: | Height: | Size: 185 KiB |
BIN
reValuate/media/images/3/1259275.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_2EcL8mE.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_31IiTQx.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_7McLK8w.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_BrenuIl.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_FvGOwP0.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_GZESP9M.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_XUwsi6c.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_ZdYnQgp.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_aePvrNY.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_b4lcgCQ.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_bWF7N4f.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_eDYdEp5.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_eo9Gsuz.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_i1upUWO.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_i3mjSDG.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/1259275_nqNFXgg.jpg
Normal file
After Width: | Height: | Size: 2.7 MiB |
BIN
reValuate/media/images/3/791.jpg
Normal file
After Width: | Height: | Size: 119 KiB |
BIN
reValuate/media/images/3/Screenshot_from_2020-03-06_10-58-51.png
Normal file
After Width: | Height: | Size: 772 KiB |
BIN
reValuate/media/images/3/Screenshot_from_2020-03-06_10-58-53.png
Normal file
After Width: | Height: | Size: 772 KiB |
BIN
reValuate/media/images/3/wp2058634-3840x1080-wallpapers.jpg
Normal file
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
@ -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>
|
||||||
|
|
||||||
|
@ -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 %}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
@ -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 %}
|
||||||
|
|
||||||
|
|
||||||
|
18
reValuate/upload/migrations/0010_auto_20210312_2339.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
18
reValuate/upload/migrations/0011_auto_20210312_2341.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
25
reValuate/upload/migrations/0012_auto_20210312_2347.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
@ -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")
|
|
||||||
|