Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/225-create…
Browse files Browse the repository at this point in the history
…-2FA-for-admin-panel
  • Loading branch information
MikeWazowskyi committed Sep 5, 2023
2 parents afa7d69 + 88b2993 commit 8040343
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 125 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/deploy-bot-on-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ jobs:
name: stage_deploy
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
# - uses: actions/checkout@v2
# - name: Prepare infra/dev
# run: |
# mkdir ../build
# cp -TR ./infra/dev ../build
# tar -cvf deploy.tar ../build/
- uses: actions/checkout@v2
- name: Prepare infra/dev
run: |
mkdir ../build
cp -TR ./infra/dev ../build
tar -cvf deploy.tar ../build/
- name: copy infra/dev
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USER }}
password: ${{ secrets.VM_PASSWORD }}
source: "infra/dev/*"
source: "deploy.tar"
target: /home/deploy/spread_wings_bot/infra/dev/
- name: ssh pull and start
uses: appleboy/ssh-action@master
Expand All @@ -35,6 +35,8 @@ jobs:
password: ${{ secrets.VM_PASSWORD }}
script: |
cd /home/deploy/spread_wings_bot/infra/dev/
tar -xvf deploy.tar --strip-components 1
rm deploy.tar
rm .env
touch .env
Expand Down Expand Up @@ -75,17 +77,11 @@ jobs:
docker system prune --force
# Installing defend service for app
# Шаг с копированием в строках 16-23 можно заменить командой ниже - нужно тестировать
# scp infra/dev/spread_wings_bot.service ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/spread_wings_bot/infra/dev/
sudo cp -f /home/deploy/spread_wings_bot/infra/dev/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service
sudo systemctl daemon-reload
sudo systemctl restart spread_wings_bot.service
# Installing the app
docker-compose -f docker-compose.stage.yaml stop
docker-compose -f docker-compose.stage.yaml pull
docker-compose -f docker-compose.stage.yaml up -d
# Applying initialization commands
sleep 7
docker exec spread-wings-bot python manage.py migrate
docker exec spread-wings-bot python manage.py collectstatic --noinput
8 changes: 4 additions & 4 deletions infra/dev/docker-compose.stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
volumes:
- ./redis.conf:/usr/local/etc/redis.conf
- data_value:/data
- ./logs/redis/:/var/log/
- ../../logs/redis/:/var/log/
networks:
- spread-wings-network

Expand All @@ -33,7 +33,7 @@ services:
- "5432:5432"
volumes:
- db_data:/var/lib/postgresql/data
- ./logs/db/:/var/log/postgres
- ../../logs/db/:/var/log/postgres
restart: always
networks:
- spread-wings-network
Expand All @@ -47,7 +47,7 @@ services:
volumes:
- ../../static:/app/src/staticfiles
- ../../media:/app/src/media
- ./logs/bot/:/app/src/logs
- ../../logs/bot/:/app/src/logs
restart: always
env_file:
- ./.env
Expand All @@ -63,7 +63,7 @@ services:
- ./nginx.stage.conf.template:/etc/nginx/templates/default.conf.template
- ../../static:/var/html/static/
- ../../media:/var/html/media/
- ./logs/nginx/:/var/log/nginx/
- ../../logs/nginx/:/var/log/nginx/
env_file:
- ./.env
depends_on:
Expand Down
2 changes: 0 additions & 2 deletions src/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@
]

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
admin.site.site_header = "Бот фонда 'Расправь крылья!'"
admin.site.site_title = "Бот фонда 'Расправь крылья!'"
4 changes: 4 additions & 0 deletions src/users/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ class CustomOTPAdminSite(OTPAdminSite):
"""Customized admin site."""

login_form = CustomOTPAuthenticationForm

site_header = "Бот фонда 'Расправь крылья!'"
site_title = "Бот фонда 'Расправь крылья!'"

login_template = "authentication/login.html"
165 changes: 88 additions & 77 deletions src/users/templates/authentication/password_set_confirm.html
Original file line number Diff line number Diff line change
@@ -1,86 +1,97 @@
{% extends "base.html" %}
{% load user_filters %}
{% block title %}Новый пароль{% endblock %}
{% extends "admin/base_site.html" %}
{% load i18n static %}

{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css"
href="{% static 'admin/css/login.css' %}"/>
{{ form.media }}

<style type="text/css">
input#id_otp_token,
select#id_otp_device
{
clear: both;
padding: 6px;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
</style>
{% endblock %}

{% block bodyclass %}{{ block.super }} login{% endblock %}

{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">Новый пароль</a></h1>
{% if user.is_anonymous %}
{% include "admin/color_theme_toggle.html" %}
{% endif %}
{% endblock %}

{% block usertools %}{% endblock %}

{% block nav-global %}{% endblock %}

{% block content_title %}{% endblock %}

{% block breadcrumbs %}{% endblock %}

{% block nav-sidebar %}{% endblock %}

{% block content %}

{% if validlink %}
<div id="container">
<div id="header">
<div id="branding">
<h1 id="site-name">
Введите новый пароль
</h1>
<button class="theme-toggle">
<div class="visually-hidden theme-label-when-auto">Toggle
theme (current theme: auto)
</div>
<div class="visually-hidden theme-label-when-light"
wfd-invisible="true">Toggle theme (current theme:
light)
</div>
<div class="visually-hidden theme-label-when-dark"
wfd-invisible="true">Toggle theme (current theme:
dark)
</div>
<svg aria-hidden="true" class="theme-icon-when-auto"
xmlns="http://www.w3.org/2000/svg" height="48"
viewBox="0 -960 960 960" width="48">
<path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm20-60q137-10 228.5-106T820-480q0-138-91.5-234T500-820v680Z"/>
</svg>
<svg aria-hidden="true" class="theme-icon-when-dark"
wfd-invisible="true"
xmlns="http://www.w3.org/2000/svg" height="48"
viewBox="0 -960 960 960" width="48">
<path d="M480-120q-150 0-255-105T120-480q0-150 105-255t255-105q8 0 17 .5t23 1.5q-36 32-56 79t-20 99q0 90 63 153t153 63q52 0 99-18.5t79-51.5q1 12 1.5 19.5t.5 14.5q0 150-105 255T480-120Zm0-60q109 0 190-67.5T771-406q-25 11-53.667 16.5Q688.667-384 660-384q-114.689 0-195.345-80.655Q384-545.311 384-660q0-24 5-51.5t18-62.5q-98 27-162.5 109.5T180-480q0 125 87.5 212.5T480-180Zm-4-297Z"/>
</svg>
<svg aria-hidden="true" class="theme-icon-when-light"
wfd-invisible="true"
xmlns="http://www.w3.org/2000/svg" height="48"
viewBox="0 -960 960 960" width="48">
<path d="M450-810v-110h60v110h-60Zm0 770v-110h60v110h-60Zm360-410v-60h110v60H810Zm-770 0v-60h110v60H40Zm702-250-43-43 66-66 43 43-66 66ZM195-151l-43-43 66-66 43 43-66 66Zm570 0-66-66 43-43 66 66-43 43ZM218-700l-66-66 43-43 66 66-43 43Zm261.824 445Q386-255 320.5-320.676q-65.5-65.677-65.5-159.5Q255-574 320.676-639.5q65.677-65.5 159.5-65.5Q574-705 639.5-639.323 705-573.647 705-479.824 705-386 639.323-320.5 573.647-255 479.824-255Zm.11-60Q549-315 597-362.934t48-117Q645-549 597.066-597t-117-48Q411-645 363-597.066t-48 117Q315-411 362.934-363t117 48ZM480-480Z"/>
</svg>
</button>
</div>
</div>
<div class="main" id="main">
<div id="content-start" class="content" tabindex="-1">
<div id="content" class="colM">
<div id="content-main">
{% include "includes/form_errors.html"%}
<form method="post" id="login-form"
{% if action_url %}
action="{% url action_url %}"
{% endif %}
>
{% include "includes/form.html"%}
</form>
</div>
<br class="clear">
<div class="main" id="main">
<div id="content-start" class="content" tabindex="-1">
<div id="content" class="colM">
<div id="content-main">
{% if user.is_authenticated %}
<p class="errornote">
{% blocktrans trimmed %}
You are authenticated as {{ username }}, but are not
authorized to
access this page. Would you like to login to a
different account?
{% endblocktrans %}
</p>
{% endif %}

{% include "includes/form_errors.html"%}
<form method="post" id="login-form"
{% if action_url %}
action="{% url action_url %}"
{% endif %}
>
{% include "includes/form.html"%}
</form>

<script type="text/javascript">
document.getElementById('id_username').focus()
</script>
</div>
</div>
</div>
</div>
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{
message }}
</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
<div class="row justify-content-center">
<div class="col-md-8 p-5">
<div class="card">
<div class="card-header">Ошибка</div>
<div class="card-body">
<p>Ссылка установки пароля содержит ошибку или
устарела.</p>
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li {% if message.tags %} class="{{ message.tags }}" {% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
<div class="row justify-content-center">
<div class="col-md-8 p-5">
<div class="card">
<div class="card-header">Ошибка</div>
<div class="card-body">
<p>Ссылка установки пароля содержит ошибку или
устарела.</p>
</div>
</div>
</div>
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}

{% endblock %}
21 changes: 0 additions & 21 deletions src/users/templates/base.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/users/templates/emailing/password_reset_email.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "email.html" %}
{% extends "emailing/email.html" %}
{% block subject %}Доступ к админ-панели бота фонда "Расправь Крылья!"{% endblock %}
{% block content %}
<div align="center">
Expand Down
12 changes: 6 additions & 6 deletions src/users/templates/includes/form_errors.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{% if form.errors %}
{% for field in form %}
{% for error in field.errors %}
<div class="alert alert-danger">
{{ error|escape }}
</div>
{% endfor %}
{% for error in field.errors %}
<div class="errornote">
{{ error|escape }}
</div>
{% endfor %}
{% endfor %}
{% for error in form.non_field_errors %}
<div class="alert alert-danger">
<div class="errornote">
{{ error|escape }}
</div>
{% endfor %}
Expand Down

0 comments on commit 8040343

Please sign in to comment.