Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions anfisa_for_friends/anfisa_for_friends/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
ALLOWED_HOSTS = []

INSTALLED_APPS = [
'users.apps.UsersConfig',
'statistic.apps.StatisticConfig',
'homepage.apps.HomepageConfig',
'ice_cream.apps.IceCreamConfig',
'about.apps.AboutConfig',
Expand Down Expand Up @@ -94,3 +96,9 @@
]

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

AUTH_USER_MODEL = 'users.CustomUser'

LOGIN_URL = 'users:login'
LOGOUT_URL = 'users:logout'
LOGIN_REDIRECT_URL = 'homepage:index'
2 changes: 2 additions & 0 deletions anfisa_for_friends/anfisa_for_friends/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
path('', include('homepage.urls', namespace='homepage')),
path('about/', include('about.urls', namespace='about')),
path('ice_cream/', include('ice_cream.urls', namespace='ice_cream')),
path('statistic/', include('statistic.urls', namespace='statistic')),
path('auth/', include('users.urls', namespace='users')),
path('admin/', admin.site.urls),
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
3 changes: 3 additions & 0 deletions anfisa_for_friends/statistic/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 anfisa_for_friends/statistic/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class StatisticConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'statistic'
Empty file.
3 changes: 3 additions & 0 deletions anfisa_for_friends/statistic/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.
3 changes: 3 additions & 0 deletions anfisa_for_friends/statistic/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.
10 changes: 10 additions & 0 deletions anfisa_for_friends/statistic/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.urls import path

from . import views

app_name = 'statistic'

urlpatterns = [
path('google/', views.google_search, name='google_search'),
path('yandex/', views.yandex_search, name='yandex_search'),
]
9 changes: 9 additions & 0 deletions anfisa_for_friends/statistic/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.http import HttpResponse


def google_search(request):
return HttpResponse('Это станица для поисковой системы Google')


def yandex_search(request):
return HttpResponse('Это станица для поисковой системы Yandex')
7 changes: 5 additions & 2 deletions anfisa_for_friends/templates/about/description.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{% extends "base.html" %}
{% block title %}
Анфиса для друзей. Описание проекта
Анфиса для друзей. О проекте
{% endblock %}
{% block content %}
<h1>Описание проекта</h1>
<h1 class="pb-2 mb-0">О проекте</h1>
<p>
Каталог экзотических сортов мороженого.
</p>
{% endblock %}
4 changes: 3 additions & 1 deletion anfisa_for_friends/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
</head>
<body>
{% include "includes/header.html" %}
<main>
<main class="pt-5 my-5">
<div class="container">
{% block content %}
{% endblock %}
</div>
</main>
{% include "includes/footer.html" %}
</body>
Expand Down
2 changes: 1 addition & 1 deletion anfisa_for_friends/templates/homepage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Анфиса для друзей. Главная
{% endblock %}
{% block content %}
<h1>Главная страница</h1>
<h1 class="pb-2 mb-0">Главная страница</h1>
{% endblock %}
21 changes: 16 additions & 5 deletions anfisa_for_friends/templates/ice_cream/detail.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
{% extends "base.html" %}
{% load static %}
{% block title %}
Анфиса для друзей. Подробное описание мороженого
Анфиса для друзей. {{ ice_cream.title }}
{% endblock %}
{% block content %}
<h1>Подробное описание мороженого</h1>
<h3>{{ ice_cream.title }}</h3>
<p>{{ ice_cream.description }}</p>
<h1 class="pb-2 mb-0">{{ ice_cream.title }}</h1>
<div class="row mt-3">
<div class="col-12 col-md-6">
<h2>Описание</h2>
<p>{{ ice_cream.description }}</p>
</div>
<div class="col-12 col-md-6 mb-3">
<img
class="img-fluid"
height="400" width="300"
src="{% static 'img/image-holder.png' %}"
>
</div>
</div>
{% endblock %}

42 changes: 28 additions & 14 deletions anfisa_for_friends/templates/ice_cream/list.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
{% extends "base.html" %}
{% load static %}
{% block title %}
Анфиса для друзей. Каталог мороженого
{% endblock %}
{% block content %}
<h1>Каталог мороженого</h1>
<ul>
{% for ice_cream in ice_cream_list %}
<li>
<h3>{{ ice_cream.title }}</h3>
<p>{{ ice_cream.description|truncatewords:10 }}</p>
<a href="{% url 'ice_cream:ice_cream_detail' ice_cream.id %}">подробнее</a>
</li>
{% if not forloop.last %}
<hr>
{% endif %}
{% endfor %}
</ul>
{% endblock %}
<h1 class="pb-2 mb-0">Каталог мороженого</h1>
<div class="row">
{% for ice_cream in ice_cream_list %}
<div class="col-6 col-md-4 my-1">
<div class="card">
<!-- Картинку берём из статики -->
<img
class="img-fluid card-img-top"
height="400" width="300"
src="{% static 'img/image-holder.png' %}"
>
<div class="card-body">
<h5 class="card-title">{{ ice_cream.title }}</h5>
<p class="card-text">
{{ ice_cream.description|truncatewords:10 }}
</p>
<a
class="mt-3 regular-link"
href="{% url 'ice_cream:ice_cream_detail' ice_cream.id %}">
Подробнее -->
</a>
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
6 changes: 3 additions & 3 deletions anfisa_for_friends/templates/includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<footer>
<p>Копирайт, год создания</p>
</footer>
<footer class="border-top text-center py-3">
<p>© 2022 «MyKit Corp»</p>
</footer>
74 changes: 60 additions & 14 deletions anfisa_for_friends/templates/includes/header.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,63 @@
{% load static %}
{% with request.resolver_match.view_name as view_name %}
<header>
<img src="{% static 'img/logo.png' %}" height="50" alt="">
<nav>
<ul>
<li>
<a href="{% url 'homepage:index' %}">Главная</a>
</li>
<li>
<a href="{% url 'ice_cream:ice_cream_list' %}">Каталог мороженого</a>
</li>
<li>
<a href="{% url 'about:description' %}">О проекте</a>
</li>
</ul>
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top shadow-sm">
<div class="container">
<div
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNav"
aria-controls="navbarNav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</div>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="nav nav-pills">
<li class="nav-item">
<!-- Добавлен класс active -->
<a
class="nav-link
{% if view_name == 'homepage:index' %}
active
{% endif %}"
href="{% url 'homepage:index' %}">
Главная
</a>
</li>
<li class="nav-item">
<a
class="nav-link
{% if view_name == 'ice_cream:ice_cream_list' %}
active
{% endif %}"
href="{% url 'ice_cream:ice_cream_list' %}">
Каталог мороженого
</a>
</li>
<li class="nav-item">
<a
class="nav-link
{% if view_name == 'about:description' %}
active
{% endif %}"
href="{% url 'about:description' %}">
О проекте
</a>
</li>
</ul>
</div>
<a class="navbar-brand" href="index.html">
<img
src="img/logo.png"
height="50"
class="d-inline-block align-top"
alt=""
>
</a>
</div>
</nav>
</header>
</header>
{% endwith %}
14 changes: 14 additions & 0 deletions anfisa_for_friends/templates/users/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "base.html" %}

{% block title %}
Login
{% endblock %}

{% block content %}
<h1>Login</h1>
<form method="post" action="{% url 'users:login' %}">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Login</button>
</form>
{% endblock %}
14 changes: 14 additions & 0 deletions anfisa_for_friends/templates/users/signup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "base.html" %}

{% block title %}
Sign Up
{% endblock %}

{% block content %}
<h1>Sign Up</h1>
<form method="post" action="{% url 'users:signup' %}">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Sign Up</button>
</form>
{% endblock %}
Empty file.
3 changes: 3 additions & 0 deletions anfisa_for_friends/users/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 anfisa_for_friends/users/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class UsersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'users'
8 changes: 8 additions & 0 deletions anfisa_for_friends/users/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib.auth.forms import UserCreationForm
from .models import CustomUser


class CustomUserCreationForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = CustomUser
fields = ('email',)
42 changes: 42 additions & 0 deletions anfisa_for_friends/users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 3.2.16 on 2025-09-04 06:17

import django.contrib.auth.models
from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

initial = True

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

operations = [
migrations.CreateModel(
name='CustomUser',
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')),
('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', django.contrib.auth.models.UserManager()),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.16 on 2025-09-04 06:34

from django.db import migrations


class Migration(migrations.Migration):

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

operations = [
migrations.AlterModelManagers(
name='customuser',
managers=[
],
),
]
Empty file.
Loading