Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Code With Stein committed May 22, 2023
0 parents commit 0d38f31
Show file tree
Hide file tree
Showing 41 changed files with 1,831 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.pyc
*/*.pyc
*/*/*.pyc
node_modules
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Jatte

This project is the base starter for a tutorial from Code With Stein
Empty file added account/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions account/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib import admin

from .models import User


admin.site.register(User)
6 changes: 6 additions & 0 deletions account/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AccountConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'account'
47 changes: 47 additions & 0 deletions account/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from django import forms
from django.contrib.auth.forms import AuthenticationForm

from .models import User


class LoginForm(AuthenticationForm):
class Meta:
model = User
fields = ('username', 'password',)


class AddUserForm(forms.ModelForm):
class Meta:
model = User
fields = ('email', 'name', 'role', 'password',)
widgets = {
'email': forms.TextInput(attrs={
'class': 'w-full py-4 px-6 rounded-xl border'
}),
'name': forms.TextInput(attrs={
'class': 'w-full py-4 px-6 rounded-xl border'
}),
'role': forms.Select(attrs={
'class': 'w-full py-4 px-6 rounded-xl border'
}),
'password': forms.TextInput(attrs={
'class': 'w-full py-4 px-6 rounded-xl border'
})
}


class EditUserForm(forms.ModelForm):
class Meta:
model = User
fields = ('email', 'name', 'role',)
widgets = {
'email': forms.TextInput(attrs={
'class': 'w-full py-4 px-6 rounded-xl border'
}),
'name': forms.TextInput(attrs={
'class': 'w-full py-4 px-6 rounded-xl border'
}),
'role': forms.Select(attrs={
'class': 'w-full py-4 px-6 rounded-xl border'
})
}
40 changes: 40 additions & 0 deletions account/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.1.7 on 2023-05-20 06:20

import account.models
from django.db import migrations, models
import django.utils.timezone
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]

operations = [
migrations.CreateModel(
name='User',
fields=[
('password', models.CharField(max_length=128, verbose_name='password')),
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('email', models.EmailField(max_length=254, unique=True)),
('name', models.CharField(blank=True, default='', max_length=255)),
('is_active', models.BooleanField(default=True)),
('is_superuser', models.BooleanField(default=False)),
('is_staff', models.BooleanField(default=False)),
('date_joined', models.DateTimeField(default=django.utils.timezone.now)),
('last_login', models.DateTimeField(blank=True, null=True)),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
],
options={
'abstract': False,
},
managers=[
('objects', account.models.CustomUserManager()),
],
),
]
18 changes: 18 additions & 0 deletions account/migrations/0002_user_role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.7 on 2023-05-20 06:23

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.AddField(
model_name='user',
name='role',
field=models.CharField(choices=[('agent', 'Agent'), ('manager', 'Manager')], default='agent', max_length=20),
),
]
Empty file added account/migrations/__init__.py
Empty file.
56 changes: 56 additions & 0 deletions account/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import uuid

from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, UserManager
from django.db import models
from django.utils import timezone


class CustomUserManager(UserManager):
def _create_user(self, name, email, password, **extra_fields):
if not email:
raise ValueError("You have not provided a valid e-mail address")

email = self.normalize_email(email)
user = self.model(email=email, name=name, **extra_fields)
user.set_password(password)
user.save(using=self._db)

return user

def create_user(self, name=None, email=None, password=None, **extra_fields):
extra_fields.setdefault('is_staff', False)
extra_fields.setdefault('is_superuser', False)
return self._create_user(name, email, password, **extra_fields)

def create_superuser(self, name=None, email=None, password=None, **extra_fields):
extra_fields.setdefault('is_staff', True)
extra_fields.setdefault('is_superuser', True)
return self._create_user(name, email, password, **extra_fields)


class User(AbstractBaseUser, PermissionsMixin):
AGENT = 'agent'
MANAGER = 'manager'

ROLES_CHOICES = (
(AGENT, 'Agent'),
(MANAGER, 'Manager'),
)

id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
email = models.EmailField(unique=True)
name = models.CharField(max_length=255, blank=True, default='')
role = models.CharField(max_length=20, choices=ROLES_CHOICES, default=AGENT)

is_active = models.BooleanField(default=True)
is_superuser = models.BooleanField(default=False)
is_staff = models.BooleanField(default=False)

date_joined = models.DateTimeField(default=timezone.now)
last_login = models.DateTimeField(blank=True, null=True)

objects = CustomUserManager()

USERNAME_FIELD = 'email'
EMAIL_FIELD = 'email'
REQUIRED_FIELDS = ['name']
33 changes: 33 additions & 0 deletions account/templates/account/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends 'core/base.html' %}

{% block content %}
<h1 class="mb-6 text-xl">Login</h1>

<form method="post" action=".">
{% csrf_token %}

<div class="mb-4">
<label for="id_email">Email</label>

<input type="email" name="email" id="id_email" class="w-full py-4 px-6 rounded-xl border">
</div>

<div class="mb-4">
<label for="id_password">Password</label>

<input type="password" name="password" id="id_password" class="w-full py-4 px-6 rounded-xl border">
</div>

{% if form.errors or form.non_field_errors %}
<div class="mb-4 p-6 bg-rose-100 rounded-xl">
{% for field in form %}
{{ field.errors }}
{% endfor %}

{{ form.non_field_errors }}
</div>
{% endif %}

<button class="py-2 px-6 bg-rose-600 text-white rounded-xl">Submit</button>
</form>
{% endblock %}
3 changes: 3 additions & 0 deletions account/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
11 changes: 11 additions & 0 deletions account/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib.auth.views import LoginView
from django.urls import path

from .forms import LoginForm

app_name = 'account'


urlpatterns = [
path('login/', LoginView.as_view(template_name='account/login.html', form_class=LoginForm), name='login')
]
3 changes: 3 additions & 0 deletions account/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
Empty file added core/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions core/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions core/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class CoreConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'core'
Empty file added core/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions core/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
5 changes: 5 additions & 0 deletions core/templates/core/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends 'core/base.html' %}

{% block content %}
<h1 class="mb-6 text-2xl">About</h1>
{% endblock %}
45 changes: 45 additions & 0 deletions core/templates/core/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% load static %}

<!doctype html>

<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" type="text/css" href="{% static 'css/main.min.css' %}">
</head>

<body>
<div class="p-2">
<nav class="p-6 bg-rose-600 text-white flex justify-between items-center rounded-xl">
<a href="{% url 'core:index' %}" class="text-xl">Jatte</a>

<div class="flex items-center space-x-4">
<a href="{% url 'core:index' %}">Home</a>
<a href="{% url 'core:about' %}">About</a>
</div>
</nav>

<main class="max-w-6xl mx-auto p-6">
{% if messages %}
<div class="message mb-6 p-6 bg-gray-800 text-white rounded-xl">
{% for message in messages %}
<p>{{ message }}</p>
{% endfor %}
</div>
{% endif %}

{% block content %}
{% endblock %}
</main>
</div>

<footer class="py-12 px-6 bg-gray-800 text-white text-center text-xs">
<p>Copyright (c) 2023 - Jatte</p>
</footer>

{% block scripts %}
{% endblock %}
</body>
</html>
79 changes: 79 additions & 0 deletions core/templates/core/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{% extends 'core/base.html' %}

{% load static %}

{% block content %}
<div class="mt-12 py-12 px-8 grid grid-cols-5 gap-4 items-center border border-rose-200 rounded-xl">
<div class="col-span-2">
<img src="{% static 'images/header.png' %}">
</div>

<div class="col-span-3">
<h1 class="mb-8 text-3xl">Welcome to Jatte</h1>

<h2 class="text-lg text-gray-500">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec accumsan tortor at sem fermentum tempor. Suspendisse vitae augue dolor. Nunc sed eleifend nulla.</h2>
</div>
</div>

<div class="mt-12 py-12 px-8 grid grid-cols-3 gap-4 items-center">
<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12 mb-8 text-rose-600 mx-auto">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.625 9.75a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375m-13.5 3.01c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.184-4.183a1.14 1.14 0 01.778-.332 48.294 48.294 0 005.83-.498c1.585-.233 2.708-1.626 2.708-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" />
</svg>

<h3 class="mb-4 text-xl text-gray-800">A dummy title</h3>

<p class="text-gray-500">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec accumsan tortor at sem fermentum tempor.</p>
</div>

<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12 mb-8 text-rose-600 mx-auto">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.625 9.75a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375m-13.5 3.01c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.184-4.183a1.14 1.14 0 01.778-.332 48.294 48.294 0 005.83-.498c1.585-.233 2.708-1.626 2.708-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" />
</svg>

<h3 class="mb-4 text-xl text-gray-800">A dummy title</h3>

<p class="text-gray-500">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec accumsan tortor at sem fermentum tempor.</p>
</div>

<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12 mb-8 text-rose-600 mx-auto">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.625 9.75a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375m-13.5 3.01c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.184-4.183a1.14 1.14 0 01.778-.332 48.294 48.294 0 005.83-.498c1.585-.233 2.708-1.626 2.708-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" />
</svg>

<h3 class="mb-4 text-xl text-gray-800">A dummy title</h3>

<p class="text-gray-500">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec accumsan tortor at sem fermentum tempor.</p>
</div>

<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12 mb-8 text-rose-600 mx-auto">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.625 9.75a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375m-13.5 3.01c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.184-4.183a1.14 1.14 0 01.778-.332 48.294 48.294 0 005.83-.498c1.585-.233 2.708-1.626 2.708-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" />
</svg>

<h3 class="mb-4 text-xl text-gray-800">A dummy title</h3>

<p class="text-gray-500">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec accumsan tortor at sem fermentum tempor.</p>
</div>

<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12 mb-8 text-rose-600 mx-auto">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.625 9.75a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375m-13.5 3.01c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.184-4.183a1.14 1.14 0 01.778-.332 48.294 48.294 0 005.83-.498c1.585-.233 2.708-1.626 2.708-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" />
</svg>

<h3 class="mb-4 text-xl text-gray-800">A dummy title</h3>

<p class="text-gray-500">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec accumsan tortor at sem fermentum tempor.</p>
</div>

<div class="text-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-12 h-12 mb-8 text-rose-600 mx-auto">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.625 9.75a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375m-13.5 3.01c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.184-4.183a1.14 1.14 0 01.778-.332 48.294 48.294 0 005.83-.498c1.585-.233 2.708-1.626 2.708-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0012 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018z" />
</svg>

<h3 class="mb-4 text-xl text-gray-800">A dummy title</h3>

<p class="text-gray-500">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec accumsan tortor at sem fermentum tempor.</p>
</div>
</div>
{% endblock %}
Loading

0 comments on commit 0d38f31

Please sign in to comment.