From b9a7159703316eceece279158371fca42f0fb1f7 Mon Sep 17 00:00:00 2001
From: fadhlanhasyim <fadhlanhasyim54@gmail.com>
Date: Sun, 20 Nov 2022 10:07:35 +0700
Subject: [PATCH] create account app

---
 account/__init__.py             |  0
 account/admin.py                |  3 +++
 account/apps.py                 |  6 +++++
 account/migrations/__init__.py  |  0
 account/models.py               |  3 +++
 account/templates/login.html    | 31 ++++++++++++++++++++++++++
 account/templates/main.html     | 27 +++++++++++++++++++++++
 account/templates/register.html | 39 +++++++++++++++++++++++++++++++++
 account/tests.py                |  3 +++
 account/urls.py                 | 10 +++++++++
 account/views.py                | 11 ++++++++++
 sirest/settings.py              |  3 ++-
 sirest/urls.py                  |  3 ++-
 templates/base.html             | 26 ++++++++++++++++++++++
 14 files changed, 163 insertions(+), 2 deletions(-)
 create mode 100644 account/__init__.py
 create mode 100644 account/admin.py
 create mode 100644 account/apps.py
 create mode 100644 account/migrations/__init__.py
 create mode 100644 account/models.py
 create mode 100644 account/templates/login.html
 create mode 100644 account/templates/main.html
 create mode 100644 account/templates/register.html
 create mode 100644 account/tests.py
 create mode 100644 account/urls.py
 create mode 100644 account/views.py
 create mode 100644 templates/base.html

diff --git a/account/__init__.py b/account/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/account/admin.py b/account/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/account/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/account/apps.py b/account/apps.py
new file mode 100644
index 0000000..2b08f1a
--- /dev/null
+++ b/account/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class AccountConfig(AppConfig):
+    default_auto_field = 'django.db.models.BigAutoField'
+    name = 'account'
diff --git a/account/migrations/__init__.py b/account/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/account/models.py b/account/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/account/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/account/templates/login.html b/account/templates/login.html
new file mode 100644
index 0000000..ec1f35e
--- /dev/null
+++ b/account/templates/login.html
@@ -0,0 +1,31 @@
+{% extends 'base.html' %} {% block meta %}
+<title>Login</title>
+{% endblock meta %} {% block content %}
+
+<div class="flex justify-center items-center">
+    <div class="bg-red-200 w-fit rounded-lg">
+        <div class="login w-[25rem] drop-shadow-2xl flex flex-col justify-center items-center bg-cream-tua p-10 rounded-xl lg:scale-100 md:scale-90 scale-75">
+            <h1 class="text-3xl font-bold mb-3">LOGIN</h1>
+            <form method="POST" action="" class="mb-3 flex flex-col items-center justify-center">
+                {% csrf_token %}
+                <table class="font-semibold">
+                    <tr class="flex flex-col justify-center">
+                        <td>Email</td>
+                        <td><input class="w-56 h-10 p-3 rounded-lg" type="text" name="username" placeholder="Username" class="form-control" /></td>
+                    </tr>
+                    <tr class="flex flex-col justify-center mt-2">
+                        <td>Password</td>
+                        <td><input class="w-56 h-10 p-3 rounded-lg" type="password" name="password" placeholder="Password" class="form-control" /></td>
+                    </tr>
+                    <tr class="mt-4 flex flex-col justify-center items-center">
+                        <td></td>
+                        <td><input class="btn rounded-lg hover:cursor-pointer h-10 w-28 bg-red-600 hover:bg-merah-tua text-white login_btn" type="submit" value="Login" /></td>
+                    </tr>
+                </table>
+            </form>
+            <p>Belum mempunyai akun? <a class="underline font-bold" href="{% url 'account:register' %}">Buat Akun</a></p>
+        </div>
+    </div>
+</div>
+
+{% endblock content %}
\ No newline at end of file
diff --git a/account/templates/main.html b/account/templates/main.html
new file mode 100644
index 0000000..9ee6fb1
--- /dev/null
+++ b/account/templates/main.html
@@ -0,0 +1,27 @@
+{% extends 'base.html' %}
+{% load static %}
+
+{% block meta %}
+<title>Hello!</title>
+{% endblock meta %}
+
+{% block content %}
+<div class="flex justify-center font-bold">
+    <h1>SIREST - A7</h1>
+</div>
+<div class="flex justify-center">
+    <div class="flex justify-between items-center w-fit">
+        <a href="{% url 'account:login' %}" class="m-2">
+            <button type="button" class="bg-red-300 hover:bg-merah-muda w-fit text-black p-2 font-bold rounded-lg flex items-center justify-center">
+                Login
+            </button>
+        </a>
+        <a href="{% url 'account:register' %}" class="m-2">
+            <button type="button" class="bg-red-300 hover:bg-merah-muda w-fit text-black p-2 font-bold rounded-lg flex items-center justify-center">
+                Register
+            </button>
+        </a>
+    </div>
+</div>
+
+{% endblock content %}
\ No newline at end of file
diff --git a/account/templates/register.html b/account/templates/register.html
new file mode 100644
index 0000000..552cf28
--- /dev/null
+++ b/account/templates/register.html
@@ -0,0 +1,39 @@
+{% extends 'base.html' %}
+{% load static %}
+
+{% block meta %}
+<title>Hello!</title>
+{% endblock meta %}
+
+{% block content %}
+<div class="flex justify-center font-bold">
+    <h1>Register</h1>
+</div>
+<div class="">
+    <div class="w-fit">
+        <a href="{% url 'account:login' %}" class="m-2">
+            <button type="button" class="bg-red-300 hover:bg-merah-muda w-fit text-black p-2 font-bold rounded-lg flex items-center justify-center">
+                Admin
+            </button>
+        </a>
+        <a href="{% url 'account:register' %}" class="m-2">
+            <button type="button" class="bg-red-300 hover:bg-merah-muda w-fit text-black p-2 font-bold rounded-lg flex items-center justify-center">
+                Pelanggan
+            </button>
+        </a>
+    </div>
+    <div class="w-fit">
+        <a href="{% url 'account:login' %}" class="m-2">
+            <button type="button" class="bg-red-300 hover:bg-merah-muda w-fit text-black p-2 font-bold rounded-lg flex items-center justify-center">
+                Restoran
+            </button>
+        </a>
+        <a href="{% url 'account:register' %}" class="m-2">
+            <button type="button" class="bg-red-300 hover:bg-merah-muda w-fit text-black p-2 font-bold rounded-lg flex items-center justify-center">
+                Kurir
+            </button>
+        </a>
+    </div>
+</div>
+
+{% endblock content %}
\ No newline at end of file
diff --git a/account/tests.py b/account/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/account/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/account/urls.py b/account/urls.py
new file mode 100644
index 0000000..dee5619
--- /dev/null
+++ b/account/urls.py
@@ -0,0 +1,10 @@
+from django.urls import path
+from account.views import *
+
+app_name = 'account'
+
+urlpatterns = [
+    path('', show_main, name='show_main'),
+    path('login/', login, name='login'),
+    path('register/', register, name='register'),
+]
\ No newline at end of file
diff --git a/account/views.py b/account/views.py
new file mode 100644
index 0000000..64ea63f
--- /dev/null
+++ b/account/views.py
@@ -0,0 +1,11 @@
+from django.shortcuts import render
+
+# Create your views here.
+def show_main(request):
+    return render(request, 'main.html')
+
+def login(request):
+    return render(request, 'login.html')
+
+def register(request):
+    return render(request, 'register.html')
\ No newline at end of file
diff --git a/sirest/settings.py b/sirest/settings.py
index 95da8cd..c3f2fab 100644
--- a/sirest/settings.py
+++ b/sirest/settings.py
@@ -38,6 +38,7 @@ INSTALLED_APPS = [
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
+    'account',
 ]
 
 MIDDLEWARE = [
@@ -56,7 +57,7 @@ ROOT_URLCONF = 'sirest.urls'
 TEMPLATES = [
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
-        'DIRS': [],
+        'DIRS': [BASE_DIR / 'templates'],
         'APP_DIRS': True,
         'OPTIONS': {
             'context_processors': [
diff --git a/sirest/urls.py b/sirest/urls.py
index 748c9a9..63bbb87 100644
--- a/sirest/urls.py
+++ b/sirest/urls.py
@@ -14,8 +14,9 @@ Including another URLconf
     2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
 """
 from django.contrib import admin
-from django.urls import path
+from django.urls import path, include
 
 urlpatterns = [
     path('admin/', admin.site.urls),
+    path('', include('account.urls')),
 ]
diff --git a/templates/base.html b/templates/base.html
new file mode 100644
index 0000000..b3269bb
--- /dev/null
+++ b/templates/base.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <link href='https://fonts.googleapis.com/css?family=Inter' rel='stylesheet'>
+  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
+  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet"
+  integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous" />
+  <script src="https://cdn.tailwindcss.com"></script>
+  <script src="https://unpkg.com/ionicons@5.0.0/dist/ionicons.js"></script>
+  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
+  {% block meta %}
+  {% endblock meta %}
+</head>
+
+<body class="flex flex-col h-screen justify-between m-20">
+  <div>
+    {% block content %}
+    {% endblock content %}
+  </div>
+  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
+</body>
+
+</html>
\ No newline at end of file
-- 
GitLab