Fakultas Ilmu Komputer UI

Commit e0871272 authored by NICHOLAS JONATHAN KINANDANA's avatar NICHOLAS JONATHAN KINANDANA
Browse files

Merge branch 'master' of https://gitlab.cs.ui.ac.id/grubwan/polte-softeng into nicho-v2

parents 17f1db4f 7478be61
Pipeline #138340 passed with stages
in 2 minutes and 49 seconds
......@@ -65,7 +65,7 @@
box-shadow: inset 0px 4px 4px rgba(0, 0, 0, 0.25);
border-radius: 25px;
}
#button:hover {
#button-review:hover {
background-color: #EEEEEE;
color: #FFD369;
transition-duration: 0.4ms;
......
# from django.contrib.auth import authenticate, login, get_user_model, logout
# from django.views.generic import CreateView, FormView
# from django.http import HttpResponse, JsonResponse
# from django.shortcuts import render,redirect
# from django.utils.http import is_safe_url
# from .serializers import UserSerializer
# from rest_framework.views import APIView
# from rest_framework.response import Response
# from rest_framework import status
# from rest_framework.permissions import IsAdminUser
# from django.contrib.auth.models import *
# from .models import Account
# # import requests
# from homepage.forms import LoginForm, RegisterForm
# class UserRecordView(APIView):
# """
# API View to create or get a list of all the registered
# users. GET request returns the registered users whereas
# a POST request allows to create a new user.
# """
# permission_classes = [IsAdminUser]
# http_method_names = ['get', 'head', 'post']
# def get(self, request, *args, **kwargs):
# serializer = UserSerializer(Account.objects.all(), many=True)
# return Response(serializer.data, status = status.HTTP_200_OK)
# def post(self, request, *args, **kwargs):
# self.http_method_names.append("GET")
# serializer = UserSerializer(data=request.data)
# if serializer.is_valid(raise_exception=ValueError):
# serializer.create(validated_data=request.data)
# return Response(
# serializer.data,
# status=status.HTTP_201_CREATED
# )
# return Response(
# {
# "error": True,
# "error_msg": serializer.error_messages,
# },
# status=status.HTTP_400_BAD_REQUEST
# )
# class LoginView(FormView):
# form_class = LoginForm
# success_url = '/homepage/'
# template_name = 'login.html'
# def form_valid(self, form):
# request = self.request
# next_ = request.GET.get('next')
# next_post = request.POST.get('next')
# redirect_path = next_ or next_post or None
# email = form.cleaned_data.get("email")
# password = form.cleaned_data.get("password")
# user = authenticate(request, username=email, password=password)
# if user is not None:
# login(request, user)
# try:
# del request.session['guest_email_id']
# except:
# pass
# if is_safe_url(redirect_path, request.get_host()):
# return redirect(redirect_path)
# else:
# return redirect("/homepage/")
# return super(LoginView, self).form_invalid(form)
# class RegisterView(CreateView):
# form_class = RegisterForm
# template_name = 'registration.html'
# success_url ='/homepage/'
# def homepage(request):
# return render(request, 'homepage.html')
# def logout_request(request):
# logout(request)
# return redirect("/homepage/")
# def homepage(request):
# data = requests.get("https://apicovid19indonesia-v2.vercel.app/api/indonesia")
# data_json = data.json()
# context = {'data':data_json[0]}
# return render(request, "homepage.html", context)
# def covid_api(request):
# data = requests.get("https://apicovid19indonesia-v2.vercel.app/api/indonesia")
# data_json = data.json()
# return JsonResponse(data_json, safe = False)
from django.shortcuts import render, redirect
from django.views.generic import CreateView
from .models import User
......@@ -117,7 +22,7 @@ def login_request(request):
user = authenticate(username=username, password=password)
if user is not None :
login(request,user)
return redirect('/homepage/')
return redirect('/')
else:
messages.error(request,"Invalid username or password")
else:
......@@ -127,16 +32,16 @@ def login_request(request):
def logout_request(request):
logout(request)
return redirect("/homepage/")
return redirect("/")
class customer_register(CreateView):
model = User
form_class = CustomerSignUpForm
template_name = 'customer_register.html'
success_url = '/homepage/'
success_url = '/'
class developer_register(CreateView):
model = User
form_class = DeveloperSignUpForm
template_name = 'developer_register.html'
success_url = '/homepage/'
success_url = '/'
......@@ -42,30 +42,29 @@
color: #222831;
}
table {
.library {
margin-left: auto;
margin-right: auto;
margin-top: 50px;
margin-top: 20px;
width: 50%;
text-align: center;
border-radius: 20px;
color: #222831;
border: #EEEEEE solid 1px;
border-radius: 10px;
}
th {
border-bottom: 1px solid #EEEEEE;
padding-top: 5px;
padding-bottom: 5px;
background-color: #FFD369;
}
td {
padding-top: 5px;
padding-bottom: 5px;
padding: 10px 0 10px 0;
color: #EEEEEE;
}
.table:hover {
.list:hover {
background-color: #FFD369;
color: #222831;
}
......@@ -106,14 +105,14 @@
<button class = "sort button_genre" onclick="sort_table(1)">Sort by Genre</button>
</div>
<table id = "library">
<table class = "library" id = "library">
<tr>
<th>Name</th>
<th>Genre</th>
<th></th>
</tr>
{% for i in game %}
<tr class = "table">
<tr class = "list">
<ul id="search">
<td><a class = "gameDetails" href = 'game/{{ i.name }}'>{{ i.name }}<a></td>
<td>{{ i.genre }}</td>
......
......@@ -63,7 +63,13 @@
<div class="container">
<h4>{{ i.name }}</h4>
<p>by {{ i.author_game }}</p>
<a href = "/store/buy/{{ i.id }}"><button>Add to library</button></a>
{% if user.is_customer %}
<a href = "/store/buy/{{ i.id }}"><button>Add to library</button></a>
{% elif user.is_developer %}
<a></a>
{% else %}
<a href = "/login"><button>Add to library</button></a>
{% endif %}
</div>
</div>
{% endfor %}
......
......@@ -33,6 +33,8 @@
font-weight: bold;
/* set the color to FFD369 */
color: #FFD369;
text-align: center;
margin-top: 100px;
}
</style>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment