Skip to content

Commit

Permalink
update-tier
Browse files Browse the repository at this point in the history
Former-commit-id: cfb5a186a51ecdb44f6abc48acb0f604d471642e
  • Loading branch information
Gkuer committed Nov 21, 2021
1 parent 18c9db1 commit 5a49721
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 3 deletions.
18 changes: 18 additions & 0 deletions accounts/migrations/0002_user_point.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2021-11-21 13:10

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='user',
name='point',
field=models.IntegerField(default=0),
),
]
2 changes: 1 addition & 1 deletion accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Create your models here.

class User(AbstractUser):
pass
point = models.IntegerField(default=0)
Binary file modified accounts/static/accounts/images/login.mp4
Binary file not shown.
Binary file modified db.sqlite3
Binary file not shown.
19 changes: 19 additions & 0 deletions movies/migrations/0008_alter_color_movie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.9 on 2021-11-21 13:10

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('movies', '0007_usercolorrecord'),
]

operations = [
migrations.AlterField(
model_name='color',
name='movie',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='movies.movie'),
),
]
2 changes: 1 addition & 1 deletion movies/templates/movies/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h2> 한줄평 </h2>
<input class="rating__input" name="grade" id="grade-4" value="4" type="radio">
<label aria-label="5 stars" class="rating__label" for="grade-5"><i
class="rating__icon rating__icon--star fa fa-star"></i></label>
<input class="rating__input" name="grade" id="grade-5" value="5" type="radio">
<input class="rating__input" name="grade" id="grade-5" value="5" type="radio" checked>
</div>
</div>
{% comment %} Comment Input {% endcomment %}
Expand Down
16 changes: 15 additions & 1 deletion movies/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def detail(request, movie_pk):
return render(request,'movies/detail.html', context)

@login_required
@require_http_methods(['GET','POST'])
@require_POST
def movie_comment(request, movie_pk):
movie = Movie.objects.get(pk = movie_pk)
form = MovieCommentForm(request.POST)
Expand All @@ -129,6 +129,8 @@ def movie_comment(request, movie_pk):
comment.movie = movie
comment.user = request.user
comment.save()
request.user.point += 10
request.user.save()
return redirect('movies:detail', movie_pk)
return redirect('movies:detail', movie_pk)

Expand All @@ -150,6 +152,8 @@ def review_create(request, movie_pk):
review.movie = movie
review.user = request.user
review.save()
request.user.point += 30
request.user.save()
return redirect('movies:detail', movie_pk)
else:
form = ReviewForm()
Expand Down Expand Up @@ -192,6 +196,8 @@ def review_comment(request, review_pk):
comment.user = request.user
comment.review = review
comment.save()
request.user.point += 5
request.user.save()
return redirect('movies:review', review_pk)

return redirect('movies:review', review_pk)
Expand Down Expand Up @@ -229,6 +235,8 @@ def review_delete(request, movie_pk, review_pk):
review = Review.objects.get(pk=review_pk)
if request.user.pk == review.user.pk:
review.delete()
request.user.point -= 30
request.user.save()
return redirect('movies:detail', movie_pk)
return redirect('movies:detail', movie_pk)

Expand All @@ -237,6 +245,8 @@ def review_comment_delete(request, review_pk, review_comment_pk):
review_comment = ReviewComment.objects.get(pk=review_comment_pk)
if request.user.pk == review_comment.user.pk:
review_comment.delete()
request.user.point -= 5
request.user.save()
return redirect('movies:review', review_pk)
return redirect('movies:review', review_pk)

Expand All @@ -245,6 +255,8 @@ def movie_comment_delete(request, comment_pk, movie_pk):
comment = MovieComment.objects.get(pk=comment_pk)
if request.user.pk == comment.user.pk:
comment.delete()
request.user.point -= 10
request.user.save()
return redirect('movies:detail', movie_pk)
return redirect('movies:detail', movie_pk)

Expand All @@ -255,6 +267,8 @@ def review_update(request,review_pk):
if request.method == "POST":
form = ReviewForm(data=request.POST, instance=review)
if form.is_valid():
request.user.point += 3
request.user.save()
form.save()
return redirect('movies:review', review_pk)
else:
Expand Down
Binary file modified static/videos/background.mp4
Binary file not shown.
17 changes: 17 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@
{% comment %} User & Login Button {% endcomment %}
<div class="header-profile d-flex justify-content-center align-items-center">
<div class="notification d-flex justify-content-center align-items-center">

{% comment %} User Tier {% endcomment %}
{% if user.is_staff %}
<img src="https://d2gd6pc034wcta.cloudfront.net/tier/31.svg" alt="" style="width:40px; height:40px; margin-top:3px; margin-right:2px;">
{% elif user.point > 200 %}
<img src="https://d2gd6pc034wcta.cloudfront.net/tier/25.svg" alt="" style="width:40px; height:40px; margin-top:3px; margin-right:2px;">
{% elif user.point > 120 %}
<img src="https://d2gd6pc034wcta.cloudfront.net/tier/19.svg" alt="" style="width:40px; height:40px; margin-top:3px; margin-right:2px;">
{% elif user.point > 60 %}
<img src="https://d2gd6pc034wcta.cloudfront.net/tier/13.svg" alt="" style="width:40px; height:40px; margin-top:3px; margin-right:2px;">
{% elif user.point > 20 %}
<img src="https://d2gd6pc034wcta.cloudfront.net/tier/7.svg" alt="" style="width:40px; height:40px; margin-top:3px; margin-right:2px;">
{% else %}
<img src="https://d2gd6pc034wcta.cloudfront.net/tier/1.svg" alt="" style="width:40px; height:40px; margin-top:3px; margin-right:2px;">
{% endif %}
<h3 style="color: white; margin: 10px; opacity: 0.9;">{{ user.username }}</h3>
<button class="btn btn-white mt-1" onclick="location.href = '{% url 'accounts:logout' %}'"> <i class="fas fa-exchange-alt" style="color: white; font-size: 20px; opacity: 0.9;"></i> </button>
<button class="btn btn-white mt-1" onclick="location.href = '{% url 'accounts:logout' %}'"> <i class="fas fa-sign-out-alt" style="color: white; font-size: 20px; opacity: 0.9;"></i> </button>
Expand Down Expand Up @@ -269,6 +284,8 @@ <h4 class="d-none" id="voiceAnswer" style="color: rgb(242, 206, 85); margin-top:
const searchInput = document.querySelector('#searchInput')
const searchButton = document.querySelector('#searchButton')
searchInput.value = query
voiceAnswer.classList.remove('d-none')
voiceAnswer.innerText = "알겠어요, 바로 실행할게요."
setTimeout(function() {
searchButton.click()
}, 1000);
Expand Down

0 comments on commit 5a49721

Please sign in to comment.