django first upload

This commit is contained in:
Bob 2023-04-23 19:08:01 +03:00
commit b38379e363
74 changed files with 1258 additions and 0 deletions

BIN
base/.DS_Store vendored Normal file

Binary file not shown.

0
base/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
base/admin.py Normal file
View File

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

6
base/apps.py Normal file
View File

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

View File

@ -0,0 +1,32 @@
# Generated by Django 4.2 on 2023-04-20 11:40
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='VendorsData',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('vendor', models.CharField(max_length=8, unique=True)),
('vendorSecretKey', models.UUIDField()),
('vendorCoverAmount', models.IntegerField(default=0)),
('vendorPaidNotification', models.IntegerField(default=1)),
('vendorSkipScreen', models.IntegerField(default=0)),
('vendorPayWindow', models.IntegerField(default=0)),
('vendorWebName', models.CharField(max_length=250)),
('vendorWebAddr', models.CharField(max_length=250)),
('vendorAddDate', models.DateTimeField(auto_now_add=True)),
('vendorDeleted', models.IntegerField(default=0)),
('vendorAddDelete', models.DateTimeField(auto_now=True)),
('vendorIsActive', models.IntegerField(default=1)),
],
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 4.2 on 2023-04-20 11:40
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),
('base', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='vendorsdata',
name='vendorid',
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 4.2 on 2023-04-20 12:34
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('base', '0002_initial'),
]
operations = [
migrations.AlterModelOptions(
name='vendorsdata',
options={'ordering': ['-id'], 'verbose_name': 'Vendor', 'verbose_name_plural': 'Vendors'},
),
]

View File

@ -0,0 +1,19 @@
# Generated by Django 4.2 on 2023-04-20 12:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0003_alter_vendorsdata_options'),
]
operations = [
migrations.AddField(
model_name='vendorsdata',
name='vendorUUID',
field=models.UUIDField(default=2),
preserve_default=False,
),
]

View File

Binary file not shown.

Binary file not shown.

30
base/models.py Normal file
View File

@ -0,0 +1,30 @@
from django.db import models
from users.models import User
# Create your models here.
class VendorsData(models.Model):
vendorid = models.ForeignKey(User, default=None, on_delete=models.CASCADE)
vendorUUID = models.UUIDField()
vendor = models.CharField(max_length=8, unique=True)
vendorSecretKey = models.UUIDField()
vendorCoverAmount = models.IntegerField(default=0)
vendorPaidNotification = models.IntegerField(default=1)
vendorSkipScreen = models.IntegerField(default=0)
vendorPayWindow = models.IntegerField(default=0)
vendorWebName = models.CharField(max_length=250)
vendorWebAddr = models.CharField(max_length=250)
vendorAddDate = models.DateTimeField(auto_now_add=True)
vendorDeleted = models.IntegerField(default=0)
vendorAddDelete = models.DateTimeField(auto_now=True)
vendorIsActive = models.IntegerField(default=1)
def __str__(self):
return self.vendor
class Meta:
verbose_name = "Vendor"
verbose_name_plural = "Vendors"
ordering = ["-id"]

View File

@ -0,0 +1,327 @@
{% extends "partials/base.html" %}
{% load static %}
{% block title %}Dashboard{% endblock title %}
{% block content %}
<!-- ============================================================== -->
<!-- Start right Content here -->
<!-- ============================================================== -->
<!-- Main content -->
<div class="h-screen flex-grow-1 overflow-y-lg-auto">
<!-- Header -->
<header class="bg-surface-primary border-bottom pt-6">
<div class="container-fluid">
<div class="mb-npx">
<div class="row align-items-center">
<div class="col-sm-6 col-12 mb-4 mb-sm-0">
<!-- Title -->
<h1 class="h2 mb-0 ls-tight"> Dashboard </h1>
<hr class="navbar-divider my-1 opacity-20">
<p> Hello "user", welcome! Here's what's happening with your store today.</p>
</div>
<!-- Actions -->
<hr class="navbar-divider my-1 opacity-20">
</div>
<!-- Nav -->
</div>
</div>
</header>
<!-- Main -->
<main class="py-6 bg-surface-secondary">
<div class="container-fluid">
<!-- Card stats -->
<div class="row g-6 mb-6">
<div class="col-xl-3 col-sm-6 col-12">
<div class="card shadow border-0">
<div class="card-body">
<div class="row">
<div class="col">
<span class="h6 font-semibold text-muted text-sm d-block mb-2">Earnings</span>
<span class="h3 font-bold mb-0">$750.90</span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-tertiary text-white text-lg rounded-circle">
<i class="bi bi-credit-card"></i>
</div>
</div>
</div>
<div class="mt-2 mb-0 text-sm">
<span class="badge badge-pill bg-soft-success text-success me-2">
<i class="bi bi-arrow-up me-1"></i>13%
</span>
<span class="text-nowrap text-xs text-muted">Since last month</span>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-sm-6 col-12">
<div class="card shadow border-0">
<div class="card-body">
<div class="row">
<div class="col">
<span class="h6 font-semibold text-muted text-sm d-block mb-2">Balance</span>
<span class="h3 font-bold mb-0">215</span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-primary text-white text-lg rounded-circle">
<i class="bi bi-people"></i>
</div>
</div>
</div>
<div class="mt-2 mb-0 text-sm">
<span class="badge badge-pill bg-soft-success text-success me-2">
<i class="bi bi-arrow-up me-1"></i>30%
</span>
<span class="text-nowrap text-xs text-muted">Since last month</span>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-sm-6 col-12">
<div class="card shadow border-0">
<div class="card-body">
<div class="row">
<div class="col">
<span class="h6 font-semibold text-muted text-sm d-block mb-2">Customers</span>
<span class="h3 font-bold mb-0">1.400</span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-info text-white text-lg rounded-circle">
<i class="bi bi-clock-history"></i>
</div>
</div>
</div>
<div class="mt-2 mb-0 text-sm">
<span class="badge badge-pill bg-soft-danger text-danger me-2">
<i class="bi bi-arrow-down me-1"></i>-5%
</span>
<span class="text-nowrap text-xs text-muted">Since last month</span>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-sm-6 col-12">
<div class="card shadow border-0">
<div class="card-body">
<div class="row">
<div class="col">
<span class="h6 font-semibold text-muted text-sm d-block mb-2">Invoices</span>
<span class="h3 font-bold mb-0">150</span>
</div>
<div class="col-auto">
<div class="icon icon-shape bg-warning text-white text-lg rounded-circle">
<i class="bi bi-minecart-loaded"></i>
</div>
</div>
</div>
<div class="mt-2 mb-0 text-sm">
<span class="badge badge-pill bg-soft-success text-success me-2">
<i class="bi bi-arrow-up me-1"></i>10%
</span>
<span class="text-nowrap text-xs text-muted">Since last month</span>
</div>
</div>
</div>
</div>
</div>
<div class="card shadow border-0 mb-7">
<div class="card-header">
<h5 class="mb-0">Last 5 paid invoices</h5>
</div>
<div class="table-responsive">
<table class="table table-hover table-nowrap">
<thead class="thead-light">
<tr>
<th scope="col">Name</th>
<th scope="col">Date</th>
<th scope="col">Company</th>
<th scope="col">Offer</th>
<th scope="col">Meeting</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<img alt="..." src="https://images.unsplash.com/photo-1502823403499-6ccfcf4fb453?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=3&w=256&h=256&q=80" class="avatar avatar-sm rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Robert Fox
</a>
</td>
<td>
Feb 15, 2021
</td>
<td>
<img alt="..." src="https://preview.webpixels.io/web/img/other/logos/logo-1.png" class="avatar avatar-xs rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Dribbble
</a>
</td>
<td>
$3.500
</td>
<td>
<span class="badge badge-lg badge-dot">
<i class="bg-success"></i>Scheduled
</span>
</td>
<td class="text-end">
<a href="#" class="btn btn-sm btn-neutral">View</a>
<button type="button" class="btn btn-sm btn-square btn-neutral text-danger-hover">
<i class="bi bi-trash"></i>
</button>
</td>
</tr>
<tr>
<td>
<img alt="..." src="https://images.unsplash.com/photo-1610271340738-726e199f0258?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=3&w=256&h=256&q=80" class="avatar avatar-sm rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Darlene Robertson
</a>
</td>
<td>
Apr 15, 2021
</td>
<td>
<img alt="..." src="https://preview.webpixels.io/web/img/other/logos/logo-2.png" class="avatar avatar-xs rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Netguru
</a>
</td>
<td>
$2.750
</td>
<td>
<span class="badge badge-lg badge-dot">
<i class="bg-warning"></i>Postponed
</span>
</td>
<td class="text-end">
<a href="#" class="btn btn-sm btn-neutral">View</a>
<button type="button" class="btn btn-sm btn-square btn-neutral text-danger-hover">
<i class="bi bi-trash"></i>
</button>
</td>
</tr>
<tr>
<td>
<img alt="..." src="https://images.unsplash.com/photo-1610878722345-79c5eaf6a48c?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=3&w=256&h=256&q=80" class="avatar avatar-sm rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Theresa Webb
</a>
</td>
<td>
Mar 20, 2021
</td>
<td>
<img alt="..." src="https://preview.webpixels.io/web/img/other/logos/logo-3.png" class="avatar avatar-xs rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Figma
</a>
</td>
<td>
$4.200
</td>
<td>
<span class="badge badge-lg badge-dot">
<i class="bg-success"></i>Scheduled
</span>
</td>
<td class="text-end">
<a href="#" class="btn btn-sm btn-neutral">View</a>
<button type="button" class="btn btn-sm btn-square btn-neutral text-danger-hover">
<i class="bi bi-trash"></i>
</button>
</td>
</tr>
<tr>
<td>
<img alt="..." src="https://images.unsplash.com/photo-1612422656768-d5e4ec31fac0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=3&w=256&h=256&q=80" class="avatar avatar-sm rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Kristin Watson
</a>
</td>
<td>
Feb 15, 2021
</td>
<td>
<img alt="..." src="https://preview.webpixels.io/web/img/other/logos/logo-4.png" class="avatar avatar-xs rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Mailchimp
</a>
</td>
<td>
$3.500
</td>
<td>
<span class="badge badge-lg badge-dot">
<i class="bg-dark"></i>Not discussed
</span>
</td>
<td class="text-end">
<a href="#" class="btn btn-sm btn-neutral">View</a>
<button type="button" class="btn btn-sm btn-square btn-neutral text-danger-hover">
<i class="bi bi-trash"></i>
</button>
</td>
</tr>
<tr>
<td>
<img alt="..." src="https://images.unsplash.com/photo-1608976328267-e673d3ec06ce?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=3&w=256&h=256&q=80" class="avatar avatar-sm rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Cody Fisher
</a>
</td>
<td>
Apr 10, 2021
</td>
<td>
<img alt="..." src="https://preview.webpixels.io/web/img/other/logos/logo-5.png" class="avatar avatar-xs rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
Webpixels
</a>
</td>
<td>
$1.500
</td>
<td>
<span class="badge badge-lg badge-dot">
<i class="bg-danger"></i>Canceled
</span>
</td>
<td class="text-end">
<a href="#" class="btn btn-sm btn-neutral">View</a>
<button type="button" class="btn btn-sm btn-square btn-neutral text-danger-hover">
<i class="bi bi-trash"></i>
</button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="card-footer border-0 py-5">
<span class="text-muted text-sm">#</span>
</div>
</div>
</div>
</main>
</div>
</div>
<!-- Dashboard -->
<!-- End Page-content -->
<div>
{% block footer %}
{% include "partials/footer.html" %}
{% endblock footer %}
</div>
<!-- end main content-->
{% endblock content %}

View File

@ -0,0 +1,83 @@
<!DOCTYPE html>
<html lang="en" class="h-100">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title> </title>
<meta name="robots" content="index">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="LitePay.ch">
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" href="https://ik.imagekit.io/litepaych/assets/dashboard/images/logo_litepay_2020_white_box.png">
<link href="https://litepay.ch//assets/new/secure/css/style.css" rel="stylesheet">
<link rel="canonical" href="https://litepay.ch/merchant/login">
</head>
{% block content %}
<!-- ============================================================== -->
<!-- Start right Content here -->
<!-- ============================================================== -->
<!-- Main content -->
<link rel="icon" type="image/png" sizes="16x16" href="https://ik.imagekit.io/litepaych/assets/dashboard/images/logo_litepay_2020_white_box.png">
<h1 style="visibility: hidden"> Sign in your Litepay.ch account </h1>
<body class="h-100">
<div class="authincation h-100">
<div class="container h-100">
<div class="row justify-content-center h-100 align-items-center">
<div class="col-md-6">
<div class="authincation-content">
<div class="row no-gutters">
<div class="col-xl-12">
<div class="auth-form">
<img style="display: block; margin-left: auto; margin-right: auto; width: 50%; padding-bottom: 2px" src="https://ik.imagekit.io/litepaych/assets/new/img/logo_litepay_2020_blue.png" alt="Litepay.ch Merchant"></a>
<h2 class="text-center mb-4">Sign in</h2>
<form action="" method="POST">
{% csrf_token %}
<div class="form-group">
<label class="mb-1"><strong>Email</strong></label>
<input type="email" class="form-control" name="email" value="Email">
</div>
<div class="form-group">
<label class="mb-1"><strong>Password</strong></label>
<input type="password" class="form-control" name="password" value="Password">
</div>
<div class="form-row d-flex justify-content-between mt-4 mb-2">
<div class="form-group">
</div>
<div class="form-group">
<a href="/merchant/forgot-password">Forgot Password?</a>
</div>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary btn-block">Sign Me In</button>
</div>
</form>
<div class="new-account mt-3">
<p>Don't have an account? <a class="text-primary" href="/merchant/register">Sign up</a></p>
</div>
</div>
{% if messages %}
<ul class="messages text-center">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<!-- end main content-->
{% endblock content %}
</html>

View File

@ -0,0 +1,111 @@
{% extends "partials/base.html" %}
{% load static %}
{% block title %}Dashboard{% endblock title %}
{% block content %}
<!-- ============================================================== -->
<!-- Start right Content here -->
<!-- ============================================================== -->
<!-- Main content -->
<div class="h-screen flex-grow-1 overflow-y-lg-auto">
<!-- Header -->
<header class="bg-surface-primary border-bottom pt-6">
<div class="container-fluid">
<div class="mb-npx">
<div class="row align-items-center">
<div class="col-sm-6 col-12 mb-4 mb-sm-0">
<!-- Title -->
<h1 class="h2 mb-0 ls-tight"> Vendor Page </h1>
<hr class="navbar-divider my-1 opacity-20">
</div>
<!-- Actions -->
<hr class="navbar-divider my-1 opacity-20">
</div>
<!-- Nav -->
</div>
</div>
</header>
<!-- Main -->
<main class="py-6 bg-surface-secondary">
<div class="container-fluid">
<!-- Card stats -->
<div class="card shadow border-0 mb-7">
<div class="card-header">
<h5 class="mb-0">Vendor Accounts</h5>
</div>
<div class="table-responsive">
<table class="table table-hover table-nowrap">
<thead class="thead-light">
<tr>
<th scope="col">VendorID</th>
<th scope="col">Creation Date</th>
<th scope="col">Website Name</th>
<th scope="col"></th>
<th scope="col">Status</th>
<th></th>
</tr>
</thead>
{% for vendor in vendors %}
<tr>
<td>
<img alt="..." src="https://preview.webpixels.io/web/img/other/logos/logo-1.png" class="avatar avatar-xs rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
{{vendor.vendor}}
</a>
</td>
<td>
{{vendor.vendorAddDate}}
</td>
<td>
<img alt="..." src="https://preview.webpixels.io/web/img/other/logos/logo-1.png" class="avatar avatar-xs rounded-circle me-2">
<a class="text-heading font-semibold" href="#">
{{vendor.vendorWebName}}
</a>
</td>
<td>
</td>
<td>
{% if vendor.vendorIsActive == 0 %}
<span class="badge badge-lg badge-dot">
<i class="bg-warning"></i> Inactive
</span>
{% else %}
<span class="badge badge-lg badge-dot">
<i class="bg-success"></i> Active
</span>
{% endif %}
</td>
<td class="text-end">
<a href="{{vendor.vendorUUID}}" class="btn btn-sm btn-neutral">Edit</a>
<a href="addresses/{{vendor.vendorUUID}}" class="btn btn-sm btn-neutral">Addresses</a>
</td>
</tr>
{% endfor %}
</table>
</div>
<div class="card-footer border-0 py-5">
<span class="text-muted text-sm">#</span>
</div>
</div>
</div>
</main>
</div>
</div>
<!-- Dashboard -->
<!-- End Page-content -->
<div>
{% block footer %}
{% include "partials/footer.html" %}
{% endblock footer %}
</div>
<!-- end main content-->
{% endblock content %}

3
base/tests.py Normal file
View File

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

11
base/urls.py Normal file
View File

@ -0,0 +1,11 @@
from . import views
from django.urls import path
urlpatterns = [
path('login/', views.LoginPage, name="login"),
path('logout/', views.LogoutPage, name="logout"),
path('', views.index, name="dashboard"),
path('vendor/', views.VendorPage, name="vendor"),
]

46
base/views.py Normal file
View File

@ -0,0 +1,46 @@
from django.shortcuts import render, redirect
from django.contrib import messages
from users.models import User
from .models import VendorsData
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
# Create your views here.
@login_required(login_url='login')
def index(request):
context = {}
return render(request, 'base/dashboard.html', context)
def LoginPage(request):
if request.method == 'POST':
email = request.POST.get('email')
password = request.POST.get('password')
user = None
error = None
try:
user = User.objects.get(email=email)
except:
error = messages.error(request, 'Email not registered')
if user is not None and error is None:
user = authenticate(request, email=email, password=password)
if user is not None:
login(request, user)
return redirect('dashboard')
else:
messages.error(request, 'Wrong password')
context = {}
return render(request, 'base/login.html', context)
def LogoutPage(request):
logout(request)
return redirect('login')
@login_required(login_url='login')
def VendorPage(request):
vendors = VendorsData.objects.filter(vendorid_id=request.user.id)
context = {'vendors': vendors}
return render(request, 'base/vendor.html', context)

BIN
dLitepay/.DS_Store vendored Normal file

Binary file not shown.

0
dLitepay/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

16
dLitepay/asgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
ASGI config for dLitepay 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', 'dLitepay.settings')
application = get_asgi_application()

165
dLitepay/settings.py Normal file
View File

@ -0,0 +1,165 @@
"""
Django settings for dLitepay 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
from django.contrib.messages import constants as messages
# 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-z#_ppfgs06)e4v18t!970-&-&jkxht!tw&ms#u5n_m-fbxulwa'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# User substitution
# https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#auth-custom-user
AUTH_USER_MODEL = 'users.User'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_bcrypt',
#
'base.apps.BaseConfig',
'users.apps.UsersConfig',
]
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 = 'dLitepay.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
BASE_DIR / '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 = 'dLitepay.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'xegh3kAJyDLaRu',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
# 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',
},
]
PASSWORD_HASHERS = [
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
]
# 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/'
STATICFILES_DIRS = [
BASE_DIR / "src"
]
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Messages customize
MESSAGE_TAGS = {
messages.DEBUG: "alert-info",
messages.INFO: "alert-info",
messages.SUCCESS: "alert-success",
messages.WARNING: "alert-warning",
messages.ERROR: "alert-danger",
}
BCRYPT_ROUNDS = 11
PASSWORD_RESET_TIMEOUT = 3600 #
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_SECURE = False #to be switched to true when in prod
CSRF_COOKIE_SECURE = False #to be switched to true when in prod
SECURE_SSL_REDIRECT = False #to be switched to true when in prod
SESSION_COOKIE_AGE = 3600
SERVER_EMAIL = 'info@litepay.ch'

24
dLitepay/urls.py Normal file
View File

@ -0,0 +1,24 @@
"""
URL configuration for dLitepay project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.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.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('base.urls'))
]

16
dLitepay/wsgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
WSGI config for dLitepay 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', 'dLitepay.settings')
application = get_wsgi_application()

0
db.sqlite3 Normal file
View File

22
manage.py Executable file
View File

@ -0,0 +1,22 @@
#!/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', 'dLitepay.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()

BIN
src/.DS_Store vendored Normal file

Binary file not shown.

BIN
templates/.DS_Store vendored Normal file

Binary file not shown.

26
templates/main.html Normal file
View File

@ -0,0 +1,26 @@
{% extends "partials/base.html" %}
{% load static %}
{% block title %}Starter Page{% endblock title %}
{% block content %}
<!-- ============================================================== -->
<!-- Start right Content here -->
<!-- ============================================================== -->
<div class="main-content">
<div class="page-content">
<div class="container-fluid">
{% block pagetitle %}
{% include "partials/page-title.html" with pagetitle="Pages" title="Starter" %}
{% endblock pagetitle %}
</div>
<!-- container-fluid -->
</div>
<!-- End Page-content -->
{% block footer %}
{% include "partials/footer.html" %}
{% endblock footer %}
</div>
<!-- end main content-->
{% endblock content %}

41
templates/partials/base.html Executable file
View File

@ -0,0 +1,41 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>{% block title %}{% endblock title %} | </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="Premium Multipurpose Admin & Dashboard Template" name="description" />
<meta content="Themesbrand" name="author" />
<!-- App favicon -->
<link rel="shortcut icon" href="{% static 'images/favicon.ico'%}">
{% block css %}
<!-- Bootstrap Css -->
<link href="https://unpkg.com/@webpixels/css@1.1.5/dist/index.css" id="bootstrap-style" rel="stylesheet" type="text/css" />
<!-- Icons Css -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.4.0/font/bootstrap-icons.min.css" rel="stylesheet" type="text/css" />
{% endblock css %}
</head>
<body>
<!-- Begin page -->
<div id="layout-wrapper">
{% block header %}
{% include "partials/topbar.html" %}
{% endblock header %}
{% block sidebar %}
{% include "partials/sidebar.html" %}
{% endblock sidebar %}
{% block content %}
{% block pagetitle %}
{% endblock pagetitle %}
{% block footer %}
{% endblock footer %}
{% endblock content %}
</div>
{% block extra_content %}
{% endblock extra_content %}
</body>
</html>

14
templates/partials/footer.html Executable file
View File

@ -0,0 +1,14 @@
{% block footer %}
<footer class="footer">
<div class="container-fluid">
<div class="row">
<div class="col-sm-6">
<script>document.write(new Date().getFullYear())</script> © Litepay.ch.
</div>
</div>
</div>
</footer>
{% endblock footer %}

View File

@ -0,0 +1,18 @@
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
<h4 class="mb-sm-0">{{title}}</h4>
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">{{pagetitle}}</a></li>
<li class="breadcrumb-item active">{{title}}</li>
</ol>
</div>
</div>
</div>
</div>
<!-- end page title -->

90
templates/partials/sidebar.html Executable file
View File

@ -0,0 +1,90 @@
{% load static %}
{% block sidebar %}
<div class="d-flex flex-column flex-lg-row h-lg-full bg-surface-secondary">
<!-- Vertical Navbar -->
<nav class="navbar show navbar-vertical h-lg-screen navbar-expand-lg px-0 py-3 navbar-light bg-white border-bottom border-bottom-lg-0 border-end-lg" id="navbarVertical">
<div class="container-fluid">
<!-- Toggler -->
<button class="navbar-toggler ms-n2" type="button" data-bs-toggle="collapse" data-bs-target="#sidebarCollapse" aria-controls="sidebarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Brand -->
<a class="navbar-brand py-lg-2 mb-lg-5 px-lg-6 me-0" href="#">
<img src="https://preview.webpixels.io/web/img/logos/clever-primary.svg" alt="...">
</a>
<!-- User menu (mobile) -->
<div class="navbar-user d-lg-none">
<!-- Dropdown -->
<div class="dropdown">
<!-- Toggle -->
<a href="#" id="sidebarAvatar" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div class="avatar-parent-child">
<img alt="Image Placeholder" src="https://images.unsplash.com/photo-1548142813-c348350df52b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=3&w=256&h=256&q=80" class="avatar avatar- rounded-circle">
<span class="avatar-child avatar-badge bg-success"></span>
</div>
</a>
<!-- Menu -->
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="sidebarAvatar">
<a href="#" class="dropdown-item">Profile</a>
<a href="#" class="dropdown-item">Settings</a>
<a href="#" class="dropdown-item">Billing</a>
<hr class="dropdown-divider">
<a href="#" class="dropdown-item">Logout</a>
</div>
</div>
</div>
<!-- Collapse -->
<div class="collapse navbar-collapse" id="sidebarCollapse">
<!-- Navigation -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">
<i class="bi bi-house"></i> Dashboard
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i class="bi bi-bar-chart"></i> Analitycs
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i class="bi bi-chat"></i> Messages
<span class="badge bg-soft-primary text-primary rounded-pill d-inline-flex align-items-center ms-auto">6</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<i class="bi bi-bookmarks"></i> Collections
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'vendor' %}">
<i class="bi bi-people"></i> Vendor
</a>
</li>
</ul>
<!-- Divider -->
<hr class="navbar-divider my-5 opacity-20">
<!-- Navigation -->
<!-- Push content down
<div class="mt-auto"></div> -->
<!-- User (md) -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="{% url 'login' %}">
<i class="bi bi-person-square"></i> Account
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'logout' %}">
<i class="bi bi-box-arrow-left"></i> Logout
</a>
</li>
</ul>
</div>
</div>
</nav>
{% endblock sidebar %}

7
templates/partials/topbar.html Executable file
View File

@ -0,0 +1,7 @@
{% load static %}
{% block header %}
<!-- Banner -->
<a href="#" class="btn w-full btn-primary text-truncate rounded-0 py-2 border-0 position-relative" style="z-index: 1000;">
<strong>Strong</strong> message here→
</a>
{% endblock header %}

0
users/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

7
users/admin.py Normal file
View File

@ -0,0 +1,7 @@
from django.contrib import admin
from users.models import User
#
@admin.register(User)
class UserAdmin(admin.ModelAdmin):
pass

6
users/apps.py Normal file
View File

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

View File

@ -0,0 +1,43 @@
# Generated by Django 4.2 on 2023-04-20 11:40
from django.db import migrations, models
import django.utils.timezone
import users.models
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]
operations = [
migrations.CreateModel(
name='User',
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')),
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('email', models.EmailField(max_length=254, unique=True, verbose_name='email address')),
('percentage', models.DecimalField(decimal_places=3, default=0.01, max_digits=4)),
('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',
'abstract': False,
},
managers=[
('objects', users.models.UserManager()),
],
),
]

View File

Binary file not shown.

46
users/models.py Normal file
View File

@ -0,0 +1,46 @@
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.base_user import BaseUserManager
# Create your models here.
class UserManager(BaseUserManager):
use_in_migrations = True
def _create_user(self, email, password, **extra_fields):
if not email:
raise ValueError('Users require an email field')
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_user(self, email, password=None, **extra_fields):
extra_fields.setdefault('is_staff', False)
extra_fields.setdefault('is_superuser', False)
return self._create_user(email, password, **extra_fields)
def create_superuser(self, email, password, **extra_fields):
extra_fields.setdefault('is_staff', True)
extra_fields.setdefault('is_superuser', True)
if extra_fields.get('is_staff') is not True:
raise ValueError('Superuser must have is_staff=True.')
if extra_fields.get('is_superuser') is not True:
raise ValueError('Superuser must have is_superuser=True.')
return self._create_user(email, password, **extra_fields)
class User(AbstractUser):
username = None
email = models.EmailField(_('email address'), unique=True)
percentage = models.DecimalField(decimal_places=3, default=0.010, max_digits=4)
objects = UserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []

3
users/tests.py Normal file
View File

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

3
users/views.py Normal file
View File

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