integrace api, stripe, vytvoření commecre app

This commit is contained in:
2025-10-05 23:41:14 +02:00
parent f5cf8bbaa7
commit 10796dcb31
26 changed files with 436 additions and 140 deletions

View File

@@ -16,15 +16,6 @@ import logging
logger = logging.getLogger(__name__)
# Custom User Manager to handle soft deletion
class CustomUserActiveManager(UserManager):
def get_queryset(self):
return super().get_queryset().filter(is_deleted=False)
# Custom User Manager to handle all users, including soft deleted
class CustomUserAllManager(UserManager):
def get_queryset(self):
return super().get_queryset()
class CustomUser(SoftDeleteModel, AbstractUser):
@@ -67,33 +58,6 @@ class CustomUser(SoftDeleteModel, AbstractUser):
email = models.EmailField(unique=True, db_index=True)
create_time = models.DateTimeField(auto_now_add=True)
"""company_id = models.CharField(
max_length=8,
blank=True,
null=True,
validators=[
RegexValidator(
regex=r'^\d{8}$',
message="Company ID must contain exactly 8 digits.",
code='invalid_company_id'
)
]
)"""
"""personal_id = models.CharField(
max_length=11,
blank=True,
null=True,
validators=[
RegexValidator(
regex=r'^\d{6}/\d{3,4}$',
message="Personal ID must be in the format 123456/7890.",
code='invalid_personal_id'
)
]
)"""
city = models.CharField(null=True, blank=True, max_length=100)
street = models.CharField(null=True, blank=True, max_length=200)
@@ -113,9 +77,6 @@ class CustomUser(SoftDeleteModel, AbstractUser):
is_active = models.BooleanField(default=False)
objects = CustomUserActiveManager()
all_objects = CustomUserAllManager()
REQUIRED_FIELDS = ['email', "username", "password"]
@@ -125,14 +86,10 @@ class CustomUser(SoftDeleteModel, AbstractUser):
def delete(self, *args, **kwargs):
self.is_active = False
#self.orders.all().update(is_deleted=True, deleted_at=timezone.now())
return super().delete(*args, **kwargs)
def save(self, *args, **kwargs):
is_new = self.pk is None # check BEFORE saving
if is_new:
if self.pk is None: # if newely created user
if self.is_superuser or self.role == "admin":
self.is_active = True

View File

@@ -1,41 +1,25 @@
from urllib import request
from rest_framework.permissions import BasePermission, SAFE_METHODS
from rest_framework.permissions import IsAuthenticated
from rest_framework_api_key.permissions import HasAPIKey
#Podle svého uvážení (NEPOUŽÍVAT!!!)
class RolePermission(BasePermission):
allowed_roles = []
def has_permission(self, request, view):
# Je uživatel přihlášený a má roli z povolených?
user_has_role = (
request.user and
request.user.is_authenticated and
getattr(request.user, "role", None) in self.allowed_roles
)
# Má API klíč?
has_api_key = HasAPIKey().has_permission(request, view)
return user_has_role or has_api_key
#TOHLE POUŽÍT!!!
#Prostě stačí vložit: RoleAllowed('seller','cityClerk')
def RoleAllowed(*roles):
"""
Allows safe methods for any authenticated user.
Allows unsafe methods only for users with specific roles.
Allows access if a valid API key is provided.
Args:
RolerAllowed('admin', 'user')
RoleAllowed('admin', 'user')
"""
class SafeOrRolePermission(BasePermission):
def has_permission(self, request, view):
# Má API klíč?
has_api_key = HasAPIKey().has_permission(request, view)
# Allow safe methods for any authenticated user
if request.method in SAFE_METHODS:
return IsAuthenticated().has_permission(request, view)

View File

@@ -0,0 +1,137 @@
<table style="background-color:#031D44; font-family:'Exo', Arial, sans-serif; width:100%;" align="center" border="0"
cellspacing="0" cellpadding="0">
<tr>
<td align="center" style="padding:20px;">
<table border="0" cellspacing="45" cellpadding="0" style="max-width:100%;" align="center">
<tr>
<td align="center"
style="padding:20px; color:#ffffff; font-size:30px; font-weight:bold; border-radius:8px; text-decoration:underline">
Nabídka tvorby webových stránek
</td>
</tr>
<tr>
<td style="color:#CAF0F8; border-radius:8px; font-size:25px; line-height:1.6;">
<p style="margin:0;">
Jsme <strong>malý tým</strong>, který se snaží prorazit a přinášet moderní řešení za férové
ceny.
Nabízíme také <strong>levný hosting</strong> a <strong>SSL zabezpečení zdarma</strong>.
</p>
<p style="margin:10px 0 0;">
Dbáme na <strong>bezpečnost</strong>, používáme <strong>moderní frameworky</strong>
a rozhodně nejsme součástí „gerontosaurů“ <strong>PHP nepoužíváme</strong>.
</p>
</td>
</tr>
<!-- Nadpis -->
<tr>
<td align="center"
style="padding-top:50px; color:#ffffff; font-size:35px; font-weight:bold; border-radius:8px; text-decoration:underline">
Balíčky
</td>
</tr>
<!-- BASIC -->
<tr>
<td
style="padding:35px; background:#3a8bb7; color:#CAF0F8; border-radius:20px; margin:20px 0; line-height:1.6;font-size: 18px; width: 450px;">
<h2 style="margin:0; color:#CAF0F8;">BASIC</h2>
<ul style="padding-left:20px; margin:10px 0;">
<li>Jednoduchá prezentační webová stránka</li>
<li>Moderní a responzivní design (PC, tablety, mobily)</li>
<li>Maximalní počet stránek: 5</li>
<li>Použítí vlastní domény a <span style="text-decoration: underline;">SSL certifikát zdarma</span></li>
</ul>
<p
style="font-size: 18px; border-radius:8px; width: fit-content;background-color:#24719f; padding:16px; color:#ffffff; font-weight:bold; margin:0;">
Cena: 5 000 Kč
(jednorázově) + 100 Kč / měsíc</p>
</td>
</tr>
<!-- STANDARD -->
<tr>
<td
style="padding:35px; background:#70A288; color:#ffffff; border-radius:20px; line-height:1.6; font-size:18px; width:450px;">
<h2 style="margin:0; color:#ffffff;">STANDARD</h2>
<ul style="padding-left:20px; margin:10px 0;">
<li>Vše z balíčku BASIC</li>
<li>Kontaktní formulář, který posílá pobídky na váš email</li>
<li>Větší priorita při řešení problémů a rychlejší vývoj (cca 2 týdny)</li>
<li>Základní SEO</li>
<li>Maximální počet stránek: 10</li>
</ul>
<p
style="font-size:18px; border-radius:8px; width: fit-content; background-color:#508845; padding:16px; color:#ffffff; font-weight:bold; margin:0;">
Cena: 7 500 Kč (jednorázově) + 250 Kč / měsíc</p>
</td>
</tr>
<!-- PREMIUM -->
<tr>
<td
style="padding:35px; background:#87a9da; color:#031D44; border-radius:20px; line-height:1.6; font-size:18px; width:450px;">
<h2 style="margin:0; color:#031D44;">PREMIUM</h2>
<ul style="padding-left:20px; margin:10px 0;">
<li>Vše z balíčku STANDARD</li>
<li>Registrace firmy do Google Business Profile</li>
<li>Pokročilé SEO (klíčová slova, podpora pro slepce, čtečky)</li>
<li>Měsíční report návštěvnosti webu</li>
<li>Možnost drobných úprav (texty, fotky)</li>
<li>Neomezený počet stránek</li>
</ul>
<p
style="font-size:18px; border-radius:8px; width: fit-content; background-color:#4c7bbd; padding:16px; color:#ffffff; font-weight:bold; margin:0;">
Cena: od 9 500 Kč (jednorázově) + 400 Kč / měsíc</p>
</td>
</tr>
<!-- CUSTOM -->
<tr>
<td
style="padding:35px; background:#04395E; color:#CAF0F8; border-radius:20px; line-height:1.6; font-size:18px; width:450px;">
<h2 style="margin:0; color:#CAF0F8;">CUSTOM</h2>
<ul style="padding-left:20px; margin:10px 0;">
<li>Kompletně na míru podle potřeb</li>
<li>Možnost e-shopu, rezervačního systému, managment</li>
<li>Integrace jakéhokoliv API</li>
<li>Integrace platební brány (např. Stripe, Platba QR kódem, atd.)</li>
<li>Pokročilé SEO</li>
<li>Marketing skrz Google Ads</li>
</ul>
<p
style="font-size:18px; border-radius:8px; width: fit-content; background-color:#216085; padding:16px; color:#ffffff; font-weight:bold; margin:0;">
Cena: dohodou</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table style="width: 100%;background-color:#031D44; font-family:'Exo', Arial, sans-serif;" align="center" border="0"
cellspacing="50" cellpadding="0" style="color: #031D44;">
<!-- Footer -->
<tr>
<td align="center"
style=" border-radius: 50px; background-color: hwb(201 23% 28% / 0); padding:30px; color:#CAF0F8;">
<p style="margin:0; font-size:25px; font-weight:bold;">Máte zájem o některý z balíčků?</p>
</td>
</tr>
<tr>
<td align="center" style=" border-radius: 50px; padding:30px; color:#CAF0F8;">
<p>Stačí odpovědět na tento e-mail nebo mě kontaktovat telefonicky:</p>
<p>
<a style="color:#CAF0F8; text-decoration:underline;" href="mailto:brunovontor@gmail.com">
brunovontor@gmail.com
</a>
</p>
<p>
<a style="color:#CAF0F8; text-decoration:underline;" href="tel:+420605512624">+420 605 512 624</a>
</p>
<p>
<a style="color:#CAF0F8; text-decoration:underline;" href="https://vontor.cz">vontor.cz</a>
</p>
</td>
</tr>
</table>