Commit bc19e3f8 authored by Radiedtya's avatar Radiedtya

first commit

parents
Pipeline #2119 failed with stages
File added
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class MainConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'main'
from django.db import models
# Create your models here.
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}Siakad{% endblock %}</title>
<script src="https://cdn.tailwindcss.com"></script>
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
</head>
<body class="bg-gray-300">
{% if show_navbar %}
{% include 'main/components/navbar.html' %}
{% endif %}
<div class="p-6">
{% block content %}
{% endblock %}
</div>
</body>
</html>
\ No newline at end of file
{% load static %}
<header
class="border-b border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900"
x-data="{ open: false }"
>
<div class="mx-auto flex h-16 max-w-7xl items-center gap-8 px-4 sm:px-6 lg:px-8">
<a href="{% url 'dashboard' %}" class="group flex">
<span class="text-xl font-bold tracking-widest text-gray-900 uppercase transition-colors group-hover:text-lime-600 dark:text-white group-hover:dark:text-lime-400">
SI<span class="text-lime-600 transition-colors group-hover:text-gray-900 dark:text-lime-400 dark:group-hover:text-white">AKAD</span>
</span>
</a>
<div class="flex flex-1 items-center justify-end md:justify-between">
<nav class="hidden md:block">
<ul class="flex items-center gap-6 text-sm">
<li>
<a href="{% url 'dashboard' %}"
class="rounded-md bg-lime-100 px-3 py-2 text-sm font-medium text-lime-700 dark:bg-lime-900/50 dark:text-lime-300">
Dashboard
</a>
</li>
<li>
<a href="#"
class="text-gray-500 transition hover:text-gray-500/75 dark:text-white dark:hover:text-white/75">
Teams
</a>
</li>
<li>
<a href="#"
class="text-gray-500 transition hover:text-gray-500/75 dark:text-white dark:hover:text-white/75">
Projects
</a>
</li>
<li>
<a href="#"
class="text-gray-500 transition hover:text-gray-500/75 dark:text-white dark:hover:text-white/75">
Calendar
</a>
</li>
</ul>
</nav>
<!-- RIGHT -->
<div class="flex items-center gap-4">
{% if request.user.is_authenticated %}
<a href="#"
class="block shrink-0 rounded-full bg-white p-2.5 text-gray-600 transition hover:text-gray-700 dark:bg-gray-800 dark:text-white dark:hover:text-white/75">
<span class="sr-only">Notifications</span>
<svg xmlns="http://www.w3.org/2000/svg" class="size-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
</svg>
</a>
<div class="flex items-center gap-2">
<img
src="https://images.unsplash.com/photo-1600486913747-55e5470d6f40"
class="h-10 w-10 rounded-full object-cover"
/>
<a href="{% url 'logout' %}"
class="text-sm text-red-500 hover:underline">
Logout
</a>
</div>
{% endif %}
<!-- Mobile Button -->
<button
@click="open = !open"
class="block rounded bg-gray-100 p-2.5 text-gray-600 transition md:hidden dark:bg-gray-800 dark:text-white"
>
<span class="sr-only">Toggle menu</span>
☰
</button>
</div>
</div>
</div>
<!-- MOBILE MENU -->
<div x-show="open" class="md:hidden px-4 pb-4">
<ul class="space-y-2 text-sm text">
<li><a href="{% url 'dashboard' %}">Dashboard</a></li>
<li><a href="#">Teams</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Calendar</a></li>
{% if request.user.is_authenticated %}
<li><a href="{% url 'logout' %}" class="text-red-500">Logout</a></li>
{% endif %}
</ul>
</div>
</header>
\ No newline at end of file
{% extends 'main/base.html' %}
{% block title %}Dashboard - SIAKAD{% endblock %}
{% block content %}
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="bg-white p-6 rounded-2xl shadow hover:shadow-lg transition">
<h2 class="text-lg font-bold text-gray-700">Mahasiswa</h2>
<p class="text-3xl font-bold text-blue-500 mt-2">120</p>
</div>
<div class="bg-white p-6 rounded-2xl shadow hover:shadow-lg transition">
<h2 class="text-lg font-bold text-gray-700">Dosen</h2>
<p class="text-3xl font-bold text-green-500 mt-2">25</p>
</div>
<div class="bg-white p-6 rounded-2xl shadow hover:shadow-lg transition">
<h2 class="text-lg font-bold text-gray-700">Mata Kuliah</h2>
<p class="text-3xl font-bold text-purple-500 mt-2">40</p>
</div>
</div>
<div class="mt-8 bg-white p-6 rounded-2xl shadow">
<h2 class="text-xl font-bold mb-2">
Selamat datang, {{ request.user.username }}
</h2>
<p class="text-gray-600">
Ini adalah dashboard
</p>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'main/base.html' %}
{% block title %}Login - Siakad{% endblock %}
{% block content %}
<div class="flex items-center justify-center h-screen">
<div class="bg-white p-8 rounded-2xl shadow-xl w-96 text-center">
<h1 class="text-2xl font-bold tracking-widest text-gray-900 uppercase mb-6">
SI<span class="text-lime-600">AKAD</span>
</h1>
{% if error %}
<div class="bg-red-100 text-red-600 p-2 rounded mb-4 text-sm">
{{ error }}
</div>
{% endif %}
<form method="post" class="space-y-4 text-left">
{% csrf_token %}
<input type="text" name="username" placeholder="Username"
class="w-full p-3 border rounded-lg focus:ring-2 focus:ring-lime-400">
<input type="password" name="password" placeholder="Password"
class="w-full p-3 border rounded-lg focus:ring-2 focus:ring-lime-400">
<button
class="w-full bg-lime-600 text-white py-3 rounded-lg hover:bg-lime-700 transition">
Login
</button>
</form>
</div>
</div>
{% endblock %}
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from . import views
urlpatterns = [
path('', views.login_view, name='login'),
path('dashboard/', views.dashboard, name='dashboard'),
path('logout/', views.logout_view, name='logout'),
]
\ No newline at end of file
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
def login_view(request):
if request.user.is_authenticated:
return redirect('dashboard')
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect('dashboard')
else:
return render(request, 'main/login.html', {'error': 'Login gagal'})
return render(request, 'main/login.html', {
'show_navbar': False,
})
def dashboard(request):
if not request.user.is_authenticated:
return redirect('login')
return render(request, 'main/dashboard.html', {
'show_navbar': True,
})
def logout_view(request):
logout(request)
return redirect('login')
\ No newline at end of file
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'siakad.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
"""
ASGI config for siakad project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'siakad.settings')
application = get_asgi_application()
"""
Django settings for siakad project.
Generated by 'django-admin startproject' using Django 4.2.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-wl0s^e^qbzhr8u6u!k-26upel4m8!$ib8&a7ytmx@cuxwdic$w'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'siakad.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'siakad.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('main.urls')),
path('admin/', admin.site.urls),
]
"""
WSGI config for siakad project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'siakad.settings')
application = get_wsgi_application()
Markdown is supported
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