-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #777 from Studio-Yandex-Practicum/develop
Release
- Loading branch information
Showing
21 changed files
with
217 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Generated by Django 3.2.25 on 2024-05-11 23:05 | ||
|
||
from django.contrib.postgres.operations import UnaccentExtension | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0038_add_yandex_disk_setting'), | ||
] | ||
|
||
operations = [ | ||
UnaccentExtension(), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""Управление записями переадресации электронной почты.""" | ||
|
||
from typing import Callable, Optional | ||
|
||
from apps.library.models.author import Author | ||
from apps.postfix.models import Virtual | ||
|
||
MAIL_CREATED = "Создан или обновлен виртуальный адрес '{virtual_email}'" | ||
MAIL_DELETED = "Виртуальный адрес '{virtual_email}' был удален" | ||
|
||
|
||
def create_forwarding(author: Author) -> Virtual: | ||
virtual_email: Optional[Virtual] = getattr(author, "virtual_email", None) | ||
if not virtual_email: | ||
virtual_email = Virtual(author=author, mailbox=author.slug) | ||
virtual_email.save() | ||
else: | ||
virtual_email.mailbox = author.slug | ||
virtual_email.recipients.all().delete() | ||
virtual_email.recipients.create(email=author.person.email) | ||
author.virtual_email = virtual_email | ||
return virtual_email | ||
|
||
|
||
def delete_forwarding(author: Author) -> Optional[Virtual]: | ||
virtual_email: Optional[Virtual] = getattr(author, "virtual_email", None) | ||
if virtual_email: | ||
virtual_email.delete() | ||
author.virtual_email = None | ||
return virtual_email | ||
|
||
|
||
def on_change(instance: Author, create: bool, message: Callable[[str], None]) -> Optional[Virtual]: | ||
if create: | ||
virtual_email = create_forwarding(instance) | ||
message(MAIL_CREATED.format(virtual_email=virtual_email)) | ||
else: | ||
virtual_email = delete_forwarding(instance) | ||
if virtual_email: | ||
message(MAIL_DELETED.format(virtual_email=virtual_email)) | ||
return virtual_email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 3.2.25 on 2024-04-26 21:51 | ||
|
||
from django.db import migrations, models | ||
import phonenumber_field.modelfields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('feedback', '0007_participationapplicationfestival_nickname'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='participationapplicationfestival', | ||
name='city', | ||
field=models.CharField(blank=True, max_length=50, null=True, verbose_name='Город проживания'), | ||
), | ||
migrations.AlterField( | ||
model_name='participationapplicationfestival', | ||
name='phone_number', | ||
field=phonenumber_field.modelfields.PhoneNumberField(blank=True, help_text='Номер телефона указывается в формате +7', max_length=128, null=True, region=None, verbose_name='Номер телефона'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.