created apps, db models and templates

This commit is contained in:
faridlu 2022-09-26 05:46:58 +06:00
parent b79369e208
commit 3ed70ba317
45 changed files with 1238 additions and 30 deletions

0
accounts/__init__.py Normal file
View file

3
accounts/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
accounts/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class AccountsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'accounts'

View file

@ -0,0 +1,39 @@
# Generated by Django 3.2 on 2022-09-25 23:10
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]
operations = [
migrations.CreateModel(
name='UserAccount',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(max_length=2555, null=True, unique=True)),
('email', models.EmailField(max_length=255, unique=True)),
('first_name', models.CharField(max_length=255)),
('last_name', models.CharField(max_length=255)),
('avatar', models.ImageField(blank=True, null=True, upload_to='avatar/')),
('is_active', models.BooleanField(default=True)),
('is_staff', models.BooleanField(default=False)),
('get_newsletter', models.BooleanField(db_index=True, default=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={
'verbose_name': 'User',
'verbose_name_plural': 'Users',
'ordering': ['-id'],
},
),
]

View file

74
accounts/models.py Normal file
View file

@ -0,0 +1,74 @@
import datetime
from django.conf import settings
from django.contrib.auth.models import (AbstractBaseUser, BaseUserManager,
PermissionsMixin)
from django.db import models
# Create your models here.
class UserAccountManager(BaseUserManager):
""" Manages the functions needed to create a user """
def create_user(self, email, password=None, **extra_fields):
""" Creates and saves a new user """
if not email:
raise ValueError("Users must have an email address")
email = self.normalize_email(email)
user = self.model(email=email, **extra_fields)
user.set_password(password)
user.save(using=self._db)
return user
def create_superuser(self, email, password, **extra_fields):
user = self.create_user(email, password, **extra_fields)
user.is_superuser = True
user.is_staff = True
user.save(using=self._db)
return user
class UserAccount(AbstractBaseUser, PermissionsMixin):
""" General user account fields """
username = models.CharField(max_length=2555, null=True, unique=True)
email = models.EmailField(max_length=255, unique=True)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
avatar = models.ImageField(upload_to='avatar/', null=True, blank=True)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
get_newsletter = models.BooleanField(default=True, db_index=True)
objects = UserAccountManager()
USERNAME_FIELD = "email"
REQUIRED_FIELDS = ["first_name", "last_name"]
class Meta:
ordering = ['-id']
verbose_name = "User"
verbose_name_plural = "Users"
def get_short_name(self):
return self.first_name
def __str__(self):
return self.email
def get_or_create_userprofile(self):
from profiles.models import UserProfile
profile, _ = UserProfile.objects.get_or_create(user=self)
return profile
def get_avatar(self):
profile = self.get_or_create_userprofile()
return profile.avatar

3
accounts/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

8
accounts/urls.py Normal file
View file

@ -0,0 +1,8 @@
from django.contrib import admin
from django.urls import include, path
app_name = 'accounts'
urlpatterns = [
]

3
accounts/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

0
album/__init__.py Normal file
View file

3
album/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
album/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class AlbumConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'album'

View file

3
album/models.py Normal file
View file

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

0
album/serializers.py Normal file
View file

View file

@ -0,0 +1,39 @@
:root {
--jumbotron-padding-y: 3rem;
}
.jumbotron {
padding-top: var(--jumbotron-padding-y);
padding-bottom: var(--jumbotron-padding-y);
margin-bottom: 0;
background-color: #fff;
}
@media (min-width: 768px) {
.jumbotron {
padding-top: calc(var(--jumbotron-padding-y) * 2);
padding-bottom: calc(var(--jumbotron-padding-y) * 2);
}
}
.jumbotron p:last-child {
margin-bottom: 0;
}
.jumbotron-heading {
font-weight: 300;
}
.jumbotron .container {
max-width: 40rem;
}
footer {
padding-top: 3rem;
padding-bottom: 3rem;
}
footer p {
margin-bottom: .25rem;
}
.box-shadow { box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); }

View file

@ -0,0 +1,389 @@
{% extends 'base.html' %}
{% block content %}
<header>
<div class="collapse bg-dark" id="navbarHeader">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-7 py-4">
<h4 class="text-white">About</h4>
<p class="text-muted">
Add some information about the album below, the author, or any other
background context. Make it a few sentences long so folks can pick
up some informative tidbits. Then, link them off to some social
networking sites or contact information.
</p>
</div>
<div class="col-sm-4 offset-md-1 py-4">
<h4 class="text-white">Contact</h4>
<ul class="list-unstyled">
<li><a href="#" class="text-white">Follow on Twitter</a></li>
<li><a href="#" class="text-white">Like on Facebook</a></li>
<li><a href="#" class="text-white">Email me</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="navbar navbar-dark bg-dark box-shadow">
<div class="container d-flex justify-content-between">
<a href="#" class="navbar-brand d-flex align-items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="mr-2"
>
<path
d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"
></path>
<circle cx="12" cy="13" r="4"></circle>
</svg>
<strong>Album</strong>
</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarHeader"
aria-controls="navbarHeader"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
</header>
<main role="main">
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">Album example</h1>
<p class="lead text-muted">
Something short and leading about the collection below—its contents, the
creator, etc. Make it short and sweet, but not too short so folks don't
simply skip over it entirely.
</p>
<p>
<a href="#" class="btn btn-primary my-2">Main call to action</a>
<a href="#" class="btn btn-secondary my-2">Secondary action</a>
</p>
</div>
</section>
<div class="album py-5 bg-light">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
{% endblock content %}

View file

@ -0,0 +1,389 @@
{% extends 'base.html' %}
{% block content %}
<header>
<div class="collapse bg-dark" id="navbarHeader">
<div class="container">
<div class="row">
<div class="col-sm-8 col-md-7 py-4">
<h4 class="text-white">About</h4>
<p class="text-muted">
Add some information about the album below, the author, or any other
background context. Make it a few sentences long so folks can pick
up some informative tidbits. Then, link them off to some social
networking sites or contact information.
</p>
</div>
<div class="col-sm-4 offset-md-1 py-4">
<h4 class="text-white">Contact</h4>
<ul class="list-unstyled">
<li><a href="#" class="text-white">Follow on Twitter</a></li>
<li><a href="#" class="text-white">Like on Facebook</a></li>
<li><a href="#" class="text-white">Email me</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="navbar navbar-dark bg-dark box-shadow">
<div class="container d-flex justify-content-between">
<a href="#" class="navbar-brand d-flex align-items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="mr-2"
>
<path
d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"
></path>
<circle cx="12" cy="13" r="4"></circle>
</svg>
<strong>Album</strong>
</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarHeader"
aria-controls="navbarHeader"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
</header>
<main role="main">
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">Album example</h1>
<p class="lead text-muted">
Something short and leading about the collection below—its contents, the
creator, etc. Make it short and sweet, but not too short so folks don't
simply skip over it entirely.
</p>
<p>
<a href="#" class="btn btn-primary my-2">Main call to action</a>
<a href="#" class="btn btn-secondary my-2">Secondary action</a>
</p>
</div>
</section>
<div class="album py-5 bg-light">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img
class="card-img-top"
data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail"
alt="Card image cap"
/>
<div class="card-body">
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
View
</button>
<button
type="button"
class="btn btn-sm btn-outline-secondary"
>
Edit
</button>
</div>
<small class="text-muted">9 mins</small>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
{% endblock content %}

3
album/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

10
album/urls.py Normal file
View file

@ -0,0 +1,10 @@
from django.contrib import admin
from django.urls import include, path
from album.views import HomePageView
app_name = 'album'
urlpatterns = [
path('', HomePageView.as_view(), name='homepage')
]

38
album/views.py Normal file
View file

@ -0,0 +1,38 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.views.generic import CreateView, TemplateView
# Create your views here.
class HomePageView(TemplateView):
template_name = 'album/homepage.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# NOTE: This will be used to update the active window in navbar
context.update({
'contact_us_create': 'active'
})
return context
# def post(self, request, *args, **kwargs) -> HttpResponse:
# data = {
# 'user': request.user.id,
# 'title': request.POST.get('title'),
# 'description': request.POST.get('description'),
# 'inquiry_type': request.POST.get('inquiry_type'),
# }
# serializer = ContactUsCreateSerializer(data=data)
# serializer.is_valid(raise_exception=True)
# instance = serializer.save()
# send_new_inquiry_notification.delay(instance.id)
# messages.success(self.request, 'Enquiry submitted successfully.')
# return HttpResponseRedirect('/dashboard')

View file

@ -1,15 +1,4 @@
"""
Django settings for config project.
Generated by 'django-admin startproject' using Django 3.2.3.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@ -32,6 +21,15 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Local apps
'accounts',
'album',
'core',
'profiles',
# Third party apps
# ....
]
MIDDLEWARE = [
@ -49,7 +47,7 @@ ROOT_URLCONF = 'config.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
@ -64,6 +62,7 @@ TEMPLATES = [
WSGI_APPLICATION = 'config.wsgi.application'
AUTH_USER_MODEL = "accounts.UserAccount"
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
@ -102,6 +101,13 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# STATICFILES_DIRS = (
# os.path.join(BASE_DIR, 'static'),
# )
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/media')
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

View file

@ -12,6 +12,6 @@ ALLOWED_HOSTS = []
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'NAME': 'db.sqlite3',
}
}

View file

@ -1,21 +1,16 @@
"""config URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('accounts.urls')),
path('', include('core.urls')),
path('', include('album.urls')),
path('', include('profiles.urls')),
]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

0
core/__init__.py Normal file
View file

3
core/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
core/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class CoreConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'core'

View file

3
core/models.py Normal file
View file

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
core/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

8
core/urls.py Normal file
View file

@ -0,0 +1,8 @@
from django.contrib import admin
from django.urls import include, path
app_name = 'core'
urlpatterns = [
]

3
core/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

Binary file not shown.

0
profiles/__init__.py Normal file
View file

3
profiles/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
profiles/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ProfilesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'profiles'

View file

@ -0,0 +1,30 @@
# Generated by Django 3.2 on 2022-09-25 23:10
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='UserProfile',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('avatar', models.ImageField(blank=True, null=True, upload_to='avatar/')),
('phone_number', models.CharField(blank=True, max_length=100, null=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'UserProfile',
'verbose_name_plural': 'UserProfiles',
},
),
]

View file

31
profiles/models.py Normal file
View file

@ -0,0 +1,31 @@
import datetime
from django.db import models
from accounts.models import UserAccount
# Create your models here.
class UserProfile(models.Model):
"""Model definition for UserProfile."""
# from order.models import Address
user = models.OneToOneField(UserAccount, on_delete=models.CASCADE)
avatar = models.ImageField(upload_to='avatar/', null=True, blank=True)
phone_number = models.CharField(max_length=100, null=True, blank=True)
class Meta:
"""Meta definition for UserProfile."""
verbose_name = 'UserProfile'
verbose_name_plural = 'UserProfiles'
def __str__(self):
return self.user.email
def get_shipping_address_data(self):
return None if not self.shipping_address else self.get_serialized_data(self.shipping_address)
def get_billing_address_data(self):
return None if not self.billing_address else self.get_serialized_data(self.billing_address)\

3
profiles/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

8
profiles/urls.py Normal file
View file

@ -0,0 +1,8 @@
from django.contrib import admin
from django.urls import include, path
app_name = 'profiles'
urlpatterns = [
]

3
profiles/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View file

@ -1,7 +1,35 @@
asgiref==3.5.2
astroid==2.12.10
autopep8==1.7.0
backports.zoneinfo==0.2.1
black==22.8.0
certifi==2022.9.24
charset-normalizer==2.0.12
click==8.1.3
decorator==5.1.1
dill==0.3.5.1
Django==3.2
idna==3.4
isort==5.10.1
lazy-object-proxy==1.7.1
mccabe==0.7.0
mypy-extensions==0.4.3
pathspec==0.10.1
Pillow==9.2.0
platformdirs==2.5.2
pycodestyle==2.9.1
pylint==2.15.3
python-decouple==3.6
pytz==2022.2.1
requests==2.27.1
six==1.16.0
sqlparse==0.4.3
toml==0.10.2
tomli==2.0.1
tomlkit==0.11.4
tqdm==4.64.1
typing-extensions==4.3.0
urllib3==1.26.12
validators==0.18.2
weaviate-client==3.8.0
wrapt==1.14.1

53
templates/base.html Normal file
View file

@ -0,0 +1,53 @@
{% load static %}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="/docs/4.0/assets/img/favicons/favicon.ico">
<title>Photo Album</title>
<link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/album/">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Custom styles for this template -->
<link href="{% static 'album/css/album.css' %}" rel="stylesheet">
</head>
<body>
{% block content %}
{% endblock content %}
<footer class="text-muted">
<div class="container">
<p class="float-right">
<a href="#">Back to top</a>
</p>
<p>Album example is &copy; Bootstrap, but please download and customize it for yourself!</p>
<p>New to Bootstrap? <a href="../../">Visit the homepage</a> or read our <a href="../../getting-started/">getting started guide</a>.</p>
</div>
</footer>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
{% comment %} <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery-slim.min.js"><\/script>')</script>
<script src="../../assets/js/vendor/popper.min.js"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<script src="../../assets/js/vendor/holder.min.js"></script> {% endcomment %}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.9/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

0
templates/homepage.html Normal file
View file