need to fix automatical true assignment(you automatically get approved)
@ -3504,3 +3504,5 @@ input, select, textarea {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,26 @@
|
||||
from django.shortcuts import render
|
||||
import os.path
|
||||
from users.models import Balance
|
||||
|
||||
def homePage(request):
|
||||
currencyTotal = open(os.path.dirname(__file__) + "/../currency.txt","r")
|
||||
currencyTotal = currencyTotal.readline()
|
||||
iter_var = 0
|
||||
all_balance = []
|
||||
|
||||
try:
|
||||
a = Balance.objects.all()
|
||||
for user in a:
|
||||
all_balance.append(user.balanceValue)
|
||||
print(f"{all_balance}")
|
||||
context = {
|
||||
"currencyTotal" : currencyTotal
|
||||
"currencyTotal":sum(all_balance)
|
||||
}
|
||||
return render(request, "home.html", context)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
|
||||
context = {
|
||||
"currencyTotal":e
|
||||
}
|
||||
return render(request, "home.html", context)
|
||||
|
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 688 KiB |
Before Width: | Height: | Size: 466 KiB |
BIN
reValuate/media/images/1/pexels-mali-maeder-802221.jpg
Normal file
After Width: | Height: | Size: 747 KiB |
BIN
reValuate/media/images/1/pexels-mali-maeder-802221_XdYP9Ry.jpg
Normal file
After Width: | Height: | Size: 747 KiB |
Before Width: | Height: | Size: 466 KiB |
Before Width: | Height: | Size: 466 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 466 KiB |
Before Width: | Height: | Size: 466 KiB |
Before Width: | Height: | Size: 466 KiB |
Before Width: | Height: | Size: 466 KiB |
27
reValuate/micro
Normal file
@ -0,0 +1,27 @@
|
||||
[?1049h[22;0;0t[>4;2m[?1h=[?2004h[?1004h[1;24r[?12h[?12l[22;2t[22;1t[27m[23m[29m[m[H[2J[?25l[24;1H[97m[41mE325: ATTENTION[m
|
||||
Found a swap file by the name "~/github/reValuate/.git/.COMMIT_EDITMSG.swp"
|
||||
[10Cowned by: gang420 dated: Thu Mar 11 03:38:41 2021
|
||||
[9Cfile name: ~gang420/github/reValuate/.git/COMMIT_EDITMSG
|
||||
[10Cmodified: YES
|
||||
[9Cuser name: gang420 host name: CatShip
|
||||
[8Cprocess ID: 22317
|
||||
While opening file "/home/gang420/github/reValuate/.git/COMMIT_EDITMSG"
|
||||
[13Cdated: Thu Mar 11 03:38:56 2021
|
||||
NEWER than swap file!
|
||||
|
||||
(1) Another program may be editing the same file. If this is the case,
|
||||
be careful not to end up with two different instances of the same
|
||||
file when making changes. Quit, or continue with caution.
|
||||
(2) An edit session for this file crashed.
|
||||
If this is the case, use ":recover" or "vim -r /home/gang420/github/reValuate/.
|
||||
[23;84Hg[24;1Hit/COMMIT_EDITMSG"
|
||||
to recover the changes (see ":help recovery").
|
||||
If you did this already, delete the swap file "/home/gang420/github/reValuate/.
|
||||
[23;84Hg[24;1Hit/.COMMIT_EDITMSG.swp"
|
||||
to avoid this message.
|
||||
|
||||
[32mSwap file "~/github/reValuate/.git/.COMMIT_EDITMSG.swp" already exists![m
|
||||
[32m-- More --[?25h[m[24;1H[K[24;1H[32m[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort: [m[24;1H[K[24;1H
|
||||
Interrupt: [32mPress ENTER or type command to continue[m[1;1H[L[?25l[2;1H[94m~ [3;1H~ [4;1H~ [5;1H~ [6;1H~ [7;1H~ [8;1H~ [9;1H~ [10;1H~ [11;1H~ [12;1H~ [13;1H~ [14;1H~ [15;1H~ [16;1H~ [17;1H~ [18;1H~ [19;1H~ [20;1H~ [21;1H~ [22;1H~ [23;1H~ [m[24;67H0,0-1[9CAll[1;1H[?25h[24;1H[?1004l[?2004l[?1l>[>4;m[?1049l[23;0;0tVim: Caught deadly signal HUP
|
||||
Vim: Finished.
|
||||
[24;1H[23;2t[23;1t
|
@ -3,17 +3,13 @@
|
||||
{% block title %} Update Balance {% endblock %}
|
||||
|
||||
|
||||
|
||||
{% if user.is_superuser %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="centered">
|
||||
{% if message is None %}
|
||||
<p>Hello, {{ user.username }} !</p>
|
||||
{% else %}
|
||||
<p>{{ message }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if request.user.is_superuser %}
|
||||
|
||||
|
||||
<p>Hello, {{ user.username }} !</p>
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
@ -21,7 +17,7 @@
|
||||
<input name="tokens", id="tokens", placeholder="523...">
|
||||
<button type="submit">Upload</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
{% else %}
|
||||
@ -30,4 +26,4 @@
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
77
reValuate/templates/adminView.html
Normal file
@ -0,0 +1,77 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block optionalParams %}
|
||||
<style>
|
||||
.choiceButtons{
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
margin-right: -50%;
|
||||
transform: translate(-50%, -50%);
|
||||
top: 80%;
|
||||
bottom: 20%;
|
||||
}
|
||||
.choice{
|
||||
border:5px;
|
||||
border-color: #4CAF50;
|
||||
border-style: dashed;
|
||||
}
|
||||
|
||||
.emoji {
|
||||
font-size: 40px;
|
||||
display: inline-block;
|
||||
animation:
|
||||
color .66s linear infinite,
|
||||
rotate 1s ease-in-out infinite;
|
||||
|
||||
&:nth-child(2) { animation-delay: -.66s; }
|
||||
&:nth-child(3) { animation-delay: -1.33s; }
|
||||
}
|
||||
|
||||
@keyframes color {
|
||||
50% { filter: hue-rotate(360deg); }
|
||||
}
|
||||
|
||||
@keyframes rotate {
|
||||
0%, 100% { transform: rotate(20deg); }
|
||||
25% { transform: scale(1.1); }
|
||||
50% { transform: rotate(-20deg); }
|
||||
75% { transform: scale(.9); }
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="centered">
|
||||
|
||||
{% if image %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
<div class="choice">
|
||||
<img src="/media/{{ image }}" width="500" width="500" >
|
||||
</div><br>
|
||||
</div>
|
||||
<div class="choiceButtons">
|
||||
|
||||
<input type="submit" value="Valid">
|
||||
<input type="submit" value="Invalid">
|
||||
</form>
|
||||
|
||||
|
||||
{% else %}
|
||||
|
||||
<h1>Congratulations, there is no work left</h1>
|
||||
<div class="choiceButtons">
|
||||
<h1 class="emoji">🎉</h1>
|
||||
<h1 class="emoji">🥳</h1>
|
||||
<h1 class="emoji">🎉</h1>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
27
reValuate/upload/migrations/0004_auto_20210311_1702.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Generated by Django 3.1.6 on 2021-03-11 15:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('upload', '0003_delete_balance'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='image',
|
||||
options={'verbose_name': 'image', 'verbose_name_plural': 'images'},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='image',
|
||||
name='tokenized',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='videos',
|
||||
name='tokenized',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
23
reValuate/upload/migrations/0005_auto_20210311_1833.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.1.6 on 2021-03-11 16:33
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('upload', '0004_auto_20210311_1702'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='image',
|
||||
name='reason',
|
||||
field=models.CharField(default=None, max_length=120),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='videos',
|
||||
name='reason',
|
||||
field=models.CharField(default=None, max_length=120),
|
||||
),
|
||||
]
|
23
reValuate/upload/migrations/0006_auto_20210311_1833.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.1.6 on 2021-03-11 16:33
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('upload', '0005_auto_20210311_1833'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='image',
|
||||
name='reason',
|
||||
field=models.CharField(blank=True, default=None, max_length=120, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='videos',
|
||||
name='reason',
|
||||
field=models.CharField(blank=True, default=None, max_length=120, null=True),
|
||||
),
|
||||
]
|
23
reValuate/upload/migrations/0007_auto_20210311_1834.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.1.6 on 2021-03-11 16:34
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('upload', '0006_auto_20210311_1833'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='image',
|
||||
name='reason',
|
||||
field=models.CharField(blank=True, max_length=120, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='videos',
|
||||
name='reason',
|
||||
field=models.CharField(blank=True, max_length=120, null=True),
|
||||
),
|
||||
]
|
23
reValuate/upload/migrations/0008_auto_20210311_1838.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.1.6 on 2021-03-11 16:38
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('upload', '0007_auto_20210311_1834'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='image',
|
||||
name='reason',
|
||||
field=models.CharField(max_length=120),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='videos',
|
||||
name='reason',
|
||||
field=models.CharField(max_length=120),
|
||||
),
|
||||
]
|
26
reValuate/upload/migrations/0009_auto_20210311_1910.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Generated by Django 3.1.6 on 2021-03-11 17:10
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('upload', '0008_auto_20210311_1838'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='image',
|
||||
name='user',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='videos',
|
||||
name='user',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
@ -18,21 +18,23 @@ def videosPath(instance,filename):
|
||||
return f"videos/{instance.user.id}/{filename}"
|
||||
|
||||
class Image(models.Model):
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE, blank=True, null=True)
|
||||
# title = models.CharField(max_length=200)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
|
||||
image = models.ImageField(upload_to=imagesPath,validators=[imageValidate])
|
||||
tokenized = models.BooleanField(default=False)
|
||||
reason = models.CharField(max_length=120)
|
||||
|
||||
# def __str__(self):
|
||||
# return self.title
|
||||
class Meta:
|
||||
verbose_name = 'image'
|
||||
verbose_name_plural = 'images'
|
||||
|
||||
class Videos(models.Model):
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE, blank=True, null=True)
|
||||
# title = models.CharField(max_length=100)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
|
||||
video = models.FileField(upload_to=videosPath, validators=[videoValidate])
|
||||
tokenized = models.BooleanField(default=False)
|
||||
reason = models.CharField(max_length=120)
|
||||
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'video'
|
||||
verbose_name_plural = 'videos'
|
||||
|
||||
# def __str__(self):
|
||||
# return self.title
|
||||
|
@ -54,6 +54,7 @@ def videoUpload(request):
|
||||
form = VideoForm()
|
||||
return render(request, 'uploadVideo.html', {'form': form})
|
||||
|
||||
|
||||
def viewMedia(request):
|
||||
path = settings.MEDIA_ROOT
|
||||
img_list = os.listdir(path + f"images/{request.user.id}/")
|
||||
@ -62,3 +63,4 @@ def viewMedia(request):
|
||||
"id":request.user.id,
|
||||
}
|
||||
return render (request, 'showAllImage.html', context)
|
||||
|
||||
|
89
reValuate/users/adminView/css/main.css
Normal file
@ -0,0 +1,89 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.app {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 300px;
|
||||
height: 400px;
|
||||
position: absolute;
|
||||
border-radius: 10px;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
transform-origin: center;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
cursor: -webkit-grab;
|
||||
-webkit-transform-style: preserve-3d;
|
||||
transform-style: preserve-3d;
|
||||
-webkit-transform: perspective(800px);
|
||||
transform: perspective(800px);
|
||||
}
|
||||
.color0 {
|
||||
background-image: linear-gradient(to right, #43e97b 0%, #38f9d7 100%);
|
||||
}
|
||||
.color1 {
|
||||
background-image: linear-gradient(
|
||||
to top,
|
||||
#3f51b1 0%,
|
||||
#5a55ae 13%,
|
||||
#7b5fac 25%,
|
||||
#8f6aae 38%,
|
||||
#a86aa4 50%,
|
||||
#cc6b8e 62%,
|
||||
#f18271 75%,
|
||||
#f3a469 87%,
|
||||
#f7c978 100%
|
||||
);
|
||||
}
|
||||
|
||||
.color2 {
|
||||
background-image: linear-gradient(
|
||||
to top,
|
||||
#dbdcd7 0%,
|
||||
#dddcd7 24%,
|
||||
#e2c9cc 30%,
|
||||
#e7627d 46%,
|
||||
#b8235a 59%,
|
||||
#801357 71%,
|
||||
#3d1635 84%,
|
||||
#1c1a27 100%
|
||||
);
|
||||
}
|
||||
|
||||
.color3 {
|
||||
background-image: linear-gradient(to top, #0250c5 0%, #d43f8d 100%);
|
||||
}
|
||||
|
||||
.color4 {
|
||||
background-image: linear-gradient(to top, #c7eafd 0%, #e8198b 100%);
|
||||
}
|
||||
|
||||
.text {
|
||||
text-align: center;
|
||||
font-family: "Montserrat", sans-serif;
|
||||
font-size: 28px;
|
||||
font-weight: 900;
|
||||
font-style: italic;
|
||||
margin-top: 50px;
|
||||
color: #fff;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
343
reValuate/users/adminView/js/main.js
Normal file
@ -0,0 +1,343 @@
|
||||
class Card extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
active: false,
|
||||
move: false,
|
||||
limit: false,
|
||||
mouseStartPosX: null,
|
||||
mouseStartPosY: null,
|
||||
mouseCurrPosX: null,
|
||||
mouseCurrPosY: null,
|
||||
Posx: null,
|
||||
Posy: null,
|
||||
k: 0.2,
|
||||
restX: 0,
|
||||
restY: 0,
|
||||
fx: 0,
|
||||
fy: 0,
|
||||
ax: 0,
|
||||
ay: 0,
|
||||
vx: 0.0,
|
||||
vy: 0.0,
|
||||
mass: 0.7,
|
||||
damping: 0.8
|
||||
};
|
||||
this.handleDown = this.handleDown.bind(this);
|
||||
this.handleUp = this.handleUp.bind(this);
|
||||
this.handleMove = this.handleMove.bind(this);
|
||||
this.animate = this.animate.bind(this);
|
||||
this.updateCard = this.updateCard.bind(this);
|
||||
this.handleTouchStart = this.handleTouchStart.bind(this);
|
||||
this.handleTouchEnd = this.handleTouchEnd.bind(this);
|
||||
this.handleTouchMove = this.handleTouchMove.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.animate();
|
||||
}
|
||||
|
||||
handleDown(e) {
|
||||
this.setState({
|
||||
move: true,
|
||||
active: true,
|
||||
mouseStartPosX: e.clientX,
|
||||
mouseStartPosY: e.clientY
|
||||
});
|
||||
}
|
||||
|
||||
handleTouchStart(e) {
|
||||
e.persist();
|
||||
this.setState({
|
||||
move: true,
|
||||
active: true,
|
||||
mouseStartPosX: e.touches[0].screenX,
|
||||
mouseStartPosY: e.touches[0].screenY
|
||||
});
|
||||
console.log(this.state.mouseStartPosX);
|
||||
}
|
||||
|
||||
handleMove(e) {
|
||||
if (!this.state.limit) {
|
||||
if (this.state.move) {
|
||||
let mouseCurrPosX = e.clientX;
|
||||
let mouseCurrPosY = e.clientY;
|
||||
let Posx = mouseCurrPosX - this.state.mouseStartPosX;
|
||||
let Posy = mouseCurrPosY - this.state.mouseStartPosY;
|
||||
let el = document.getElementById("card" + this.props.no);
|
||||
let height = window.innerHeight;
|
||||
let width = window.innerWidth;
|
||||
let maxX = width - width * 20 / 100;
|
||||
function map_range(value, low1, high1, low2, high2) {
|
||||
return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
|
||||
}
|
||||
let mouseRange = mouseCurrPosX;
|
||||
if (mouseRange < width / 2) {
|
||||
mouseRange = width - mouseRange;
|
||||
}
|
||||
let damping = map_range(
|
||||
mouseRange,
|
||||
width / 2,
|
||||
width - width * 10 / 100,
|
||||
0.6,
|
||||
0.8
|
||||
);
|
||||
|
||||
this.setState({
|
||||
Posx,
|
||||
Posy,
|
||||
damping,
|
||||
mouseCurrPosX,
|
||||
mouseCurrPosY
|
||||
});
|
||||
|
||||
if (mouseCurrPosX > width - width * 20 / 100) {
|
||||
let restX, restY;
|
||||
if (mouseCurrPosX > width / 2) {
|
||||
restX = this.state.Posx * 5;
|
||||
} else {
|
||||
restX = -this.state.Posx * 5;
|
||||
}
|
||||
if (mouseCurrPosY > height / 2) {
|
||||
restY = this.state.Posy * 5;
|
||||
} else {
|
||||
restY = this.state.Posy * 5;
|
||||
}
|
||||
let limit = true;
|
||||
let move = false;
|
||||
let damping = 0.06;
|
||||
this.setState(
|
||||
{
|
||||
restX,
|
||||
restY,
|
||||
limit,
|
||||
move,
|
||||
damping
|
||||
},
|
||||
() => {
|
||||
setTimeout(() => {
|
||||
window.cancelAnimationFrame(this.animate);
|
||||
}, 10);
|
||||
}
|
||||
);
|
||||
} else if (mouseCurrPosX < width * 20 / 100) {
|
||||
let restX, restY;
|
||||
if (mouseCurrPosX > width / 2) {
|
||||
restX = -this.state.Posx * 5;
|
||||
} else {
|
||||
restX = this.state.Posx * 5;
|
||||
}
|
||||
if (mouseCurrPosY > height / 2) {
|
||||
restY = this.state.Posy * 5;
|
||||
} else {
|
||||
restY = this.state.Posy * 5;
|
||||
}
|
||||
let limit = true;
|
||||
let move = false;
|
||||
let damping = 0.06;
|
||||
this.setState({
|
||||
restX,
|
||||
restY,
|
||||
limit,
|
||||
move,
|
||||
damping
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleTouchMove(e) {
|
||||
e.persist();
|
||||
if (!this.state.limit) {
|
||||
if (this.state.move) {
|
||||
let mouseCurrPosX = e.touches[0].screenX;
|
||||
let mouseCurrPosY = e.touches[0].screenY;
|
||||
let Posx = mouseCurrPosX - this.state.mouseStartPosX;
|
||||
let Posy = mouseCurrPosY - this.state.mouseStartPosY;
|
||||
let el = document.getElementById("card" + this.props.no);
|
||||
let height = window.innerHeight;
|
||||
let width = window.innerWidth;
|
||||
let maxX = width - width * 20 / 100;
|
||||
function map_range(value, low1, high1, low2, high2) {
|
||||
return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
|
||||
}
|
||||
let mouseRange = mouseCurrPosX;
|
||||
if (mouseRange < width / 2) {
|
||||
mouseRange = width - mouseRange;
|
||||
}
|
||||
let damping = map_range(
|
||||
mouseRange,
|
||||
width / 2,
|
||||
width - width * 10 / 100,
|
||||
0.6,
|
||||
0.8
|
||||
);
|
||||
|
||||
this.setState({
|
||||
Posx,
|
||||
Posy,
|
||||
damping,
|
||||
mouseCurrPosX,
|
||||
mouseCurrPosY
|
||||
});
|
||||
|
||||
if (mouseCurrPosX > width - width * 10 / 100) {
|
||||
let restX, restY;
|
||||
if (mouseCurrPosX > width / 2) {
|
||||
restX = this.state.Posx * 5;
|
||||
} else {
|
||||
restX = -this.state.Posx * 5;
|
||||
}
|
||||
if (mouseCurrPosY > height / 2) {
|
||||
restY = this.state.Posy * 5;
|
||||
} else {
|
||||
restY = this.state.Posy * 5;
|
||||
}
|
||||
let limit = true;
|
||||
let move = false;
|
||||
let damping = 0.08;
|
||||
this.setState(
|
||||
{
|
||||
restX,
|
||||
restY,
|
||||
limit,
|
||||
move,
|
||||
damping
|
||||
},
|
||||
() => {
|
||||
setTimeout(() => {
|
||||
window.cancelAnimationFrame(this.animate);
|
||||
}, 10);
|
||||
}
|
||||
);
|
||||
} else if (mouseCurrPosX < width * 10 / 100) {
|
||||
let restX, restY;
|
||||
if (mouseCurrPosX > width / 2) {
|
||||
restX = -this.state.Posx * 5;
|
||||
} else {
|
||||
restX = this.state.Posx * 5;
|
||||
}
|
||||
if (mouseCurrPosY > height / 2) {
|
||||
restY = this.state.Posy * 5;
|
||||
} else {
|
||||
restY = this.state.Posy * 5;
|
||||
}
|
||||
let limit = true;
|
||||
let move = false;
|
||||
let damping = 0.08;
|
||||
this.setState({
|
||||
restX,
|
||||
restY,
|
||||
limit,
|
||||
move,
|
||||
damping
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleUp() {
|
||||
this.setState({
|
||||
move: false
|
||||
});
|
||||
}
|
||||
|
||||
handleTouchEnd() {
|
||||
this.setState({
|
||||
move: false
|
||||
});
|
||||
}
|
||||
|
||||
updateCard() {
|
||||
if (!this.state.move) {
|
||||
this.setState(
|
||||
{
|
||||
fx: -this.state.k * (this.state.Posx - this.state.restX),
|
||||
fy: -this.state.k * (this.state.Posy - this.state.restY)
|
||||
},
|
||||
() => {
|
||||
this.setState(
|
||||
{
|
||||
ax: this.state.fx / this.state.mass,
|
||||
ay: this.state.fy / this.state.mass
|
||||
},
|
||||
() => {
|
||||
this.setState(
|
||||
{
|
||||
vx: this.state.damping * (this.state.vx + this.state.ax),
|
||||
vy: this.state.damping * (this.state.vy + this.state.ay)
|
||||
},
|
||||
() => {
|
||||
this.setState({
|
||||
Posx: this.state.Posx + this.state.vx,
|
||||
Posy: this.state.Posy + this.state.vy
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
animate() {
|
||||
let el = document.getElementById("card" + this.props.no);
|
||||
if (
|
||||
this.state.Posx > window.innerWidth + 400 ||
|
||||
this.state.Posx < -window.innerWidth - 400
|
||||
) {
|
||||
cancelAnimationFrame(this.animate);
|
||||
} else {
|
||||
requestAnimationFrame(this.animate);
|
||||
}
|
||||
if (this.state.active) {
|
||||
el.style.transform =
|
||||
"translate(" +
|
||||
this.state.Posx +
|
||||
"px" +
|
||||
"," +
|
||||
this.state.Posy +
|
||||
"px) rotate(" +
|
||||
this.state.Posx / 9 +
|
||||
"deg) perspective(800px)";
|
||||
this.updateCard();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div
|
||||
id={"card" + this.props.no}
|
||||
className={"card color" + this.props.no}
|
||||
onMouseDown={this.handleDown}
|
||||
onMouseMove={this.handleMove}
|
||||
onMouseUp={this.handleUp}
|
||||
onMouseLeave={this.handleUp}
|
||||
onTouchStart={this.handleTouchStart}
|
||||
onTouchMove={this.handleTouchMove}
|
||||
onTouchEnd={this.handleTouchEnd}
|
||||
>
|
||||
<div className="text">DRAG THE CARD LEFT OR RIGHT</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class App extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
data: [0, 1, 2, 3, 4]
|
||||
};
|
||||
}
|
||||
render() {
|
||||
var box = this.state.data.map((item, i) => {
|
||||
return <Card key={i} no={i} />;
|
||||
});
|
||||
return <div className="app">{box}</div>;
|
||||
}
|
||||
}
|
||||
ReactDOM.render(<App />, document.getElementById("app"));
|
@ -5,6 +5,7 @@ from .models import Balance
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib import messages
|
||||
from upload.models import Image, Videos
|
||||
|
||||
# need to make oauth facebook login
|
||||
class SignUpView(generic.CreateView):
|
||||
@ -52,6 +53,7 @@ def removeBalance(request):
|
||||
return render(request,"getBalance.html", {"userBalance":balAdd})
|
||||
else:
|
||||
return render(request,"removeBalance.html")
|
||||
|
||||
def getBalance(request):
|
||||
balObject = Balance.objects.filter(user=request.user.id)
|
||||
print(dir(balObject))
|
||||
@ -61,3 +63,21 @@ def getBalance(request):
|
||||
|
||||
return render(request,"getBalance.html", {"userBalance":userBalance} )
|
||||
|
||||
def adminView(request):
|
||||
congrats = None
|
||||
try:
|
||||
latestPicture = Image.objects.filter(tokenized=False)
|
||||
latestPicture, userId = latestPicture.values("image")[0]["image"], latestPicture.values("user_id")[0]["user_id"]
|
||||
|
||||
if request.method == "POST":
|
||||
if request.POST.get('Valid','True'):
|
||||
imageObj = Image.objects.get(image=latestPicture, user_id=userId)
|
||||
imageObj.tokenized = True
|
||||
imageObj.save()
|
||||
return redirect("/admin/")
|
||||
else:
|
||||
Image.objects.get(image=latestPicture, user_id=userId).delete()
|
||||
return render(request, "adminView.html", {"image":latestPicture, "userId":userId})
|
||||
except IndexError:
|
||||
return render(request, "adminView.html")
|
||||
return render(request, "adminView.html")
|
||||
|
@ -13,6 +13,8 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
@ -137,3 +139,4 @@ EMAIL_FILE_PATH = str(BASE_DIR.joinpath('sent_emails'))
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
|
||||
|
||||
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
|
@ -21,10 +21,10 @@ from django.conf.urls.static import static
|
||||
from django.contrib.auth import views
|
||||
from django.views.generic.base import TemplateView
|
||||
from upload.views import uploadContent, imageUpload, videoUpload, viewMedia
|
||||
from users.views import getBalance, addToBalance
|
||||
from users.views import getBalance, addToBalance, adminView
|
||||
urlpatterns = [
|
||||
path("", homePage, name='home'),
|
||||
path('admin/', admin.site.urls),
|
||||
|
||||
path("users/", include('django.contrib.auth.urls')),
|
||||
path('users/', include('users.urls')),
|
||||
path("upload/", uploadContent, name="Upload"),
|
||||
@ -32,7 +32,8 @@ urlpatterns = [
|
||||
path("upload_video/", videoUpload, name="Video"),
|
||||
path("view_media/", viewMedia, name="All Media"),
|
||||
path("get_balance/",getBalance, name="Balance" ),
|
||||
path("add_balance/", addToBalance, name="Add")
|
||||
path("add_balance/", addToBalance, name="Add"),
|
||||
path("admin/", adminView, name="admin")
|
||||
]
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.MEDIA_URL,
|
||||
|