index
int64
repo_name
string
branch_name
string
path
string
content
string
import_graph
string
6,537
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/models.py
from django.db import models from apps.account.models import User from apps.brand.models import Filial from core.constants import CHECK_TYPE class Check(models.Model): """ Model to save all checks from 1C """ unique_1c_check_code = models.CharField( max_length=255, unique=True, verbose_name='Уникальный 1C код чека' ) money_paid = models.DecimalField( null=True, blank=True, max_digits=8, decimal_places=2, verbose_name='Оплачено деньгами' ) bonus_paid = models.DecimalField( null=True, blank=True, max_digits=8, decimal_places=2, verbose_name='Оплачено бонусами' ) total_paid = models.DecimalField( null=True, blank=True, max_digits=8, decimal_places=2, verbose_name='Сумма оплаты' ) accrued_point = models.DecimalField( null=True, blank=True, max_digits=8, decimal_places=2, verbose_name='Начислено бонусов' ) accrued_point_date = models.DateTimeField( null=True, blank=True, verbose_name='Дата начисления' ) withdrawn_point = models.DecimalField( null=True, blank=True, max_digits=8, decimal_places=2, verbose_name='Снято бонусов (Возврат)' ) withdrawn_point_date = models.DateTimeField( null=True, blank=True, verbose_name='Дата возврата' ) is_active = models.BooleanField( default=True, verbose_name='Активность чека' ) user = models.ForeignKey( to=User, on_delete=models.CASCADE, related_name='checks', verbose_name='Пользователь' ) filial = models.ForeignKey( to=Filial, null=True, on_delete=models.SET_NULL, related_name='checks', verbose_name='Филиал' ) user_1c_code = models.CharField( max_length=255, null=True, verbose_name='Уникальный 1C код пользователя' ) filial_1c_code = models.CharField( max_length=255, null=True, verbose_name='Уникальный 1C код филиала' ) status = models.CharField( choices=CHECK_TYPE, max_length=25, verbose_name='Статус чека', ) due_date = models.DateTimeField( null=True, blank=True, verbose_name='Дата оплаты долга' ) is_on_credit = models.BooleanField(default=False, verbose_name='В долг') balance_owed = models.DecimalField( null=True, blank=True, max_digits=8, decimal_places=2, verbose_name='Остаток долга' ) def __str__(self): return f'Чек №{self.unique_1c_check_code}' class Meta: verbose_name = 'Чек' verbose_name_plural = 'Чеки'
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,538
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/custom_openapi.py
from drf_yasg import openapi lat_param = openapi.Parameter( 'lat', openapi.IN_QUERY, description="Query param lat", type=openapi.TYPE_NUMBER ) long_param = openapi.Parameter( 'long', openapi.IN_QUERY, description="Query param long", type=openapi.TYPE_NUMBER ) filial_extra_params = [lat_param, long_param]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,539
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/migrations/0005_auto_20210408_1140.py
# Generated by Django 2.2.16 on 2021-04-08 05:40 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('info', '0004_auto_20210406_1501'), ] operations = [ migrations.AlterField( model_name='promotionandnews', name='created_at', field=models.DateTimeField(verbose_name='Дата публикации'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,540
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/models.py
from django.db import models from django.forms import ValidationError from ckeditor_uploader.fields import RichTextUploadingField from django_2gis_maps import fields as map_fields from core.utils import generate_filename from core.constants import WORK_DAYS class Brand(models.Model): position = models.PositiveIntegerField( default=0, blank=False, null=False, verbose_name='№', ) title = models.CharField(max_length=255, verbose_name='Название') logo = models.ImageField(upload_to=generate_filename, verbose_name='Лого') description = RichTextUploadingField( null=True, blank=True, verbose_name='Описание' ) address = models.CharField( max_length=100, blank=True, null=True, verbose_name='Адрес' ) link = models.URLField(null=True, blank=True, verbose_name='Ссылка') def __str__(self): return self.title class Meta: ordering = ['position'] verbose_name = 'Бренд' verbose_name_plural = 'Бренды' class BrandImage(models.Model): brand = models.ForeignKey( to='Brand', on_delete=models.CASCADE, related_name='images', verbose_name='Бренд' ) image = models.ImageField( upload_to=generate_filename, verbose_name='Изображение', ) def __str__(self): return f'Image of {self.brand.title} brand' class Meta: verbose_name = 'Изображение бренда' verbose_name_plural = 'Изображения бренда' class Filial(models.Model): position = models.PositiveIntegerField( default=0, blank=False, null=False, verbose_name='№', ) title = models.CharField(max_length=255, verbose_name='Название') address = map_fields.AddressField(max_length=200, verbose_name='Адрес') geolocation = map_fields.GeoLocationField(verbose_name='Геолокация') filial_1c_code = models.CharField( max_length=255, unique=True, verbose_name='Уникальный 1C код филиала' ) def __str__(self): return self.title class Meta: ordering = ['position'] verbose_name = 'Филиал' verbose_name_plural = 'Филиалы' class FilialImage(models.Model): filial = models.ForeignKey( to='Filial', on_delete=models.CASCADE, related_name='images', verbose_name='Филиал' ) image = models.ImageField( upload_to=generate_filename, verbose_name='Изображение' ) is_main = models.BooleanField(default=False, verbose_name='Основная?') def __str__(self): return f'Image of {self.filial.title} filial' class Meta: verbose_name = 'Изображение филиала' verbose_name_plural = 'Изображения филиала' class FilialPhone(models.Model): filial = models.ForeignKey( to='Filial', on_delete=models.CASCADE, related_name='phone_numbers', verbose_name='Филиал' ) phone = models.CharField(max_length=255, verbose_name='Номер телефона') is_phone = models.BooleanField( default=True, verbose_name='Номер телефона?' ) is_whatsapp = models.BooleanField( default=True, verbose_name='Номер Whatsapp?' ) def __str__(self): return f'Phone of {self.filial.title} filial' class Meta: verbose_name = 'Номер филиала' verbose_name_plural = 'Номера филиала' class WorkTime(models.Model): day = models.SmallIntegerField( choices=WORK_DAYS, verbose_name='День недели' ) start_work = models.TimeField( verbose_name='Начало рабочего времени', null=True, blank=True ) end_work = models.TimeField( verbose_name='Конец рабочего времени', null=True, blank=True ) filial = models.ForeignKey( to=Filial, on_delete=models.CASCADE, related_name='works_time', verbose_name='Филиал' ) class Meta: ordering = ['day'] unique_together = ['day', 'filial'] verbose_name = 'Рабочий день' verbose_name_plural = 'Рабочие дни' def __str__(self): return f'{str(self.filial)}, {self.day}' def clean(self): text = ('Нельзя заполнить только время ' 'конца или начала, рабочего времени') if ( self.start_work is None and self.end_work is not None ): raise ValidationError(text) elif ( self.start_work is not None and self.end_work is None ): raise ValidationError(text)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,541
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/migrations/0005_auto_20210405_1740.py
# Generated by Django 2.2.16 on 2021-04-05 11:40 import ckeditor_uploader.fields import core.utils from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('brand', '0004_auto_20210401_1321'), ] operations = [ migrations.AlterField( model_name='brand', name='address', field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Адрес'), ), migrations.AlterField( model_name='brand', name='description', field=ckeditor_uploader.fields.RichTextUploadingField(blank=True, null=True, verbose_name='Описание'), ), migrations.AlterField( model_name='brand', name='logo', field=models.ImageField(default='logo.jpeg', upload_to=core.utils.generate_filename, verbose_name='Лого'), preserve_default=False, ), migrations.AlterField( model_name='brand', name='title', field=models.CharField(default='title', max_length=255, verbose_name='Название'), preserve_default=False, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,542
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/migrations/0004_auto_20210401_1321.py
# Generated by Django 2.2.16 on 2021-04-01 07:21 from django.db import migrations import django_2gis_maps.fields class Migration(migrations.Migration): dependencies = [ ('brand', '0003_remove_filial_description'), ] operations = [ migrations.RemoveField( model_name='brandimage', name='is_main', ), migrations.RemoveField( model_name='filial', name='link', ), migrations.AlterField( model_name='filial', name='geolocation', field=django_2gis_maps.fields.GeoLocationField(verbose_name='Геолокация'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,543
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/apps.py
from django.apps import AppConfig class InfoConfig(AppConfig): name = 'apps.info' verbose_name = 'Информация'
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,544
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/integration/views.py
from drf_yasg.utils import swagger_auto_schema from rest_framework import generics, status from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from apps.check.models import Check from apps.integration.serializers import ( Auth1cSerializer, Get1cUserSerializer, CheckSerializer, Login1cAPIViewResponseSerializer, UpdateCheckSerializer, ) from apps.integration.service import User1cAuthService, CreateCheckService from apps.check.service import CheckNotificationService class Auth1cAPIView(generics.GenericAPIView): """ Эндпоинт для login 1C пользователя """ serializer_class = Auth1cSerializer @swagger_auto_schema( responses={ 200: Login1cAPIViewResponseSerializer(), 400: "It will return error type", } ) def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) return User1cAuthService.get_response(serializer) class GetUserAPIView(generics.GenericAPIView): """ Эндпоинт для получения unique_1C_ID пользователя по QR коду """ serializer_class = Get1cUserSerializer permission_classes = (IsAuthenticated,) @swagger_auto_schema( responses={ 400: "Устарел QR код пользователя", 404: "Пользователь не найден", } ) def get(self, request, *args, **kwargs): user = CreateCheckService.get_user_by_qr_code(kwargs.get('qr_code')) if not user: return Response( {'message': 'Пользователь не найден'}, status=status.HTTP_404_NOT_FOUND ) return CreateCheckService.response_user_1c_code( self.serializer_class(user), user ) class CreateCheckAPIView(generics.CreateAPIView): """ Эндпоинт для создание чека """ serializer_class = CheckSerializer permission_classes = (IsAuthenticated,) @swagger_auto_schema( responses={ 200: CheckSerializer(), 400: 'Ошибка при валидации', } ) def post(self, request, *args, **kwargs): return self.create(request, *args, **kwargs) def perform_create(self, serializer): user, filial = CreateCheckService.get_user_and_filial_from_serializer( serializer.validated_data ) serializer.validated_data['user'] = user serializer.validated_data['filial'] = filial check = serializer.save() CheckNotificationService.send_notification(check, user) class UpdateCheckAPIView(generics.UpdateAPIView): """ Эндпоинт для обновления чека """ http_method_names = ('patch',) serializer_class = UpdateCheckSerializer permission_classes = (IsAuthenticated,) queryset = Check.objects.all() lookup_field = 'unique_1c_check_code' @swagger_auto_schema( responses={ 200: UpdateCheckSerializer(), 404: '"detail": "Страница не найдена."', } ) def patch(self, request, *args, **kwargs): return self.partial_update(request, *args, **kwargs)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,545
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/migrations/0004_auto_20210504_1810.py
# Generated by Django 2.2.16 on 2021-05-04 12:10 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('notifications', '0003_auto_20210428_1419'), ] operations = [ migrations.AlterField( model_name='notification', name='notice_type', field=models.CharField(choices=[('accrued', 'Начислено бонусов'), ('withdrawn', 'Снято бонусов'), ('accrued_and_withdrawn', 'Начислено и снято'), ('promotion', 'Акции'), ('news', 'Новости')], max_length=25, verbose_name='Тип'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,546
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/core/urls.py
from django.conf import settings from django.conf.urls import url from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include, re_path from drf_yasg import openapi from drf_yasg.views import get_schema_view admin.site.site_header = "Adeliya" admin.site.site_title = "Adeliya" admin.site.index_title = "Админ-панель Adeliya" schema_view = get_schema_view( openapi.Info( title="Adeliya API", default_version='v1', description="Adeliya API description", terms_of_service="https://www.google.com/policies/terms/", contact=openapi.Contact(email="kalmanbetovaman@gmail.com"), license=openapi.License(name="BSD License"), ), public=True, permission_classes=(settings.API_PERMISSION,), ) v1_api = ([ path('account/', include('apps.account.urls')), path('brand/', include('apps.brand.urls')), path('info/', include('apps.info.urls')), path('check/', include('apps.check.urls')), path('notification/', include('apps.notifications.urls')), path('setting/', include('apps.setting.urls')), path('1c/', include('apps.integration.urls')) ], 'v1') urlpatterns = [ path('jet/', include('jet.urls', 'jet')), path('admin/', admin.site.urls), path('ckeditor/', include('ckeditor_uploader.urls')), url(r'^docs(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'), url(r'^docs/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), url(r'^redocs/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), re_path(r'api/v1/', include(v1_api, namespace='v1')), ] if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) import debug_toolbar urlpatterns += [path('__debug__/', include(debug_toolbar.urls))]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,547
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/migrations/0008_auto_20210428_1228.py
# Generated by Django 2.2.16 on 2021-04-28 06:28 import ckeditor_uploader.fields from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('info', '0007_banner_description'), ] operations = [ migrations.AlterField( model_name='promotionandnews', name='description', field=ckeditor_uploader.fields.RichTextUploadingField(verbose_name='Текст статьи'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,548
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/tests/factories.py
from random import choice import factory from apps.brand.models import ( Brand, BrandImage, Filial, FilialImage, FilialPhone, ) class BrandFactory(factory.django.DjangoModelFactory): class Meta: model = Brand title = factory.Faker('company') logo = factory.django.ImageField(width=1024, height=768) description = factory.Faker('text') address = factory.Faker('address') link = factory.Faker('url') class BrandImageFactory(factory.django.DjangoModelFactory): class Meta: model = BrandImage brand = None image = factory.django.ImageField(width=1024, height=768) class FilialFactory(factory.django.DjangoModelFactory): class Meta: model = Filial position = factory.Sequence(lambda x: '%d' % x) title = factory.Faker('name') address = factory.Faker('address') geolocation = "42.87962197359586,74.60025385022163" start_work = factory.Faker('time') end_work = factory.Faker('time') is_around_the_clock = factory.Sequence(lambda x: choice([True, False])) filial_1c_code = factory.Faker('random_number') class FilialImageFactory(factory.django.DjangoModelFactory): class Meta: model = FilialImage filial = factory.SubFactory(FilialFactory) image = factory.django.ImageField(width=1024, height=768) is_main = factory.Sequence(lambda x: choice([True, False])) class FilialPhoneFactory(factory.django.DjangoModelFactory): class Meta: model = FilialPhone filial = factory.SubFactory(FilialFactory) phone = factory.Faker('phone_number') is_phone = factory.Sequence(lambda x: choice([True, False])) is_whatsapp = factory.Sequence(lambda x: choice([True, False]))
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,549
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/tests/test_views.py
import json from unittest import mock from django.test import TestCase, Client from django.urls import reverse from rest_framework import status from rest_framework.authtoken.models import Token from rest_framework.test import APIClient from apps.account.service import UserAuthService, ChangeOldPhoneService from apps.account.tests.factories import UserFactory, CityFactory from apps.account.tests.mymock import ( SuccessSmsNikitaResponse, SuccessSmsNikitaInvalidStatusResponse, failure_compare_confirmation_time, SuccessChangePhone, ) from apps.account.utils import generate_photo_file from core.constants import MALE class AuthorizedTestMixin: def test_unauthorized_on_401(self): client = APIClient() response = client.get(self.url) expected_data = {'detail': 'Учетные данные не были предоставлены.'} self.assertEqual(status.HTTP_401_UNAUTHORIZED, response.status_code) self.assertEqual(expected_data, json.loads(response.content)) def test_get_invalid_token_on_401(self): user = UserFactory() token = Token.objects.create(user=user) client = APIClient() client.credentials(HTTP_AUTHORIZATION='Token ' + token.key + 'a') response = client.get(self.url) expected_data = {'detail': 'Недопустимый токен.'} self.assertEqual(status.HTTP_401_UNAUTHORIZED, response.status_code) self.assertEqual(expected_data, json.loads(response.content)) class AuthAPIViewTest(TestCase): @classmethod def setUpTestData(cls) -> None: UserFactory(phone='+996553000117', is_registration_finish=True) UserFactory( phone='+996553000118', is_active=False, is_registration_finish=True, ) cls.client = Client() cls.auth_url = reverse('v1:auth') @mock.patch('requests.post', return_value=SuccessSmsNikitaResponse()) def test_success_status_on_201(self, mocked): phone_data = {'phone': '+996999111222'} response = self.client.post(self.auth_url, data=phone_data) expected_data = {'message': 'User создан! Сообщение отправлено'} self.assertEqual(status.HTTP_201_CREATED, response.status_code) self.assertEqual(expected_data, response.data) @mock.patch('requests.post', return_value=SuccessSmsNikitaResponse()) def test_success_status_on_200(self, mocked): phone_data = {'phone': '+996553000117'} response = self.client.post(self.auth_url, data=phone_data) expected_data = {'message': 'Сообщение отправлено'} self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertEqual(expected_data, response.data) def test_is_not_active_user_status_on_400(self): phone_data = {'phone': '+996553000118'} response = self.client.post(self.auth_url, data=phone_data) expected_data = {'phone': ['Этот номер не активен.']} self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) self.assertEqual(expected_data, json.loads(response.content)) @mock.patch('requests.post', return_value=SuccessSmsNikitaInvalidStatusResponse()) def test_sms_nikita_with_invalid_status_on_400(self, mocked): phone_data = {'phone': '+996999111222'} response = self.client.post(self.auth_url, data=phone_data) expected_data = {'message': 'Не удалось отправить сообщение. Попробуйте позже.'} self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) self.assertEqual(expected_data, response.data) @mock.patch.object(UserAuthService, 'compare_confirmation_time', return_value=failure_compare_confirmation_time()) def test_failure_too_many_requests_on_429(self, mocked): phone_data = {'phone': '+996999111222'} response = self.client.post(self.auth_url, data=phone_data) expected_data = {'message': 'Вы слишком часто отправляете сообщение.'} self.assertEqual(status.HTTP_429_TOO_MANY_REQUESTS, response.status_code) self.assertEqual(expected_data, response.data) def test_failure_phone_validate_on_400(self): phone_data = {'phone': '+996999111222a'} response = self.client.post(self.auth_url, data=phone_data) expected_data = {'phone': ['phone is not valid!']} self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) self.assertEqual(expected_data, json.loads(response.content)) class LoginConfirmAPIViewTest(TestCase): @classmethod def setUpTestData(cls): UserFactory(phone='+996999111222', is_active=True, confirmation_code='123456') UserFactory(phone='+996701626702', is_active=False, confirmation_code='123456') UserFactory(phone='+996701626700', confirmation_code='123456',) cls.url = reverse('v1:login-confirm') def test_success_login_confirmation_with_profile_completed_on_200(self): data = {'phone': '+996701626700', 'confirmation_code': '123456'} response = self.client.post(self.url, data=data) self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertEqual(True, response.data.get('is_profile_completed')) def test_success_login_confirmation_without_profile_completed_on_200(self): data = {'phone': '+996999111222', 'confirmation_code': '123456'} response = self.client.post(self.url, data=data) self.assertEqual(status.HTTP_200_OK, response.status_code) def test_failure_not_valid_confirmation_code_on_403(self): data = {'phone': '+996999111222', 'confirmation_code': '123455'} expected_data = {'message': 'Неверный код'} response = self.client.post(self.url, data=data) self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code) self.assertEqual(expected_data, response.data) def test_is_not_active_user_on_400(self): data = {'phone': '+996701626702', 'confirmation_code': '123456'} response = self.client.post(self.url, data=data) expected_data = {'phone': ['Этот номер не активен.']} self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) self.assertEqual(expected_data, json.loads(response.content)) def test_not_exist_user_on_404(self): data = {'phone': '+996701626705', 'confirmation_code': '123456'} response = self.client.post(self.url, data=data) expected_data = {'detail': 'user not found'} self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code) self.assertEqual(expected_data, json.loads(response.content)) def test_failure_phone_validate_on_400(self): phone_data = {'phone': '+996999111222a', 'confirmation_code': '123456'} response = self.client.post(self.url, data=phone_data) expected_data = {'phone': ['phone is not valid!']} self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) self.assertEqual(expected_data, json.loads(response.content)) class CityListAPIViewTest(TestCase): @classmethod def setUpTestData(cls): CityFactory() CityFactory() cls.url = reverse('v1:cities') cls.client = Client() def test_city_list_api(self): response = self.client.get(self.url) self.assertEqual(status.HTTP_200_OK, response.status_code) class UserRetrieveUpdateAPIViewTest(AuthorizedTestMixin, TestCase): @classmethod def setUpTestData(cls): cls.url = reverse('v1:retrieve-update') user = UserFactory() cls.token = Token.objects.create(user=user) cls.city = user.city def setUp(self) -> None: self.client = APIClient() self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key) def test_get_success_on_200(self): response = self.client.get(self.url) self.assertEqual(status.HTTP_200_OK, response.status_code) def test_put_bad_request_on_400(self): response = self.client.put(self.url, {}) self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) def test_put_success_on_200(self): data = { 'first_name': 'Aman', 'last_name': 'Kalmanbetov', 'gender': MALE, 'birth_date': '1975-05-09', 'city': self.city.id, } response = self.client.put(self.url, data) self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertEqual('Aman', response.data.get('first_name')) self.assertEqual('Kalmanbetov', response.data.get('last_name')) def test_patch_success_on_200(self): data = {'first_name': 'Amanbek'} response = self.client.patch(self.url, data) self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertEqual('Amanbek', response.data.get('first_name')) class UserAvatarRetrieveUpdateAPIViewTest(AuthorizedTestMixin, TestCase): @classmethod def setUpTestData(cls): cls.url = reverse('v1:avatar') user = UserFactory() cls.token = Token.objects.create(user=user) def setUp(self) -> None: self.client = APIClient() self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key) def test_success_update_avatar_on_200(self): data = {'avatar': generate_photo_file()} response = self.client.patch(self.url, data) self.assertEqual(status.HTTP_200_OK, response.status_code) class SendSmsToOldPhoneAPIViewTest(AuthorizedTestMixin, TestCase): @classmethod def setUpTestData(cls): cls.url = reverse('v1:send_sms_to_old_phone') cls.user = UserFactory() cls.token = Token.objects.create(user=cls.user) def setUp(self) -> None: self.client = APIClient() self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key) @mock.patch.object(UserAuthService, 'compare_confirmation_time', return_value=failure_compare_confirmation_time()) def test_failure_too_many_requests_on_429(self, mocked): response = self.client.get(self.url) expected_data = {'message': 'Вы слишком часто отправляете сообщение.'} self.assertEqual(status.HTTP_429_TOO_MANY_REQUESTS, response.status_code) self.assertEqual(expected_data, response.data) @mock.patch('requests.post', return_value=SuccessSmsNikitaResponse()) def test_success_status_on_200(self, mocked): response = self.client.get(self.url) expected_data = {'message': 'Сообщение отправлено'} self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertEqual(expected_data, response.data) @mock.patch('requests.post', return_value=SuccessSmsNikitaInvalidStatusResponse()) def test_sms_nikita_with_invalid_status_on_400(self, mocked): response = self.client.get(self.url) expected_data = {'message': 'Не удалось отправить сообщение. Попробуйте позже.'} self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) self.assertEqual(expected_data, response.data) class OldPhoneConfirmAPIViewTest(AuthorizedTestMixin, TestCase): @classmethod def setUpTestData(cls): cls.url = reverse('v1:old_phone_confirm') def setUp(self) -> None: self.user = UserFactory(confirmation_code='123456') self.token = Token.objects.create(user=self.user) self.client = APIClient() self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key) def test_failure_not_valid_confirmation_code_on_403(self): data = {'confirmation_code': '123455'} expected_data = {'message': 'Неверный код'} response = self.client.post(self.url, data=data) self.user.refresh_from_db() self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code) self.assertEqual(expected_data, response.data) self.assertEqual(False, self.user.is_old_phone_confirmed) def test_success_confirmation_on_200(self): data = {'confirmation_code': '123456'} response = self.client.post(self.url, data=data) expected_data = {"message": "Old phone is confirmed"} self.user.refresh_from_db() self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertEqual(expected_data, response.data) self.assertEqual(True, self.user.is_old_phone_confirmed) class SendSmsToNewPhoneAPIVewTest(TestCase): @classmethod def setUpTestData(cls) -> None: cls.user = UserFactory(phone='+996553000117', is_registration_finish=True) cls.url = reverse('v1:change_old_phone') cls.token = Token.objects.create(user=cls.user) def setUp(self) -> None: self.client = APIClient() self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key) @mock.patch('requests.post', return_value=SuccessSmsNikitaResponse()) def test_success_status_on_200(self, mocked): phone_data = {'phone': '+996553000119'} response = self.client.post(self.url, data=phone_data) expected_data = {'message': 'Сообщение отправлено'} self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertEqual(expected_data, response.data) @mock.patch('requests.post', return_value=SuccessSmsNikitaInvalidStatusResponse()) def test_sms_nikita_with_invalid_status_on_400(self, mocked): phone_data = {'phone': '+996999111222'} response = self.client.post(self.url, data=phone_data) expected_data = { 'message': 'Не удалось отправить сообщение. Попробуйте позже.'} self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) self.assertEqual(expected_data, response.data) def test_checking_for_uniqueness_with_status_on_406(self): phone_data = {'phone': '+996553000117'} response = self.client.post(self.url, data=phone_data) expected_data = {'message': 'Такой номер телефона уже существует'} self.assertEqual(status.HTTP_406_NOT_ACCEPTABLE, response.status_code) self.assertEqual(expected_data, response.data) def test_failure_too_many_requests_on_429(self): phone_data = {'phone': '+996999111222'} response = self.client.post(self.url, phone_data) response = self.client.post(self.url, phone_data) expected_data = {'message': 'Вы слишком часто отправляете сообщение.'} self.assertEqual(status.HTTP_429_TOO_MANY_REQUESTS, response.status_code) self.assertEqual(expected_data, response.data) class NewPhoneConfirmAPIViewTest(AuthorizedTestMixin, TestCase): @classmethod def setUpTestData(cls): cls.url = reverse('v1:new_phone_confirm') cls.user = UserFactory(confirmation_code='123456') cls.token = Token.objects.create(user=cls.user) def setUp(self) -> None: self.client = APIClient() self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key) def test_failure_not_valid_confirmation_code_on_403(self): data = {'confirmation_code': '123455'} expected_data = {'message': 'Неверный код'} response = self.client.post(self.url, data=data) self.user.refresh_from_db() self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code) self.assertEqual(expected_data, response.data) self.assertEqual(False, self.user.is_old_phone_confirmed) """ Don't forget to added test for ChangePhoneSerializer """
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,550
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/core/utils.py
import os import re import uuid from django.utils import timezone def slugify_camelcase(string: str, sep: str = "-") -> str: """ Converts camelcase string to lowercase string divided with given separator :param string: string to slugify :param sep: separator :return: slugified string With sep='_': 'CamelCase' -> 'camel_case' """ repl = r"\1{}\2".format(sep) s1 = re.sub("(.)([A-Z][a-z]+)", repl, string) return re.sub("([a-z0-9])([A-Z])", repl, s1).lower() def generate_filename(instance, filename: str) -> str: """ Generates a filename for a model's instance :param instance: Django model's instance :param filename: filename :return: generated filename Filename consist of slugified model name, current datetime and time and uuid """ f, ext = os.path.splitext(filename) model_name = slugify_camelcase(instance._meta.model.__name__, "_") strftime = timezone.datetime.now().strftime("%Y/%m/%d") hex_ = uuid.uuid4().hex return f"{model_name}/{strftime}/{hex_}{ext}"
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,551
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/migrations/0010_auto_20210630_1621.py
# Generated by Django 2.2.16 on 2021-06-30 10:21 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('account', '0009_auto_20210527_1151'), ] operations = [ migrations.AlterField( model_name='user', name='discount', field=models.CharField(max_length=20, verbose_name='Скидка'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,552
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/admin.py
from django.contrib import admin from solo.admin import SingletonModelAdmin from apps.brand.admin import ImageInlineFormSet from .models import ( Banner, ProgramCondition, Contact, PromotionAndNews, PromotionAndNewsImage, ContactIcon, ) from apps.notifications.tasks import save_notification_and_send_fcm_for_article class PromotionAndNewsImageInline(admin.StackedInline): model = PromotionAndNewsImage extra = 0 formset = ImageInlineFormSet @admin.register(Banner) class BannerAdmin(SingletonModelAdmin): list_display = ('title',) @admin.register(ProgramCondition) class ProgramConditionAdmin(SingletonModelAdmin): list_display = ('title', 'description',) @admin.register(Contact) class ContactAdmin(admin.ModelAdmin): list_display = ('title', 'icon_image', 'link',) @admin.register(ContactIcon) class ContactIconAdmin(admin.ModelAdmin): pass @admin.register(PromotionAndNews) class PromotionAndNewsAdmin(admin.ModelAdmin): list_display = ('title', 'information_type', 'is_active',) fields = [ 'created_at', 'title', 'description', 'information_type', 'is_active', ] inlines = (PromotionAndNewsImageInline,) def save_model(self, request, obj, form, change): is_old = obj.pk # checking for existence in the database super().save_model(request, obj, form, change) if not is_old: if obj.is_active: body = { 'object_id': obj.id, 'title': obj.title, 'information_type': obj.information_type, } save_notification_and_send_fcm_for_article(body, obj)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,553
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/service.py
import json import datetime from fcm_django.models import FCMDevice from loguru import logger from core.constants import DUE_DATE_CHECK_MESSAGE, MONTH_NAMES class SendPushNotification: @classmethod def send_fcm(cls, user, notice_obj, body, badge_count): responses, full_notification, data = cls.message_generate( user, notice_obj, body, badge_count ) try: for response in responses: if response.type and response.type == 'android': response.send_message(data=data) else: full_notification['click_action'] = notice_obj.notice_type response.send_message(**full_notification) from apps.notifications.tasks import create_notification_for_db create_notification_for_db(notice_obj) except Exception as e: logger.error('Error on sending push notification to fcm service') logger.exception(e) else: logger.success('Success sending push notification') @classmethod def send_fcm_for_debtors(cls, user, notice_obj, body, badge_count): responses, full_notification, data = cls.message_generate( user, notice_obj, body, badge_count ) data['body'] = body['description'] full_notification['data'] = data try: for response in responses: if response.type and response.type == 'android': response.send_message(data=data) else: full_notification['click_action'] = notice_obj.notice_type response.send_message(**full_notification) except Exception as e: logger.error('Error on sending push notification to fcm service') logger.exception(e) else: logger.success('Success sending push notification') @staticmethod def set_notification_viewed_for_check(request, obj): user = request.user if user.is_authenticated: from apps.notifications.models import Notification notices = ( Notification.objects.filter( user=user, linked_check_id=obj.id, is_viewed=False ) ) notices.update(is_viewed=True) @staticmethod def set_notification_viewed_for_article(request, obj): user = request.user if user.is_authenticated: from apps.notifications.models import Notification notice = ( Notification.objects.filter( user=user, linked_article_id=obj.id ).first() ) if notice and not notice.is_viewed: notice.is_viewed = True notice.save(update_fields=['is_viewed']) @classmethod def checking_debtors(cls): from apps.check.models import Check from apps.notifications.models import Notification checks = ( Check.objects.filter( is_on_credit=True, due_date__date=datetime.datetime.now() + datetime.timedelta( days=3) ).select_related('user') ) for check in checks: body = { 'object_id': check.id, 'title': str(check.filial), 'status': check.status, 'accrued_point': check.accrued_point, 'withdrawn_point': check.withdrawn_point, 'description': DUE_DATE_CHECK_MESSAGE, } notice_obj = cls.save_notification_for_debtor(check, body) badge_count = Notification.objects.filter( user=check.user, is_viewed=False ).count() cls.send_fcm_for_debtors(check.user, notice_obj, body, badge_count) @staticmethod def save_notification_for_debtor(check, body): from apps.notifications.models import Notification from django.core.serializers.json import DjangoJSONEncoder notice_obj = Notification.objects.create( user=check.user, notice_type=check.status, linked_check=check, body=json.dumps(body, cls=DjangoJSONEncoder), is_on_credit=True, ) return notice_obj @staticmethod def message_generate(user, notice_obj, body, badge_count): responses = FCMDevice.objects.filter(user=user, active=True) data_msg = dict( title=notice_obj.NOTIFICATION_TITLE, body=notice_obj.get_message, click_action=notice_obj.notice_type, id=body['object_id'], type=notice_obj.notice_type, badge_count=badge_count, ) full_notification = { 'data': data_msg, 'title': notice_obj.NOTIFICATION_TITLE, 'body': notice_obj.get_message, 'sound': "default", } return responses, full_notification, data_msg @classmethod def send_notice_for_delete(cls, devices, is_corporate_account) -> None: data = dict( title='TruckParts', body='Вы зашли с другого устройства!', click_action='TruckPartsKick', id=6699, # not necessarily is_kicked=True, ) full_notification = { 'data': data, 'title': 'TruckParts', 'body': 'Вы зашли с другого устройства!', 'sound': "default", } if is_corporate_account: device = devices.last() cls.send_kick_notice(device, data) else: for device in devices: cls.send_kick_notice(device, data, full_notification) @staticmethod def send_kick_notice(device, data, full_notification=None): try: if device.type and device.type == 'android': device.send_message(data=data) else: device.send_message(**full_notification) except Exception as e: logger.error('Error on sending push notification to fcm service') logger.exception(e) device.delete() else: logger.success('Success sending push notification') device.delete() class NotificationResponseService: @classmethod def reformat(cls, notifications): notification_list = [] month_list = [] last_month = None last_year = None if len(notifications) == 0: return notification_list for notification in notifications: notification_date = notification['created_at'].split('T')[0] year, month, _ = notification_date.split('-') if last_month == month and last_year == year: month_list['notifications'].append(notification) else: if month_list: notification_list.append(month_list) month_list = { 'month': cls.get_month_name(month), 'year': year, 'notifications': [notification] } last_month, last_year = month, year notification_list.append(month_list) return notification_list @staticmethod def get_month_name(month_number): return MONTH_NAMES.get(month_number)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,554
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/tests/test_views.py
from django.test import TestCase from django.urls import reverse from rest_framework import status from rest_framework.authtoken.models import Token from rest_framework.test import APIClient from apps.account.tests.factories import UserFactory class QRCodeAPIViewTest(TestCase): @classmethod def setUpTestData(cls): cls.url = reverse('v1:qr_code') user = UserFactory() cls.token = Token.objects.create(user=user) def setUp(self) -> None: self.client = APIClient() def test_success_get_qr_code_on_200(self): self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token.key) response = self.client.get(self.url) self.assertEqual(status.HTTP_200_OK, response.status_code) def test_fail_get_qr_code_on_401(self): response = self.client.get(self.url) self.assertEqual(status.HTTP_401_UNAUTHORIZED, response.status_code)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,555
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/middleware.py
from apps.setting.service import ApplicationStatusService class ApplicationStatusMiddleware: def __init__(self, get_response): self.get_response = get_response def __call__(self, request): response = self.get_response(request) return ApplicationStatusService.check_application_status( request, response )
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,556
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/tasks.py
import json from django.core.serializers.json import DjangoJSONEncoder from huey.contrib.djhuey import task, periodic_task, db_task from huey import crontab from loguru import logger from apps.notifications.models import Notification from apps.notifications.service import SendPushNotification from core.constants import DUE_DATE_CHECK_MESSAGE @task() def save_notification_and_send_fcm_for_article(body, obj): from apps.account.models import User users_qs = User.objects.filter(is_registration_finish=True, is_active=True) for user in users_qs: notice_obj = Notification( user=user, notice_type=body['information_type'], linked_article=obj, body=json.dumps(body, cls=DjangoJSONEncoder), ) badge_count = Notification.objects.filter( user=user, is_viewed=False ).count() SendPushNotification.send_fcm(user, notice_obj, body, badge_count) @db_task(retries=5) def create_notification_for_db(notice_obj): try: notice_obj.save() except Exception as e: logger.error('Didn\'t created notification') logger.exception(e) else: logger.success('Success create notification') @task() def save_notification_and_send_fcm_for_check(body, user, obj): notice_obj = Notification( user=user, notice_type=body['status'], linked_check=obj, body=json.dumps(body, cls=DjangoJSONEncoder) ) if obj.is_on_credit: body['description'] = DUE_DATE_CHECK_MESSAGE notice_obj.is_on_credit = True else: body['description'] = f'{user.first_name}, {notice_obj.get_message}' notice_obj.body = json.dumps(body, cls=DjangoJSONEncoder) badge_count = Notification.objects.filter( user=user, is_viewed=False ).count() SendPushNotification.send_fcm(user, notice_obj, body, badge_count) @periodic_task(crontab(hour='*/24')) def send_notification_for_debtors(): """Everyday sending push notification for debtor""" SendPushNotification.checking_debtors() @task() def send_notice_for_deleted_fcm_device(device, is_corporate_account): SendPushNotification.send_notice_for_delete( device, is_corporate_account )
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,557
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/filters.py
import django_filters from apps.check.models import Check class CheckFilter(django_filters.FilterSet): start_date = django_filters.CharFilter( field_name='accrued_point_date', method='start_date_filter' ) end_date = django_filters.CharFilter( field_name='accrued_point_date', method='end_date_filter' ) class Meta: model = Check fields = ['start_date', 'end_date'] def start_date_filter(self, queryset, name, value): if 'end_date' in self.request.GET: return queryset.filter(accrued_point_date__date__gte=value) return queryset.filter(accrued_point_date__date=value) def end_date_filter(self, queryset, name, value): self.end_date = value return queryset.filter(accrued_point_date__date__lte=value)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,558
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/pagination.py
from rest_framework.pagination import PageNumberPagination from rest_framework.response import Response from apps.notifications.service import NotificationResponseService class LargeListNotificationPagination(PageNumberPagination): page_size = 20 def get_paginated_response(self, data): reformat_data = NotificationResponseService.reformat(data) return Response({ 'count': self.page.paginator.count, 'next': self.page.next_page_number() if self.page.has_next() else None, 'previous': self.page.previous_page_number() if self.page.has_previous() else None, 'results': reformat_data, })
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,559
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/models.py
import datetime from django.db import models from solo.models import SingletonModel class TimeStampAbstractModel(models.Model): created_at = models.DateTimeField( verbose_name='Создано', auto_now_add=True, null=True ) updated_at = models.DateTimeField( verbose_name='Обновлено', auto_now=True, null=True ) def __unicode__(self): pass def __str__(self): return self.__unicode__() class Meta: abstract = True class Setting(SingletonModel): qr_code_expiration_date = models.DurationField( default=datetime.timedelta(minutes=3), verbose_name='Срок активности QR кода', help_text=' QR код будет недействителен при истечений срока активности' ) is_service_active = models.BooleanField( default=True, verbose_name='Статус сервиса', help_text='Убрав галочку, вы можете отключить сервис' ) def __str__(self): return f'Статус сайта: {self.is_service_active}' class Meta: verbose_name = 'Настройка сайта' verbose_name_plural = 'Настройки сайта' class AppVersion(SingletonModel): android_version = models.CharField( max_length=15, verbose_name='Версия для android приложения', ) android_force_update = models.BooleanField( default=False, verbose_name='Принудительное обновление(Вкл/Выкл)', ) ios_build_number = models.PositiveIntegerField( verbose_name='Build версия для ios приложения', null=True ) ios_version = models.CharField( max_length=15, verbose_name='Версия для ios приложения', ) ios_force_update = models.BooleanField( default=False, verbose_name='Принудительное обновление(Вкл/Выкл)', ) def __str__(self): return f'Android v{self.android_version}, ios v{self.ios_version}' class Meta: verbose_name = 'Версия мобильного приложения' verbose_name_plural = 'Версии мобильного приложения' class HelpPage(SingletonModel): title = models.CharField( max_length=50, verbose_name="Заголовок справки", ) text = models.TextField(verbose_name="Текст справки") def __str__(self): return self.title class Meta: verbose_name = 'Справка' verbose_name_plural = 'Справки'
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,560
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/migrations/0008_user_is_corporate_account.py
# Generated by Django 2.2.16 on 2021-04-29 05:00 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('account', '0007_auto_20210414_1630'), ] operations = [ migrations.AddField( model_name='user', name='is_corporate_account', field=models.BooleanField(default=False, verbose_name='Корпоративный аккаунт?'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,561
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/service.py
import random import re import string import requests import xmltodict from datetime import timedelta, datetime from django.contrib.auth import get_user_model from django.utils import timezone from django.conf import settings from rest_framework import exceptions, status from rest_framework.authtoken.models import Token from rest_framework.response import Response from rest_framework import serializers from dicttoxml import dicttoxml from apps.integration.service import User1CNumberChangeService from apps.notifications.tasks import send_notice_for_deleted_fcm_device User = get_user_model() class UserAuthService: """ Service for handling AUTH methods """ @classmethod def get_response(cls, serializer) -> Response: """Method для login или создания пользователя и отсылки SMS """ user = serializer.user if not cls.compare_confirmation_time(user): return Response( {'message': 'Вы слишком часто отправляете сообщение.'}, status=status.HTTP_429_TOO_MANY_REQUESTS ) if not cls.send_confirmation_sms(user): return Response( {'message': 'Не удалось отправить сообщение. Попробуйте позже.'}, status=status.HTTP_400_BAD_REQUEST ) if serializer.created: return Response( {'message': 'User создан! Сообщение отправлено'}, status=status.HTTP_201_CREATED ) return Response( {'message': 'Сообщение отправлено'}, status=status.HTTP_200_OK ) @classmethod def send_to_old_phone(cls, user: User) -> Response: """method for send sms to old phone number""" if not cls.compare_confirmation_time(user): return Response( {'message': 'Вы слишком часто отправляете сообщение.'}, status=status.HTTP_429_TOO_MANY_REQUESTS ) if not cls.send_confirmation_sms(user): return Response( {'message': 'Не удалось отправить сообщение. Попробуйте позже.'}, status=status.HTTP_400_BAD_REQUEST ) return Response( {'message': 'Сообщение отправлено'}, status=status.HTTP_200_OK ) @staticmethod def generate_new_code(): """ Method for generating random confirmation code """ code = ''.join(random.choice(string.digits) for i in range(6)) return code @staticmethod def compare_confirmation_time(user_obj) -> bool: """ Method for checking if 1 minute left from last request """ result = ( not user_obj.confirmation_date or (timezone.now() - user_obj.confirmation_date) > timedelta(minutes=1) ) return result @staticmethod def check_format_user_phone(phone): """ Method for formation user phone (+ and only digits) """ match = re.match(r'^\+[0-9]{10,}$', phone) if not match: raise exceptions.ValidationError('phone is not valid!') return phone @staticmethod def get_or_create_user_instance(phone_number): """ Getting or creating user instance """ try: user = User.objects.get(phone=phone_number) except User.DoesNotExist: user = User.objects.create( phone=phone_number, is_active=True, is_registration_finish=False, ) created = not user.is_registration_finish return user, created @classmethod def set_confirmation_code(cls, user_obj: User) -> str: """ Method for setting confirmation sms code to user """ confirmation_code = cls.generate_new_code() if user_obj.phone == '+996553000117' or user_obj.phone == '+996999111222': confirmation_code = '123456' user_obj.confirmation_code = confirmation_code user_obj.confirmation_date = timezone.now() user_obj.save( update_fields=['confirmation_code', 'confirmation_date']) return confirmation_code @classmethod def send_confirmation_sms(cls, user_obj: User) -> bool: """ Method for sending confirmation sms to a new or old user """ confirmation_code = cls.set_confirmation_code(user_obj) id_string = '%s%d' % (user_obj.id, datetime.now().timestamp()) data = { 'login': settings.NIKITA_LOGIN, 'pwd': settings.NIKITA_PASSWORD, 'id': id_string, 'sender': settings.NIKITA_SENDER, 'text': f'Ваш код активации: {confirmation_code}', 'phones': [str(user_obj.phone).replace('+', '')], 'test': settings.NIKITA_TEST } page = dicttoxml(data, custom_root='message', item_func=lambda x: x[:-1], attr_type=False) response = requests.post( 'https://smspro.nikita.kg/api/message', data=page, headers={'Content-Type': 'application/xml'} ) response_dict = xmltodict.parse(response.text) status = response_dict['response']['status'] return True if status in ('0', '11') else False class PhoneConfirmationService: """ Service for handling phone confirmation on create or login """ @classmethod def get_response(cls, serializer) -> Response: phone = serializer.validated_data['phone'] # exists of user is checked before user = User.objects.get(phone=phone) confirmation_code = serializer.validated_data['confirmation_code'] if not cls.check_confirmation_code(user, confirmation_code): return Response( {'message': 'Неверный код'}, status=status.HTTP_403_FORBIDDEN, ) cls.check_corporate_account(user) cls.finish_registration(user) token = cls.create_or_refresh_user_token(user) from apps.account.serializers import LoginConfirmAPIViewResponseSerializer response = LoginConfirmAPIViewResponseSerializer({ 'token': token.key, 'is_profile_completed': cls.check_is_profile_completed(user), }).data return Response( response, status=status.HTTP_200_OK, ) @classmethod def get_response_for_old_phone_confirmation(cls, user: User, serializer) -> Response: confirmation_code = serializer.validated_data['confirmation_code'] if not cls.check_confirmation_code(user, confirmation_code): return Response( {'message': 'Неверный код'}, status=status.HTTP_403_FORBIDDEN, ) cls.confirm_old_phone(user) cls.set_confirmation_date(user) return Response( {'message': 'Old phone is confirmed'}, status=status.HTTP_200_OK, ) @classmethod def check_confirmation_code(cls, user: User, confirmation_code: str) -> bool: return user.confirmation_code == confirmation_code @staticmethod def finish_registration(user: User) -> None: user.is_active = True user.is_registration_finish = True user.save(update_fields=['is_active', 'is_registration_finish']) @staticmethod def create_or_refresh_user_token(user: User) -> Token: token, created = Token.objects.get_or_create(user=user) return token @staticmethod def check_is_profile_completed(user: User) -> bool: return all( [user.first_name, user.last_name, user.gender, user.birth_date] ) @staticmethod def check_is_user_exists(phone: str) -> None: if not User.objects.filter(phone=phone).exists(): raise exceptions.NotFound('user not found') @staticmethod def set_confirmation_date(user_obj: User) -> None: user_obj.confirmation_date = None user_obj.save(update_fields=['confirmation_date']) @staticmethod def confirm_old_phone(user: User) -> None: user.is_old_phone_confirmed = True user.save(update_fields=['is_old_phone_confirmed']) @classmethod def check_corporate_account(cls, user) -> None: from fcm_django.models import FCMDevice user_active_device = ( FCMDevice.objects.filter(active=True, user=user) ) if user.is_corporate_account: if len(user_active_device) < 5: pass else: send_notice_for_deleted_fcm_device( user_active_device, user.is_corporate_account ) elif len(user_active_device) < 1: pass else: send_notice_for_deleted_fcm_device( user_active_device, user.is_corporate_account ) class ChangeOldPhoneService(UserAuthService, PhoneConfirmationService): """ Service for changing old phone number """ @classmethod def get_response(cls, serializer) -> Response: """Method для login пользователя и отсылки SMS """ user = serializer.user new_phone = serializer.data['phone'] response_data = { 'message': {'message': 'Сообщение отправлено'}, 'status': status.HTTP_200_OK } if not cls.compare_confirmation_time(user): response_data = { 'message': {'message': 'Вы слишком часто отправляете сообщение.'}, 'status': status.HTTP_429_TOO_MANY_REQUESTS } elif not cls.send_confirmation_sms(user): response_data = { 'message': {'message': 'Не удалось отправить сообщение. Попробуйте позже.'}, 'status': status.HTTP_400_BAD_REQUEST } elif cls.new_phone_not_unique(new_phone): response_data = { 'message': {'message': 'Такой номер телефона уже существует'}, 'status': status.HTTP_406_NOT_ACCEPTABLE, } return Response( response_data['message'], response_data['status'] ) @classmethod def get_response_for_new_phone_confirmation( cls, user: User, serializer: serializers.Serializer) -> Response: confirmation_code = serializer.validated_data['confirmation_code'] if not cls.check_confirmation_code(user, confirmation_code): return Response( {'message': 'Неверный код'}, status=status.HTTP_403_FORBIDDEN, ) response_1c_status, response_1c_data = ( User1CNumberChangeService.sync_user_phone(user) ) if not response_1c_status: return Response( {'message': response_1c_data}, status=status.HTTP_400_BAD_REQUEST, ) cls.confirm_new_phone(user) return Response( {'message': 'New phone is confirmed'}, status=status.HTTP_200_OK, ) @staticmethod def new_phone_not_unique(new_phone) -> bool: return User.objects.filter(phone=new_phone).exists() @staticmethod def confirm_new_phone(user: User) -> None: user.phone, user.tmp_phone = user.tmp_phone, user.phone user.is_old_phone_confirmed = False user.save(update_fields=['phone', 'tmp_phone', 'is_old_phone_confirmed']) @staticmethod def set_tmp_phone_number(phone_number, user): """ Getting user instance """ user.tmp_phone = phone_number user.save(update_fields=['tmp_phone']) return user
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,562
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/tests/factories.py
from random import choice import datetime import factory from apps.setting.models import AppVersion, Setting class AppVersionFactory(factory.django.DjangoModelFactory): class Meta: model = AppVersion android_version = factory.Sequence(lambda n: '1.%d' % choice([1, 2, 3])) android_force_update = factory.Sequence(lambda x: choice([True, False])) ios_version = factory.Sequence(lambda n: '1.%d' % choice([1, 2, 3])) ios_force_update = factory.Sequence(lambda x: choice([True, False])) class SettingFactory(factory.django.DjangoModelFactory): qr_code_expiration_date = factory.LazyFunction(datetime.timedelta) is_service_active = False class Meta: model = Setting
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,563
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/migrations/0009_auto_20210527_1151.py
# Generated by Django 2.2.16 on 2021-05-27 05:51 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('account', '0008_user_is_corporate_account'), ] operations = [ migrations.AlterField( model_name='user', name='qr_code', field=models.CharField(blank=True, max_length=255, null=True, verbose_name='QR-код'), ), migrations.AlterField( model_name='user', name='qr_code_updated_at', field=models.DateTimeField(blank=True, null=True, verbose_name='QR-код обновлен в'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,564
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/views.py
from django_filters.rest_framework import DjangoFilterBackend from drf_yasg.utils import swagger_auto_schema from rest_framework import generics from rest_framework.permissions import IsAuthenticated from apps.account.custom_openapi import AuthRetrieveAPIView, auth_param from apps.account.serializers import AuthErrorSerializer from apps.brand.pagination import LargeListPagination from apps.check.models import Check from apps.check.serializers import ( QRCodeSerializer, CheckListSerializer, CheckDetailSerializer ) from apps.check.service import QRCodeService from apps.check.filters import CheckFilter from apps.notifications.service import SendPushNotification class QRCodeAPIView(AuthRetrieveAPIView): """ Api view for get QR code """ serializer_class = QRCodeSerializer def get_object(self): return QRCodeService.update_user_data(self.request.user) class CheckListAPIView(generics.ListAPIView): """ API View for get check list """ permission_classes = (IsAuthenticated,) pagination_class = LargeListPagination serializer_class = CheckListSerializer filter_backends = [DjangoFilterBackend] filter_class = CheckFilter def get_queryset(self): queryset = ( Check.objects.filter(user=self.request.user) ).order_by('-accrued_point_date') return queryset @swagger_auto_schema( manual_parameters=[auth_param], responses={ 401: AuthErrorSerializer(), } ) def get(self, request, *args, **kwargs): return super(CheckListAPIView, self).get(request, *args, **kwargs) class CheckRetrieveAPIView(AuthRetrieveAPIView): """ API View for get check detail """ serializer_class = CheckDetailSerializer def get_queryset(self): return Check.objects.filter(user=self.request.user) @swagger_auto_schema( manual_parameters=[auth_param], responses={ 401: AuthErrorSerializer(), } ) def get(self, request, *args, **kwargs): SendPushNotification.set_notification_viewed_for_check( request, self.get_object() ) return super(CheckRetrieveAPIView, self).get(request, *args, **kwargs)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,565
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/migrations/0003_appversion_ios_build_number.py
# Generated by Django 2.2.16 on 2021-04-30 08:06 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('setting', '0002_appversion'), ] operations = [ migrations.AddField( model_name='appversion', name='ios_build_number', field=models.PositiveIntegerField(default=1, verbose_name='Build версия для ios приложения'), preserve_default=False, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,566
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/migrations/0007_banner_description.py
# Generated by Django 2.2.16 on 2021-04-09 04:33 import ckeditor_uploader.fields from django.db import migrations import django.utils.timezone class Migration(migrations.Migration): dependencies = [ ('info', '0006_auto_20210408_1352'), ] operations = [ migrations.AddField( model_name='banner', name='description', field=ckeditor_uploader.fields.RichTextUploadingField(default=django.utils.timezone.now, verbose_name='Описание баннера'), preserve_default=False, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,567
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/__init__.py
default_app_config = 'apps.check.apps.CheckConfig'
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,568
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/serializers.py
from rest_framework import serializers from drf_yasg.utils import swagger_serializer_method from .models import ( Banner, ProgramCondition, Contact, PromotionAndNews, PromotionAndNewsImage, ContactIcon, ) from apps.notifications.models import Notification class PromotionAndNewsSerializer(serializers.ModelSerializer): image = serializers.SerializerMethodField() class Meta: model = PromotionAndNews fields = ( 'id', 'created_at', 'information_type', 'title', 'description', 'is_active', 'image', ) @swagger_serializer_method(serializer_or_field=serializers.ImageField) def get_image(self, obj) -> str: image_obj = obj.images.all() request = self.context['request'] image_url = request.build_absolute_uri( image_obj[0].image.url) if image_obj else None return image_url class PromotionAndNewsImageSerializers(serializers.ModelSerializer): class Meta: model = PromotionAndNewsImage fields = ('id', 'image', 'is_main',) class PromotionAndNewsDetailSerializer(serializers.ModelSerializer): images = PromotionAndNewsImageSerializers(many=True) badge_count = serializers.SerializerMethodField() class Meta: model = PromotionAndNews fields = ( 'id', 'created_at', 'information_type', 'title', 'description', 'is_active', 'images', 'badge_count', ) @swagger_serializer_method(serializer_or_field=serializers.IntegerField) def get_badge_count(self, obj): user = self.context['request'].user if user.is_anonymous: count = 0 return count else: count = Notification.objects.filter(user=user, is_viewed=False).count() return count class BannerSerializer(serializers.ModelSerializer): class Meta: model = Banner fields = ('id', 'title', 'description', 'image',) class BannerDetailSerializer(serializers.ModelSerializer): class Meta: model = Banner fields = ('id', 'title', 'image', 'description',) class ProgramConditionSerializer(serializers.ModelSerializer): class Meta: model = ProgramCondition fields = ('id', 'title', 'description',) class ContactIconSerializer(serializers.ModelSerializer): class Meta: model = ContactIcon fields = ('id', 'title', 'image') class ContactListSerializer(serializers.ModelSerializer): icon_image = ContactIconSerializer() class Meta: model = Contact fields = ('id', 'icon_image', 'title', 'link',) class BannerAndPromotionSerializer(serializers.Serializer): banner = BannerSerializer() promotion = PromotionAndNewsSerializer(many=True) class Meta: field = ('banner', 'promotion',)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,569
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/admin.py
from django.contrib import admin from solo.admin import SingletonModelAdmin from apps.setting.models import Setting, AppVersion, HelpPage @admin.register(Setting) class SettingAdmin(SingletonModelAdmin): pass @admin.register(HelpPage) class HelpPageAdmin(SingletonModelAdmin): pass @admin.register(AppVersion) class AppVersionAdmin(SingletonModelAdmin): fieldsets = ( ('Android', { 'fields': ( 'android_version', 'android_force_update', ) }), ('Ios', { 'fields': ( 'ios_build_number', 'ios_version', 'ios_force_update', ) }) )
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,570
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/migrations/0001_initial.py
# Generated by Django 2.2.16 on 2021-04-06 10:20 import datetime from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Setting', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('qr_code_expiration_date', models.DurationField(default=datetime.timedelta(seconds=180), help_text=' QR код будет недействителен при истечений срока активности', verbose_name='Срок активности QR кода')), ('is_service_active', models.BooleanField(default=True, help_text='Убрав галочку, вы можете отключить сервис', verbose_name='Статус сервиса')), ], options={ 'verbose_name': 'Настройка сайта', 'verbose_name_plural': 'Настройки сайта', }, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,571
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/integration/apps.py
from django.apps import AppConfig class IntegrationConfig(AppConfig): name = 'apps.integration' verbose_name = 'Интеграция'
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,572
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/service.py
from django.http import JsonResponse from rest_framework import status from apps.setting.models import Setting class ApplicationStatusService: @classmethod def check_application_status(cls, request, response): app_setting = Setting.objects.first() is_service_off = ( app_setting and not app_setting.is_service_active and cls.is_api_path(request) ) if is_service_off: return JsonResponse( {'message': 'Сервис временно недоступен'}, status=status.HTTP_503_SERVICE_UNAVAILABLE, ) return response @staticmethod def is_api_path(request): return True if request.path.split('/')[1] == 'api' else False
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,573
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/urls.py
from django.urls import path from apps.notifications.views import NotificationAPIView urlpatterns = [ path('', NotificationAPIView.as_view(), name='notification_list'), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,574
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/migrations/0004_auto_20210429_1835.py
# Generated by Django 2.2.16 on 2021-04-29 12:35 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('check', '0003_auto_20210426_1106'), ] operations = [ migrations.AddField( model_name='check', name='due_date', field=models.DateTimeField(blank=True, null=True, verbose_name='Дата оплаты долга'), ), migrations.AddField( model_name='check', name='status', field=models.CharField(choices=[('accrued', 'Начислено'), ('withdrawn', 'Снято'), ('accrued_and_withdrawn', 'Начислено и снято'), ('on_credit', 'В долг')], default='accrued', max_length=10, verbose_name='Статус чека'), preserve_default=False, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,575
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/views.py
from django.db.models import Prefetch from rest_framework import generics from drf_yasg.utils import swagger_auto_schema from apps.brand import custom_openapi from apps.brand.models import Brand, Filial, FilialImage from apps.brand.pagination import LargeListPagination, SmallListPagination from apps.brand.serializers import ( BrandListSerializer, BrandDetailSerializer, FilialListSerializer, FilialSerializer, ) from apps.brand.service import FilialService class BrandListAPIView(generics.ListAPIView): """ Api view for get all brand list page by 20 """ serializer_class = BrandListSerializer queryset = Brand.objects.all() pagination_class = LargeListPagination class BrandRetrieveAPIView(generics.RetrieveAPIView): """ Api view for get brand by id """ serializer_class = BrandDetailSerializer queryset = Brand.objects.all() lookup_field = 'id' @swagger_auto_schema( responses={ 404: '{"detail": "Страница не найдена."}', } ) def get(self, request, *args, **kwargs): return super(BrandRetrieveAPIView, self).get(request, *args, **kwargs) class FilialListAPIView(generics.ListAPIView): """ Api view for get all filial list page by 10 """ serializer_class = FilialListSerializer pagination_class = SmallListPagination queryset = ( Filial.objects.all() .prefetch_related( Prefetch('images', FilialImage.objects.filter(is_main=True)) ) ) def get_serializer_context(self): context = super(FilialListAPIView, self).get_serializer_context() client_geolocation = FilialService.get_geolocation(self.request) context['client_geolocation'] = client_geolocation return context @swagger_auto_schema( manual_parameters=custom_openapi.filial_extra_params, responses={ 400: '{"geolocation": "Неправильный формат query param: lat long"}', } ) def get(self, request, *args, **kwargs): return super(FilialListAPIView, self).get(request, *args, **kwargs) class FilialRetrieveAPIView(generics.RetrieveAPIView): """ Api view for get filial by id """ serializer_class = FilialSerializer queryset = Filial.objects.all() lookup_field = 'id' def get_serializer_context(self): context = super(FilialRetrieveAPIView, self).get_serializer_context() client_geolocation = FilialService.get_geolocation(self.request) context['client_geolocation'] = client_geolocation return context @swagger_auto_schema( manual_parameters=custom_openapi.filial_extra_params, responses={ 400: '{"geolocation": "Неправильный формат query param: lat long"}', 404: '{"detail": "Страница не найдена."}', } ) def get(self, request, *args, **kwargs): return super(FilialRetrieveAPIView, self).get(request, *args, **kwargs)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,576
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/integration/serializers.py
from django.contrib.auth import authenticate from rest_framework import serializers from apps.account.models import User from apps.brand.models import Filial from apps.check.models import Check class Auth1cSerializer(serializers.ModelSerializer): """Сериалайзер для валидации пользователя 1c""" phone = serializers.CharField(required=True) password = serializers.CharField(required=True) def validate(self, data): phone = data.get('phone') password = data.get('password') if phone and password: user = authenticate(request=self.context.get('request'), phone=phone, password=password) if not user: raise serializers.ValidationError( {'Сообщение': 'Некорректные данные'}) else: raise serializers.ValidationError( {'Сообщение': 'Неверный формат данных'}) self.user = user return data class Meta: model = User fields = ('phone', 'password') class Login1cAPIViewResponseSerializer(serializers.Serializer): """ Сериалайзер для токена пользователя 1c """ token = serializers.CharField() class Get1cUserSerializer(serializers.ModelSerializer): """ Сериализатор 1С данных пользователя """ class Meta: model = User fields = ('user_1C_code', 'phone') extra_kwargs = { 'user_1C_code': {'required': True}, 'phone': {'required': True} } class CheckSerializer(serializers.ModelSerializer): """Сериалайзер для чека""" user_1c_code = serializers.CharField(required=True) filial_1c_code = serializers.CharField(required=True) class Meta: model = Check fields = ( 'unique_1c_check_code', 'money_paid', 'bonus_paid', 'total_paid', 'accrued_point', 'accrued_point_date', 'withdrawn_point', 'withdrawn_point_date', 'is_active', 'user_1c_code', 'filial_1c_code', 'status', 'is_on_credit', 'balance_owed', 'due_date', ) class UpdateCheckSerializer(serializers.ModelSerializer): """Сериалайзер обновления для чека""" class Meta: model = Check fields = ( 'money_paid', 'bonus_paid', 'total_paid', 'accrued_point', 'accrued_point_date', 'withdrawn_point', 'withdrawn_point_date', 'is_active', 'status', 'is_on_credit', 'balance_owed','due_date', ) class Sync1cUserSerializer(serializers.ModelSerializer): """ Сериализатор для синхронизации 1С данных пользователя """ class Meta: model = User fields = ( 'phone', 'first_name', 'last_name', 'gender', 'birth_date' )
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,577
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/migrations/0005_notification_is_on_credit.py
# Generated by Django 2.2.16 on 2021-05-06 08:19 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('notifications', '0004_auto_20210504_1810'), ] operations = [ migrations.AddField( model_name='notification', name='is_on_credit', field=models.BooleanField(default=False, verbose_name='В долг?'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,578
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/models.py
import ast from django.contrib.postgres.fields import JSONField from django.db import models from fcm_django.models import FCMDevice from apps.account.models import User from core.constants import ( ACCRUED, WITHDRAW, ACCRUED_AND_WITHDRAW, NEWS, PROMOTION ) from core.constants import NOTIFICATION_TYPE from apps.setting.models import TimeStampAbstractModel class Notification(TimeStampAbstractModel): NOTIFICATION_TITLE = 'Уведомление' NOTIFICATION_MESSAGE = { ACCRUED: 'Вам начислено {accrued_point} баллов', WITHDRAW: 'Вы использовали {withdrawn_point} баллов', ACCRUED_AND_WITHDRAW: 'Вы использовали {withdrawn_point} и Вам начисленно {accrued_point} баллов', PROMOTION: '{title}', NEWS: '{title}', } user = models.ForeignKey( User, related_name='notifications', on_delete=models.CASCADE, verbose_name='Пользователь' ) notice_type = models.CharField( choices=NOTIFICATION_TYPE, max_length=25, verbose_name='Тип', ) is_on_credit = models.BooleanField( default=False, verbose_name='В долг?', ) linked_article = models.ForeignKey( 'info.PromotionAndNews', null=True, blank=True, related_name='notice', on_delete=models.CASCADE, verbose_name='Новость или Акция' ) linked_check = models.ForeignKey( 'check.Check', null=True, blank=True, related_name='notice', on_delete=models.CASCADE, verbose_name='Чек' ) body = JSONField(null=True, blank=True, verbose_name='Тело') is_viewed = models.BooleanField(verbose_name='Просмотрено?', default=False) is_active = models.BooleanField(verbose_name='Активен?', default=True) def __str__(self): return f'ID: {self.id}' @property def get_message(self): return self.NOTIFICATION_MESSAGE[self.notice_type].format( **ast.literal_eval(self.body) ) class Meta: verbose_name = 'Уведомление' verbose_name_plural = 'Уведомления' ordering = ['-created_at']
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,579
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/migrations/0006_auto_20210408_1352.py
# Generated by Django 2.2.16 on 2021-04-08 07:52 import core.utils from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('info', '0005_auto_20210408_1140'), ] operations = [ migrations.CreateModel( name='ContactIcon', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=70, verbose_name='Заголовок иконки')), ('image', models.ImageField(upload_to=core.utils.generate_filename, verbose_name='Фото иконки для контактов')), ], options={ 'verbose_name': 'Иконка для контактов', 'verbose_name_plural': 'Иконки для контактов', }, ), migrations.RemoveField( model_name='contact', name='icon_type', ), migrations.AddField( model_name='contact', name='icon_image', field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='contacts', to='info.ContactIcon', verbose_name='Иконка'), preserve_default=False, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,580
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/views.py
from drf_yasg.utils import swagger_auto_schema from rest_framework import generics, status from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from apps.account.custom_openapi import ( AuthRetrieveAPIView, AuthUpdateAPIView, auth_param, ) from apps.account.models import City from apps.account.serializers import ( PhoneAuthSerializer, LoginConfirmationCodeSerializer, CitySerializer, UserUpdateSerializer, LoginConfirmAPIViewResponseSerializer, UserAvatarUpdateSerializer, AuthErrorSerializer, ConfirmationCodeSerializer, ChageOldPhoneSerializer, UserRetrieveSerializer, ) from apps.account.service import ( UserAuthService, PhoneConfirmationService, ChangeOldPhoneService ) from apps.integration.service import User1cUpdateService class AuthAPIView(generics.GenericAPIView): """ Эндпоинт для login или создания пользователя и отсылки SMS """ serializer_class = PhoneAuthSerializer @swagger_auto_schema( responses={ 200: '{"message": "Сообщение отправлено"}', 201: '{"message": "User создан! Сообщение отправлено"}', 400: "It will return error type", 429: '{"message": "Вы слишком часто отправляете сообщение."}', } ) def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) return UserAuthService.get_response(serializer) class LoginConfirmAPIView(generics.GenericAPIView): """ Endpoint для подтверждения номера и авторизации пользователя """ serializer_class = LoginConfirmationCodeSerializer @swagger_auto_schema( responses={ 200: LoginConfirmAPIViewResponseSerializer(), 400: 'It will return error type', 403: '{"message": "Неверный код"}', 404: '{"detail": "user not found"}', } ) def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) return PhoneConfirmationService.get_response(serializer) class SendSmsToOldPhoneAPIView(generics.GenericAPIView): """ Endpoint for send sms to old phone number """ permission_classes = (IsAuthenticated,) @swagger_auto_schema( manual_parameters=[auth_param], responses={ 200: '{"message": "Сообщение отправлено"}', 400: "It will return error type", 401: AuthErrorSerializer(), 429: '{"message": "Вы слишком часто отправляете сообщение."}', } ) def get(self, request, *args, **kwargs): user = request.user return UserAuthService.send_to_old_phone(user) class OldPhoneConfirmAPIView(generics.GenericAPIView): """ Endpoint для подтверждения old phone number """ permission_classes = (IsAuthenticated,) serializer_class = ConfirmationCodeSerializer @swagger_auto_schema( manual_parameters=[auth_param], responses={ 200: '{"message": "Old phone is confirmed"}', 400: 'It will return error type', 401: AuthErrorSerializer(), 403: '{"message": "Неверный код"}', } ) def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) user = request.user return PhoneConfirmationService.get_response_for_old_phone_confirmation(user, serializer) class ChangeOldPhoneAPIView(generics.GenericAPIView): """ Endpoint для смены old phone number """ permission_classes = (IsAuthenticated,) serializer_class = ChageOldPhoneSerializer @swagger_auto_schema( responses={ 200: '{"message": "Сообщение отправлено"}', 400: "It will return error type", 406: "{'message': 'Такой номер телефона уже существует'}", 429: '{"message": "Вы слишком часто отправляете сообщение."}', } ) def post(self, request, *args, **kwargs): serializer = self.serializer_class( data=request.data, context={'request': request} ) serializer.is_valid(raise_exception=True) return ChangeOldPhoneService.get_response(serializer) class NewPhoneConfirmAPIView(generics.GenericAPIView): """ Endpoint для подтверждения new phone number """ permission_classes = (IsAuthenticated,) serializer_class = ConfirmationCodeSerializer @swagger_auto_schema( manual_parameters=[auth_param], responses={ 200: '{"message": "New phone is confirmed"}', 400: 'It will return error type', 401: AuthErrorSerializer(), 403: '{"message": "Неверный код"}', } ) def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) user = request.user return ChangeOldPhoneService.get_response_for_new_phone_confirmation(user, serializer) class CityListAPIView(generics.ListAPIView): """Endpoint for get city list""" queryset = City.objects.all() serializer_class = CitySerializer class UserUpdateAPIView(AuthUpdateAPIView): """Endpoint for update user""" serializer_class = UserUpdateSerializer def get_object(self): return self.request.user def perform_update(self, serializer): user = serializer.save() User1cUpdateService.update_1c_user_id(user) class UserRetrieveAPIView(AuthRetrieveAPIView): """Endpoint for update user""" serializer_class = UserRetrieveSerializer def get_object(self): return self.request.user class UserAvatarRetrieveUpdateAPIView(AuthRetrieveAPIView, AuthUpdateAPIView, generics.DestroyAPIView): """Endpoint for update user image""" serializer_class = UserAvatarUpdateSerializer def get_object(self): return self.request.user def destroy(self, request, *args, **kwargs): instance = self.get_object() instance.avatar = None instance.save(update_fields=['avatar']) return Response(status=status.HTTP_204_NO_CONTENT)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,581
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/apps.py
from django.apps import AppConfig class CheckConfig(AppConfig): name = 'apps.check' verbose_name = 'Чек'
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,582
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/admin.py
from django.contrib import admin from apps.notifications.models import Notification @admin.register(Notification) class NotificationAdmin(admin.ModelAdmin): list_display = ['__str__', 'notice_type', 'user', 'is_viewed', 'is_active'] list_filter = ['user', 'notice_type', 'is_active'] fields = [ 'user', 'notice_type', 'linked_check', 'linked_article', 'is_viewed', 'is_active', 'is_on_credit', ] readonly_fields = [ 'user', 'notice_type', 'linked_check', 'linked_article', 'is_viewed', 'is_active', 'is_on_credit', ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,583
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/serializers.py
from drf_yasg.utils import swagger_serializer_method from rest_framework import serializers from apps.account.models import User, City from apps.account.service import ( UserAuthService, PhoneConfirmationService, ChangeOldPhoneService, ) from apps.integration.service import UserGetWalletDataService from apps.notifications.models import Notification from apps.setting.models import HelpPage from apps.setting.serializers import HelpPageSerializer class PhoneAuthSerializer(serializers.Serializer): """Сериалайзер для валидации и создания пользователя """ phone = serializers.CharField(required=True) def validate(self, data): self.user, self.created = ( UserAuthService.get_or_create_user_instance(phone_number=data.get('phone')) ) if not self.created: self.confirm_login_allowed(self.user) return data def validate_phone(self, value): UserAuthService.check_format_user_phone(value) return value @staticmethod def confirm_login_allowed(user): if not user.is_active: raise serializers.ValidationError({'phone': 'Этот номер не активен.'}) class ConfirmationCodeSerializer(serializers.Serializer): """Serializer for phone code confirmation""" confirmation_code = serializers.CharField(max_length=6, required=True) class LoginConfirmationCodeSerializer(PhoneAuthSerializer, ConfirmationCodeSerializer): """ Сериалайзер для login код подтверждения """ def validate(self, data): PhoneConfirmationService.check_is_user_exists(data.get('phone')) self.confirm_login_allowed(data.get('phone')) return data def validate_phone(self, value): super(LoginConfirmationCodeSerializer, self).validate_phone(value) PhoneConfirmationService.check_is_user_exists(value) return value @staticmethod def confirm_login_allowed(phone: str) -> None: if not User.objects.filter(phone=phone, is_active=True).exists(): raise serializers.ValidationError({'phone': 'Этот номер не активен.'}) class ChageOldPhoneSerializer(PhoneAuthSerializer): """ Сериалайзер для login код подтверждения """ def validate(self, data): request = self.context['request'] self.user = ( ChangeOldPhoneService.set_tmp_phone_number( phone_number=data.get('phone'), user=request.user, ) ) return data def validate_phone(self, value): return ChangeOldPhoneService.check_format_user_phone(value) class LoginConfirmAPIViewResponseSerializer(serializers.Serializer): token = serializers.CharField() is_profile_completed = serializers.BooleanField() class CitySerializer(serializers.ModelSerializer): class Meta: model = City fields = ['id', 'title'] class UserUpdateSerializer(serializers.ModelSerializer): class Meta: model = User fields = ['first_name', 'last_name', 'gender', 'birth_date', 'city'] extra_kwargs = { field: {'required': True} for field in fields } class UserAvatarUpdateSerializer(serializers.ModelSerializer): class Meta: model = User fields = ['avatar'] extra_kwargs = {'avatar': {'required': True}} class AuthErrorSerializer(serializers.Serializer): """ Error response on status.HTTP_401_UNAUTHORIZED """ detail = serializers.CharField(help_text='This is error text') class UserGetWalletSerializer(serializers.Serializer): """ Serializer for user wallet data """ discount = serializers.CharField(required=True) active_point = serializers.CharField(required=True) inactive_point = serializers.CharField(required=True) class UserRetrieveSerializer(serializers.ModelSerializer): city = serializers.SerializerMethodField() has_notification = serializers.SerializerMethodField() wallet = serializers.SerializerMethodField() help_page = serializers.SerializerMethodField() class Meta: model = User fields = [ 'first_name', 'phone', 'avatar', 'last_name', 'gender', 'birth_date', 'city', 'has_notification', 'wallet', 'help_page', ] @swagger_serializer_method(serializer_or_field=UserGetWalletSerializer) def get_wallet(self, obj): user_wallet_data = UserGetWalletDataService.update_user_wallet_data(obj) serializer = UserGetWalletSerializer(data=user_wallet_data) serializer.is_valid(raise_exception=True) return serializer.data @swagger_serializer_method(serializer_or_field=HelpPageSerializer) def get_help_page(self, obj): help_page_obj = HelpPage.objects.first() serializer = HelpPageSerializer(help_page_obj) return serializer.data def get_city(self, obj): return obj.city.title if obj.city else None def get_has_notification(self, obj): return Notification.objects.filter(user=obj, is_viewed=False).exists()
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,584
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/forms.py
from django import forms from django.core.exceptions import ValidationError from apps.brand.models import Filial class FilialForm(forms.ModelForm): class Meta: model = Filial fields = '__all__' def clean(self): super().clean() errors = {} start_work = self.cleaned_data['start_work'] end_work = self.cleaned_data['end_work'] is_around_the_clock = self.cleaned_data['is_around_the_clock'] if not (is_around_the_clock or (start_work and end_work)): errors['is_around_the_clock'] = ValidationError( 'Обязательно заполнить дату начала и конца рабочего времени' 'или указать как круглосуточно' ) if errors: raise ValidationError(errors)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,585
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/__init__.py
default_app_config = 'apps.setting.apps.SettingConfig'
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,586
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/tests/mymock.py
from rest_framework import status from rest_framework.response import Response from apps.account.tests import constants class SuccessSmsNikitaResponse: def __init__(self): self.status_code = status.HTTP_200_OK self.text = constants.SMS_NIKITA_TEXT_ON_200_WITH_RESPONSE_STATUS_11 class SuccessSmsNikitaInvalidStatusResponse: def __init__(self): self.status_code = status.HTTP_200_OK self.text = constants.SMS_NIKITA_TEXT_ON_200_WITH_INVALID_RESPONSE_STATUS
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,587
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/migrations/0005_helppage.py
# Generated by Django 2.2.16 on 2021-05-17 10:35 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('setting', '0004_auto_20210505_1513'), ] operations = [ migrations.CreateModel( name='HelpPage', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=50, verbose_name='Заголовок справки')), ('text', models.TextField(verbose_name='Текст справки')), ], options={ 'verbose_name': 'Справка', 'verbose_name_plural': 'Справки', }, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,588
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/custom_openapi.py
from drf_yasg import openapi from drf_yasg.utils import swagger_auto_schema from rest_framework import generics from rest_framework.permissions import IsAuthenticated from apps.account.serializers import AuthErrorSerializer auth_param = openapi.Parameter( 'Authorization', openapi.IN_HEADER, description='Token ...', type=openapi.TYPE_STRING ) class AuthUpdateAPIView(generics.UpdateAPIView): """UpdateAPIView for Authenticated endpoints""" permission_classes = (IsAuthenticated,) @swagger_auto_schema( manual_parameters=[auth_param], responses={ 401: AuthErrorSerializer(), 400: 'It will return error type', } ) def put(self, request, *args, **kwargs): return super(AuthUpdateAPIView, self).put(request, *args, **kwargs) @swagger_auto_schema( manual_parameters=[auth_param], responses={ 401: AuthErrorSerializer(), 400: 'It will return error type', } ) def patch(self, request, *args, **kwargs): return super(AuthUpdateAPIView, self).patch(request, *args, **kwargs) class AuthRetrieveAPIView(generics.RetrieveAPIView): """RetrieveAPIView for Authenticated endpoints""" permission_classes = (IsAuthenticated,) @swagger_auto_schema( manual_parameters=[auth_param], responses={ 401: AuthErrorSerializer(), } ) def get(self, request, *args, **kwargs): return super(AuthRetrieveAPIView, self).get(request, *args, **kwargs)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,589
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/migrations/0007_filial_unique_1c_filial_code.py
# Generated by Django 2.2.16 on 2021-04-12 11:38 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('brand', '0006_auto_20210407_1607'), ] operations = [ migrations.AddField( model_name='filial', name='unique_1c_filial_code', field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Уникальный 1C код филиала'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,590
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/models.py
from django.contrib.auth.models import AbstractUser, UserManager from django.db import models from django.db.models import Q, UniqueConstraint from core.constants import GENDER_TYPE, MALE from core.utils import generate_filename class CustomUserManager(UserManager): def _create_user(self, phone, password, **extra_fields): """ Create and save a user with the given phone, and password. """ if not phone: raise ValueError('The given username must be set') user = self.model(phone=phone, **extra_fields) user.set_password(password) user.save(using=self._db) return user def create_user(self, phone, password=None, **extra_fields): extra_fields.setdefault('is_staff', False) extra_fields.setdefault('is_superuser', False) return self._create_user(phone, password, **extra_fields) def create_superuser(self, phone, 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(phone, password, **extra_fields) class User(AbstractUser): username = None phone = models.CharField(max_length=25, unique=True, verbose_name='Телефон') avatar = models.ImageField( upload_to=generate_filename, null=True, blank=True, verbose_name='Аватар', ) tmp_phone = models.CharField( max_length=25, verbose_name='Временный телефон', null=True, blank=True, ) birth_date = models.DateField(null=True, verbose_name='Дата рождения',) gender = models.CharField( choices=GENDER_TYPE, default=MALE, max_length=10, verbose_name='Пол', ) city = models.ForeignKey( to='City', verbose_name='Город', null=True, on_delete=models.SET_NULL, related_name='users', ) active_point = models.PositiveIntegerField( default=0, verbose_name='Активные баллы', ) inactive_point = models.PositiveIntegerField( default=0, verbose_name='Неактивные баллы', ) discount = models.CharField( max_length=20, verbose_name='Скидка', ) qr_code = models.CharField( max_length=255, blank=True, null=True, verbose_name='QR-код', ) qr_code_updated_at = models.DateTimeField( blank=True, null=True, verbose_name='QR-код обновлен в', ) is_registration_finish = models.BooleanField( default=False, verbose_name='is_registration_finish', ) confirmation_code = models.CharField( verbose_name='confirmation code', max_length=6, null=True, blank=True, ) confirmation_date = models.DateTimeField( verbose_name='confirmation date', null=True, blank=True, ) is_old_phone_confirmed = models.BooleanField( verbose_name='is old phone confirmed', default=False, ) user_1C_code = models.CharField( max_length=255, null=True, blank=True, verbose_name='Уникальный 1С код пользователя' ) is_corporate_account = models.BooleanField( default=False, verbose_name='Корпоративный аккаунт?' ) objects = CustomUserManager() USERNAME_FIELD = 'phone' REQUIRED_FIELDS = [] class Meta: verbose_name = 'Пользователь' verbose_name_plural = 'Пользователи' constraints = [ UniqueConstraint( fields=['user_1C_code'], condition=~Q(user_1C_code=None), name='unique_user_1C_code_exp_null') ] def __str__(self): return f'{self.phone} {self.first_name}' class City(models.Model): title = models.CharField(max_length=200, verbose_name='Город') class Meta: verbose_name = 'Город' verbose_name_plural = 'Города' def __str__(self): return self.title
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,591
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/migrations/0002_auto_20210415_1834.py
# Generated by Django 2.2.16 on 2021-04-15 12:34 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('check', '0001_initial'), ] operations = [ migrations.AddField( model_name='check', name='filial_1c_code', field=models.CharField(max_length=255, null=True, verbose_name='Уникальный 1C код филиала'), ), migrations.AddField( model_name='check', name='user_1c_code', field=models.CharField(max_length=255, null=True, verbose_name='Уникальный 1C код пользователя'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,592
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/migrations/0002_auto_20210329_2332.py
# Generated by Django 2.2.16 on 2021-03-29 17:32 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('brand', '0001_initial'), ] operations = [ migrations.AlterField( model_name='brandimage', name='is_main', field=models.BooleanField(default=False, verbose_name='Основная?'), ), migrations.AlterField( model_name='filial', name='end_work', field=models.TimeField(blank=True, null=True, verbose_name='Конец рабочего времени'), ), migrations.AlterField( model_name='filial', name='start_work', field=models.TimeField(blank=True, null=True, verbose_name='Начало рабочего времени'), ), migrations.AlterField( model_name='filialimage', name='is_main', field=models.BooleanField(default=False, verbose_name='Основная?'), ), migrations.AlterField( model_name='filialphone', name='is_whatsapp', field=models.BooleanField(default=True, verbose_name='Номер Whatsapp?'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,593
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/integration/urls.py
from django.urls import path, include from apps.integration.views import ( Auth1cAPIView, GetUserAPIView, CreateCheckAPIView, UpdateCheckAPIView ) urlpatterns = [ path('user/', include([ path('login/', Auth1cAPIView.as_view(), name='login-1c'), path( '<str:qr_code>/', GetUserAPIView.as_view(), name='get_user_by_qr_code' ), ])), path('check/', include([ path('', CreateCheckAPIView.as_view(), name='create_check'), path( '<str:unique_1c_check_code>/', UpdateCheckAPIView.as_view(), name='update_check_view' ), ])), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,594
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/migrations/0002_auto_20210330_1214.py
# Generated by Django 2.2.16 on 2021-03-30 06:14 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('account', '0001_initial'), ] operations = [ migrations.AddField( model_name='user', name='confirmation_code', field=models.CharField(blank=True, max_length=6, null=True, verbose_name='confirmation code'), ), migrations.AddField( model_name='user', name='confirmation_date', field=models.DateTimeField(blank=True, null=True, verbose_name='confirmation date'), ), migrations.AddField( model_name='user', name='is_registration_finish', field=models.BooleanField(default=False, verbose_name='is_registration_finish'), ), migrations.AddField( model_name='user', name='tmp_phone', field=models.CharField(blank=True, max_length=25, null=True, verbose_name='Временный телефон'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,595
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/views.py
from rest_framework import generics from .models import AppVersion from .serializers import AppVersionSerializer class AppVersionAPIView(generics.RetrieveAPIView): """ API view for app version control """ queryset = AppVersion.objects.all() serializer_class = AppVersionSerializer def get_object(self): return self.get_queryset().first()
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,596
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/migrations/0001_initial.py
# Generated by Django 2.2 on 2021-03-29 07:58 import ckeditor_uploader.fields import core.utils from django.db import migrations, models import django.db.models.deletion import django_2gis_maps.fields class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Brand', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(blank=True, max_length=255, null=True, verbose_name='Название')), ('logo', models.ImageField(blank=True, null=True, upload_to=core.utils.generate_filename, verbose_name='Лого')), ('description', ckeditor_uploader.fields.RichTextUploadingField(verbose_name='Описание')), ('address', models.CharField(blank=True, max_length=50, null=True, verbose_name='Адрес')), ('link', models.URLField(blank=True, null=True, verbose_name='Ссылка')), ], options={ 'verbose_name': 'Бренд', 'verbose_name_plural': 'Бренды', }, ), migrations.CreateModel( name='Filial', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=255, verbose_name='Название')), ('address', django_2gis_maps.fields.AddressField(max_length=200, verbose_name='Адрес')), ('geolocation', django_2gis_maps.fields.GeoLocationField()), ('start_work', models.TimeField(auto_now_add=True, verbose_name='Начало рабочего времени')), ('end_work', models.TimeField(auto_now_add=True, verbose_name='Конец рабочего времени')), ('is_around_the_clock', models.BooleanField(default=False, verbose_name='Круглосуточно?')), ('description', ckeditor_uploader.fields.RichTextUploadingField(verbose_name='Описание')), ('link', models.URLField(blank=True, null=True, verbose_name='Ссылка')), ], options={ 'verbose_name': 'Филиал', 'verbose_name_plural': 'Филиалы', }, ), migrations.CreateModel( name='FilialPhone', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('phone', models.CharField(max_length=255, verbose_name='Номер телефона')), ('is_phone', models.BooleanField(default=True, verbose_name='Номер телефона?')), ('is_whatsapp', models.BooleanField(default=True, verbose_name='Номер Whatsapp')), ('filial', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='phone_numbers', to='brand.Filial', verbose_name='Филиал')), ], options={ 'verbose_name': 'Номер филиала', 'verbose_name_plural': 'Номера филиала', }, ), migrations.CreateModel( name='FilialImage', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('image', models.ImageField(upload_to=core.utils.generate_filename, verbose_name='Изображение')), ('is_main', models.BooleanField(default=False, verbose_name='Основная')), ('filial', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='brand.Filial', verbose_name='Филиал')), ], options={ 'verbose_name': 'Изображение филиала', 'verbose_name_plural': 'Изображения филиала', }, ), migrations.CreateModel( name='BrandImage', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('image', models.ImageField(upload_to=core.utils.generate_filename, verbose_name='Изображение')), ('is_main', models.BooleanField(default=False, verbose_name='Основная')), ('brand', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='brand.Brand', verbose_name='Бренд')), ], options={ 'verbose_name': 'Изображение бренда', 'verbose_name_plural': 'Изображения бренда', }, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,597
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/migrations/0003_auto_20210428_1419.py
# Generated by Django 2.2.16 on 2021-04-28 08:19 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('notifications', '0002_auto_20210428_1228'), ] operations = [ migrations.AlterField( model_name='notification', name='linked_article', field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notice', to='info.PromotionAndNews', verbose_name='Новость или Акция'), ), migrations.AlterField( model_name='notification', name='linked_check', field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='notice', to='check.Check', verbose_name='Чек'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,598
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/migrations/0004_auto_20210406_1501.py
# Generated by Django 2.2.16 on 2021-04-06 09:01 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('info', '0003_auto_20210331_1540'), ] operations = [ migrations.AlterModelOptions( name='promotionandnews', options={'ordering': ['-created_at'], 'verbose_name': 'Акция и новость', 'verbose_name_plural': 'Акции и новости'}, ), migrations.AlterModelOptions( name='promotionandnewsimage', options={'ordering': ['-is_main'], 'verbose_name': 'Фотография для акции/новости', 'verbose_name_plural': 'Фотографии для акций/новости'}, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,599
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/migrations/0003_auto_20210331_1540.py
# Generated by Django 2.2.16 on 2021-03-31 09:40 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('info', '0002_auto_20210329_1451'), ] operations = [ migrations.RenameField( model_name='promotionandnews', old_name='create_at', new_name='created_at', ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,600
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/serializers.py
from drf_yasg.utils import swagger_serializer_method from rest_framework import serializers from apps.brand.models import ( Brand, BrandImage, FilialImage, FilialPhone, Filial ) from apps.brand.service import FilialService, WorkDayService class BrandListSerializer(serializers.ModelSerializer): class Meta: model = Brand fields = ('id', 'logo') class BrandImageSerializer(serializers.ModelSerializer): class Meta: model = BrandImage fields = ('id', 'image') class BrandDetailSerializer(serializers.ModelSerializer): images = BrandImageSerializer(many=True, required=False) class Meta: model = Brand fields = ('title', 'description', 'address', 'link', 'images') class FilialImageSerializer(serializers.ModelSerializer): class Meta: model = FilialImage fields = ('id', 'image', 'is_main') class FilialPhoneSerializer(serializers.ModelSerializer): class Meta: model = FilialPhone fields = ('id', 'phone', 'is_phone', 'is_whatsapp') class GeolocationSerializer(serializers.Serializer): lat = serializers.FloatField() long = serializers.FloatField() class FilialSerializer(serializers.ModelSerializer): images = FilialImageSerializer(many=True, required=False) phone_numbers = FilialPhoneSerializer(many=True, required=False) is_filial_open = serializers.SerializerMethodField() distance = serializers.SerializerMethodField() geolocation = serializers.SerializerMethodField() week_days = serializers.SerializerMethodField() class Meta: model = Filial fields = ( 'title', 'address', 'geolocation', 'distance', 'images', 'phone_numbers', 'is_filial_open', 'week_days', ) def get_is_filial_open(self, obj) -> bool: return FilialService.check_filial_status(obj) def get_distance(self, obj) -> float: client_geolocation = self.context.get('client_geolocation') return FilialService.calculate_distance( filial_geolocation=obj.geolocation, client_geolocation=client_geolocation ) @swagger_serializer_method(serializer_or_field=serializers.ListField) def get_week_days(self, obj): data = WorkDayService.get_weekday(obj) return data @swagger_serializer_method(serializer_or_field=GeolocationSerializer) def get_geolocation(self, obj): if obj.geolocation: lat, long = tuple(map(float, obj.geolocation.split(','))) data = {'lat': lat, 'long': long} serializer = GeolocationSerializer(data=data) serializer.is_valid(raise_exception=True) return serializer.data return None class FilialListSerializer(serializers.ModelSerializer): image = serializers.SerializerMethodField() is_filial_open = serializers.SerializerMethodField() distance = serializers.SerializerMethodField() class Meta: model = Filial fields = ( 'position', 'id', 'title', 'address', 'distance', 'is_filial_open', 'image' ) @swagger_serializer_method(serializer_or_field=serializers.ImageField) def get_image(self, obj): image_obj = obj.images.all() request = self.context['request'] image_url = request.build_absolute_uri(image_obj[0].image.url) if image_obj else None return image_url def get_is_filial_open(self, obj) -> bool: return FilialService.check_filial_status(obj) def get_distance(self, obj) -> float: client_geolocation = self.context.get('client_geolocation') return FilialService.calculate_distance( filial_geolocation=obj.geolocation, client_geolocation=client_geolocation )
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,601
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/migrations/0010_auto_20210512_1145.py
# Generated by Django 2.2.16 on 2021-05-12 05:45 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('brand', '0009_auto_20210426_1104'), ] operations = [ migrations.AlterModelOptions( name='brand', options={'ordering': ['position'], 'verbose_name': 'Бренд', 'verbose_name_plural': 'Бренды'}, ), migrations.AddField( model_name='brand', name='position', field=models.PositiveIntegerField(default=0, verbose_name='№'), ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,602
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/migrations/0001_initial.py
# Generated by Django 2.2.16 on 2021-04-12 11:38 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ ('brand', '0007_filial_unique_1c_filial_code'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Check', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('unique_1c_check_code', models.CharField(max_length=255, unique=True, verbose_name='Уникальный 1C код чека')), ('money_paid', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='Оплачено деньгами')), ('bonus_paid', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='Оплачено бонусами')), ('total_paid', models.DecimalField(decimal_places=2, max_digits=8, verbose_name='Сумма оплаты')), ('accrued_point', models.PositiveIntegerField(blank=True, null=True, verbose_name='Начислено бонусов')), ('accrued_point_date', models.DateTimeField(blank=True, null=True, verbose_name='Дата начисления')), ('withdrawn_point', models.PositiveIntegerField(blank=True, null=True, verbose_name='Снято бонусов (Возврат)')), ('withdrawn_point_date', models.DateTimeField(blank=True, null=True, verbose_name='Дата возврата')), ('is_active', models.BooleanField(default=True, verbose_name='Активность чека')), ('filial', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='users', to='brand.Filial', verbose_name='Филиал')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='users', to=settings.AUTH_USER_MODEL, verbose_name='Пользователь')), ], options={ 'verbose_name': 'Чек', 'verbose_name_plural': 'Чеки', }, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,603
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/integration/service.py
import datetime import json import requests from requests.auth import HTTPBasicAuth from requests.exceptions import Timeout from django.conf import settings from django.utils import timezone from rest_framework import status, serializers, exceptions from rest_framework.authtoken.models import Token from rest_framework.response import Response from apps.account.models import User from apps.brand.models import Filial from apps.integration.serializers import Sync1cUserSerializer from apps.setting.models import Setting class User1cAuthService: @classmethod def get_response(cls, serializer) -> Response: """Method для login пользователя 1С""" user = serializer.user token = cls.create_or_refresh_user_token(user) from apps.integration.serializers import ( Login1cAPIViewResponseSerializer ) response = Login1cAPIViewResponseSerializer({ 'token': token.key, }).data return Response( response, status=status.HTTP_200_OK, ) @staticmethod def create_or_refresh_user_token(user: User) -> Token: token, created = Token.objects.get_or_create(user=user) return token class CreateCheckService: @classmethod def response_user_1c_code(cls, serializer, user): if cls.check_qr_code_expiration_date(user): return Response(serializer.data, status=status.HTTP_200_OK) else: return Response( {'message': 'Устарел QR код пользователя'}, status=status.HTTP_400_BAD_REQUEST ) @staticmethod def get_user_by_qr_code(qr_code): user = None if qr_code: try: user = User.objects.get(qr_code=qr_code) except User.DoesNotExist: pass return user @staticmethod def check_qr_code_expiration_date(user): setting = Setting.objects.first() exp_date_limit = ( setting.qr_code_expiration_date if setting else datetime.timedelta(minutes=3) ) return timezone.now() - user.qr_code_updated_at <= exp_date_limit @staticmethod def get_user_and_filial_from_serializer(validated_data): try: user = User.objects.get( user_1C_code=validated_data['user_1c_code'] ) except User.DoesNotExist: raise serializers.ValidationError( {'user_1c_code': 'Пользователь не найден'} ) try: filial = Filial.objects.get( filial_1c_code=validated_data['filial_1c_code'] ) except Filial.DoesNotExist: raise serializers.ValidationError( {'filial_1c_code': 'Филиал не найден'} ) return user, filial REQUEST_PARAMS = { "auth": HTTPBasicAuth(settings.USER_1C['username'], settings.USER_1C['password']), "headers": {'Content-Type': 'application/json'}, "timeout": 3 } class User1cUpdateService: @classmethod def update_1c_user_id(cls, user): serialized_user = Sync1cUserSerializer(user).data response = cls.send_user_to_1c(serialized_user) response_data = cls.check_response(response, user) user.user_1C_code = response_data['unique_1c_user_code'] user.save(update_fields=['user_1C_code']) @classmethod def check_response(cls, response, user): if response.status_code not in (200, 201): cls.clean_user_sign_up_data(user) raise exceptions.NotAcceptable( '1С сервер временно недоступен' ) response_data = json.loads(response.text) if not response_data.get('unique_1c_user_code'): cls.clean_user_sign_up_data(user) raise exceptions.ValidationError( 'Не верный формат данных из 1С сервера' ) return response_data @staticmethod def send_user_to_1c(data): try: response = requests.post( settings.LINKS_1C['SYNC_USER_URL'], data=json.dumps(data), **REQUEST_PARAMS ) except Timeout: raise exceptions.NotAcceptable( '1С сервер не отвечает' ) return response @staticmethod def clean_user_sign_up_data(user): user.first_name = '' user.last_name = '' user.birth_date = None user.city = None user.save(update_fields=[ 'first_name', 'last_name', 'birth_date', 'city' ]) class UserGetWalletDataService: @classmethod def update_user_wallet_data(cls, user): response_data = cls.get_user_wallet_data(user) return response_data @staticmethod def get_user_wallet_data(user): response_error_data = { "active_point": '-', "inactive_point": '-', "discount": '-' } try: response = requests.get( settings.LINKS_1C['GET_USER_WALLET_DATA_URL'], params={'unique_1c_user_code': user.user_1C_code}, **REQUEST_PARAMS ) except Timeout: return response_error_data if response.status_code not in (200, 201): return response_error_data response_data = json.loads(response.text) if hasattr(response_data, 'err_text'): return response_error_data return response_data class User1CNumberChangeService: @classmethod def sync_user_phone(cls, user): response = cls.send_user_phone(user) return cls.check_response(response) @staticmethod def send_user_phone(user): data = { 'new_phone': user.tmp_phone, 'unique_1c_user_code': user.user_1C_code, } try: response = requests.post( settings.LINKS_1C['CHANGE_USER_NUMBER'], data=json.dumps(data), **REQUEST_PARAMS ) except Timeout: raise exceptions.NotAcceptable( '1С сервер не отвечает' ) return response @classmethod def check_response(cls, response): if response.status_code != status.HTTP_200_OK: return False, 'Номер не изменен. 1C сервер не доступен' response_data = json.loads(response.text) response_is_not_success = ( hasattr(response_data, 'err_text') or not response_data.get('is_changed') ) if response_is_not_success: return False, 'Номер не изменен. Ошибка при синхронизации с 1C' return True, response_data
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,604
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/serializers.py
import datetime from rest_framework import serializers from drf_yasg.utils import swagger_serializer_method from apps.account.models import User from apps.brand.models import Filial from apps.brand.serializers import FilialImageSerializer from apps.check.models import Check from apps.setting.models import Setting from apps.notifications.models import Notification class QRCodeSerializer(serializers.ModelSerializer): """ Сериализатор для QR code Если не найден объект Setting или не указано exp date - по умолчанию 3 мин """ expiration_date = serializers.SerializerMethodField() def get_expiration_date(self, obj): setting = Setting.objects.first() if setting and setting.qr_code_expiration_date: return setting.qr_code_expiration_date return datetime.timedelta(minutes=3) class Meta: model = User fields = ('qr_code', 'expiration_date') extra_kwargs = { 'qr_code': {'required': True}, 'expiration_date': {'required': True}, } class FilialListCheckSerializer(serializers.ModelSerializer): class Meta: model = Filial fields = ('id', 'title', 'address') class FilialDetailCheckSerializer(serializers.ModelSerializer): images = FilialImageSerializer(many=True, required=False) class Meta: model = Filial fields = ('id', 'title', 'address', 'images') class CheckListSerializer(serializers.ModelSerializer): filial = FilialListCheckSerializer() class Meta: model = Check fields = ( 'id', 'filial', 'accrued_point', 'accrued_point_date', 'withdrawn_point', 'withdrawn_point_date', 'status' ) class CheckDetailSerializer(serializers.ModelSerializer): filial = FilialDetailCheckSerializer() badge_count = serializers.SerializerMethodField() class Meta: model = Check fields = ( 'id', 'filial', 'money_paid', 'bonus_paid', 'total_paid', 'accrued_point', 'accrued_point_date', 'withdrawn_point', 'withdrawn_point_date', 'is_active', 'status', 'is_on_credit', 'balance_owed', 'due_date', 'badge_count', ) @swagger_serializer_method(serializer_or_field=serializers.IntegerField) def get_badge_count(self, obj): user = self.context['request'].user count = Notification.objects.filter(user=user, is_viewed=False).count() return count
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,605
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/brand/migrations/0008_auto_20210415_1834.py
# Generated by Django 2.2.16 on 2021-04-15 12:34 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('brand', '0007_filial_unique_1c_filial_code'), ] operations = [ migrations.RenameField( model_name='filial', old_name='unique_1c_filial_code', new_name='filial_1c_code', ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,606
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/account/tests/factories.py
import factory from django.contrib.auth import get_user_model from apps.account.models import City User = get_user_model() class CityFactory(factory.django.DjangoModelFactory): class Meta: model = City title = factory.Faker('city') class UserFactory(factory.django.DjangoModelFactory): phone = factory.Sequence(lambda x: '+9967001112%02d' % x) is_registration_finish = False is_active = True first_name = factory.Faker('first_name') last_name = factory.Faker('last_name') birth_date = factory.Faker('date') city = factory.SubFactory(CityFactory) class Meta: model = User
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,607
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/tests/test_views.py
from django.urls import reverse from rest_framework import status from rest_framework.test import APITestCase from apps.info.models import ( Banner, ProgramCondition, Contact, PromotionAndNews, ) from .factories import ( BannerFactory, ProgramConditionFactory, ContactFactory, PromotionAndNewsImageFactory, PromotionAndNewsFactory, ) class BannerAndPromotionTest(APITestCase): def setUp(self) -> None: self.banner = BannerFactory() self.url = reverse('v1:banner-promotions') def test_get_banner(self) -> None: response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertIn(self.banner.title, response.data['banner']['title']) def test_get_banner_on_empty_db_table(self) -> None: Banner.objects.all().delete() response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data['banner'], None) self.assertEqual(response.data['promotion'], []) class BannerTest(APITestCase): def setUp(self) -> None: self.banner = BannerFactory() self.url = reverse('v1:banner-detail') def test_get_banner(self) -> None: response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertIn(response.data['title'], self.banner.title) self.assertIn( response.data['description'], self.banner.description ) def test_get_banner_on_empty_db_table(self) -> None: Banner.objects.all().delete() response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertIn(response.data['title'], '') self.assertIn( response.data['description'], '' ) class ProgramConditionTest(APITestCase): def setUp(self) -> None: self.program_condition = ProgramConditionFactory() self.url = reverse('v1:program_condition') def test_get_program_condition(self) -> None: response = self.client.get(self.url) expected_data = { 'id': 1, 'title': self.program_condition.title, 'description': self.program_condition.description } self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data, expected_data) def test_get_program_condition_on_empty_db_table(self) -> None: ProgramCondition.objects.all().delete() response = self.client.get(self.url) expected_data = { 'title': '', 'description': '', } self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data, expected_data) class TestContactListAPIView(APITestCase): def setUp(self) -> None: self.insta = ContactFactory() self.vk = ContactFactory() self.url = reverse('v1:contacts') def test_get_contacts(self) -> None: response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertIn(self.insta.title, response.data[0]['title']) self.assertIn(self.vk.title, response.data[1]['title']) def test_get_contacts_on_empty_db_table(self) -> None: Contact.objects.all().delete() response = self.client.get(self.url) expected_data = [] self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data, expected_data) class PromotionAndNewsListTest(APITestCase): def setUp(self) -> None: self.article = PromotionAndNewsImageFactory() self.url = reverse('v1:promotions-news') def test_get_promotion_and_news(self): response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual( self.article.information.title, response.data['results'][0]['title'] ) def test_get_promotions_news_list_on_empty_db_table(self): PromotionAndNews.objects.all().delete() response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data['results'], []) class PromotionAndNewsDetail(APITestCase): def setUp(self) -> None: self.article = PromotionAndNewsFactory() def test_get_promotions_and_news_detail(self): url = reverse('v1:promotions-news-detail', kwargs={'pk': self.article.id}) response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data['title'], self.article.title) def test_get_promotions_and_news_detail_on_empty_db_table(self): url = reverse('v1:promotions-news-detail', kwargs={'pk': 260}) response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) self.assertEqual(response.data['detail'], 'Страница не найдена.')
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,608
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/views.py
from rest_framework import generics from rest_framework.permissions import IsAuthenticated from apps.notifications.models import Notification from apps.notifications.pagination import LargeListNotificationPagination from apps.notifications.serializers import NotificationSerializer class NotificationAPIView(generics.ListAPIView): serializer_class = NotificationSerializer pagination_class = LargeListNotificationPagination permission_classes = (IsAuthenticated,) def get_queryset(self): queryset = ( Notification.objects.filter(is_active=True, user=self.request.user) ) return queryset
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,609
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/check/service.py
import uuid import datetime from apps.notifications.tasks import save_notification_and_send_fcm_for_check class QRCodeService: @staticmethod def generate_qr_code(): unique_code = uuid.uuid4().int return unique_code @classmethod def update_user_data(cls, user): user.qr_code = cls.generate_qr_code() user.qr_code_updated_at = datetime.datetime.now() user.save(update_fields=['qr_code', 'qr_code_updated_at']) return user class CheckNotificationService: @classmethod def send_notification(cls, check, user): body = { 'object_id': check.id, 'title': str(check.filial), 'status': check.status, 'accrued_point': check.accrued_point, 'withdrawn_point': check.withdrawn_point, } save_notification_and_send_fcm_for_check(body, user, check)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,610
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/serializers.py
from rest_framework import serializers from .models import AppVersion class AppVersionSerializer(serializers.ModelSerializer): class Meta: model = AppVersion fields = ( 'android_version', 'android_force_update', 'ios_build_number', 'ios_version', 'ios_force_update', ) class HelpPageSerializer(serializers.Serializer): """Serializer for help page""" title = serializers.CharField(required=True) text = serializers.CharField(required=True)
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,611
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/info/models.py
from datetime import datetime from django.db import models from solo.models import SingletonModel from ckeditor_uploader.fields import RichTextUploadingField from core.constants import INFORMATION_TYPE, NEWS from core.utils import generate_filename class Banner(SingletonModel): title = models.CharField( max_length=25, verbose_name='Заголовок баннера', ) image = models.ImageField( upload_to=generate_filename, verbose_name='Фото баннера', ) description = RichTextUploadingField( verbose_name='Описание баннера', ) class Meta: verbose_name_plural = 'Баннера' verbose_name = 'Баннер' def __str__(self): return f'{self.title}' class ProgramCondition(SingletonModel): title = models.CharField( max_length=50, verbose_name='Заголовок программы лояльности', ) description = RichTextUploadingField( verbose_name='Текст программы лояльности', ) class Meta: verbose_name_plural = 'Программы лояльности' verbose_name = 'Программа лояльности' def __str__(self): return f'{self.title}' class ContactIcon(models.Model): title = models.CharField(max_length=70, verbose_name='Заголовок иконки') image = models.ImageField( upload_to=generate_filename, verbose_name='Фото иконки для контактов', ) def __str__(self): return self.title class Meta: verbose_name = 'Иконка для контактов' verbose_name_plural = 'Иконки для контактов' class Contact(models.Model): icon_image = models.ForeignKey( 'ContactIcon', on_delete=models.CASCADE, related_name='contacts', verbose_name='Иконка', ) title = models.CharField( max_length=100, verbose_name='Заголовок ссылки', ) link = models.CharField( max_length=150, verbose_name='Ссылка', ) class Meta: verbose_name_plural = 'Контакты' verbose_name = 'Контакт' def __str__(self): return f'{self.title} {str(self.icon_image)}' class PromotionAndNews(models.Model): created_at = models.DateTimeField( default=datetime.now, verbose_name="Дата публикации", ) information_type = models.CharField( max_length=15, choices=INFORMATION_TYPE, default=NEWS, verbose_name='Тип записи', ) title = models.CharField( max_length=100, verbose_name='Заголовок', ) description = RichTextUploadingField( verbose_name='Текст статьи', ) is_active = models.BooleanField( default=True, verbose_name='Активный(Вкл/Выкл)', ) class Meta: verbose_name_plural = 'Акции и новости' verbose_name = 'Акция и новость' ordering = ['-created_at'] def __str__(self): return f'{self.title} {self.information_type}' class PromotionAndNewsImage(models.Model): image = models.ImageField( upload_to=generate_filename, verbose_name='Фото новости или акции', ) is_main = models.BooleanField( default=False, verbose_name='Превью(Вкл/Выкл)', ) information = models.ForeignKey( 'PromotionAndNews', on_delete=models.CASCADE, related_name="images" ) class Meta: verbose_name_plural = 'Фотографии для акций/новости' verbose_name = 'Фотография для акции/новости' ordering = ['-is_main']
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,612
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/core/settings/local.example.py
import environ from rest_framework import permissions env = environ.Env() SECRET_KEY = env.str('DJANGO_SECRET_KEY', default='not secret)') DEBUG = env.bool('DJANGO_DEBUG', default=True) DATABASES = { 'default': env.db( 'DATABASE_URL', default='sqlite:///db.sqlite' ) } ALLOWED_HOSTS = env.list('DJANGO_ALLOWED_HOSTS', default=['*']) if DEBUG: API_PERMISSION = permissions.AllowAny else: API_PERMISSION = permissions.IsAuthenticated INTERNAL_IPS = [ '127.0.0.1', ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,613
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/notifications/migrations/0001_initial.py
# Generated by Django 2.2.16 on 2021-04-21 09:24 from django.conf import settings import django.contrib.postgres.fields.jsonb 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), ] operations = [ migrations.CreateModel( name='Notification', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Создано')), ('updated_at', models.DateTimeField(auto_now=True, null=True, verbose_name='Обновлено')), ('notice_type', models.CharField(choices=[('bonus_accrued', 'Начислено бонусов'), ('bonus_paid', 'Снято бонусов'), ('bonus_withdraw', 'Снято бонусов неактивных'), ('promotion', 'Акции'), ('news', 'Новости')], max_length=25, verbose_name='Тип')), ('linked_object_id', models.CharField(blank=True, max_length=120, null=True, verbose_name='ID связанного объекта')), ('body', django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True, verbose_name='Тело')), ('is_viewed', models.BooleanField(default=False, verbose_name='Просмотрено?')), ('is_active', models.BooleanField(default=True, verbose_name='Активен?')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notifications', to=settings.AUTH_USER_MODEL, verbose_name='Пользователь')), ], options={ 'verbose_name': 'Уведомление', 'verbose_name_plural': 'Уведомления', 'ordering': ['-created_at'], }, ), ]
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,614
TimurAbdymazhinov/adeliya-backend
refs/heads/main
/apps/setting/tests/test_views.py
from django.urls import reverse from rest_framework import status from rest_framework.test import APITestCase from apps.setting.models import AppVersion from .factories import AppVersionFactory class AppVersionTest(APITestCase): def setUp(self) -> None: self.app_version = AppVersionFactory() self.url = reverse('v1:app-version') def test_get_app_version(self): response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(self.app_version.android_version, response.data['android_version']) def test_get_app_version_on_empty_db_table(self): AppVersion.objects.all().delete() response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual('', response.data['android_version'])
{"/apps/info/views.py": ["/apps/brand/pagination.py", "/core/constants.py", "/apps/info/models.py", "/apps/info/serializers.py", "/apps/notifications/service.py"], "/apps/notifications/serializers.py": ["/apps/notifications/models.py"], "/apps/brand/urls.py": ["/apps/brand/views.py"], "/apps/check/urls.py": ["/apps/check/views.py"], "/apps/account/urls.py": ["/apps/account/views.py"], "/apps/check/admin.py": ["/apps/check/models.py"], "/apps/info/migrations/0001_initial.py": ["/core/utils.py"], "/apps/setting/urls.py": ["/apps/setting/views.py"], "/apps/info/tests/factories.py": ["/apps/info/models.py", "/core/constants.py"], "/apps/brand/service.py": ["/apps/brand/models.py", "/core/constants.py"], "/apps/info/urls.py": ["/apps/info/views.py"], "/apps/brand/tests/test_views.py": ["/apps/brand/models.py"], "/apps/setting/tests/test_middleware.py": ["/apps/setting/tests/factories.py"], "/apps/brand/admin.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/check/models.py": ["/apps/account/models.py", "/apps/brand/models.py", "/core/constants.py"], "/apps/brand/models.py": ["/core/utils.py", "/core/constants.py"], "/apps/brand/migrations/0005_auto_20210405_1740.py": ["/core/utils.py"], "/apps/integration/views.py": ["/apps/check/models.py", "/apps/integration/serializers.py", "/apps/integration/service.py", "/apps/check/service.py"], "/apps/brand/tests/factories.py": ["/apps/brand/models.py"], "/apps/account/tests/test_views.py": ["/apps/account/service.py", "/apps/account/tests/factories.py", "/apps/account/tests/mymock.py", "/core/constants.py"], "/apps/info/admin.py": ["/apps/brand/admin.py", "/apps/info/models.py", "/apps/notifications/tasks.py"], "/apps/notifications/service.py": ["/core/constants.py", "/apps/check/models.py", "/apps/notifications/models.py", "/apps/notifications/tasks.py"], "/apps/check/tests/test_views.py": ["/apps/account/tests/factories.py"], "/apps/setting/middleware.py": ["/apps/setting/service.py"], "/apps/notifications/tasks.py": ["/apps/notifications/models.py", "/apps/notifications/service.py", "/core/constants.py", "/apps/account/models.py"], "/apps/check/filters.py": ["/apps/check/models.py"], "/apps/notifications/pagination.py": ["/apps/notifications/service.py"], "/apps/account/service.py": ["/apps/integration/service.py", "/apps/notifications/tasks.py", "/apps/account/serializers.py"], "/apps/setting/tests/factories.py": ["/apps/setting/models.py"], "/apps/check/views.py": ["/apps/account/custom_openapi.py", "/apps/account/serializers.py", "/apps/brand/pagination.py", "/apps/check/models.py", "/apps/check/serializers.py", "/apps/check/service.py", "/apps/check/filters.py", "/apps/notifications/service.py"], "/apps/info/serializers.py": ["/apps/info/models.py", "/apps/notifications/models.py"], "/apps/setting/admin.py": ["/apps/setting/models.py"], "/apps/setting/service.py": ["/apps/setting/models.py"], "/apps/notifications/urls.py": ["/apps/notifications/views.py"], "/apps/brand/views.py": ["/apps/brand/__init__.py", "/apps/brand/models.py", "/apps/brand/pagination.py", "/apps/brand/serializers.py", "/apps/brand/service.py"], "/apps/integration/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/check/models.py"], "/apps/notifications/models.py": ["/apps/account/models.py", "/core/constants.py", "/apps/setting/models.py"], "/apps/info/migrations/0006_auto_20210408_1352.py": ["/core/utils.py"], "/apps/account/views.py": ["/apps/account/custom_openapi.py", "/apps/account/models.py", "/apps/account/serializers.py", "/apps/account/service.py", "/apps/integration/service.py"], "/apps/notifications/admin.py": ["/apps/notifications/models.py"], "/apps/account/serializers.py": ["/apps/account/models.py", "/apps/account/service.py", "/apps/integration/service.py", "/apps/notifications/models.py", "/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/forms.py": ["/apps/brand/models.py"], "/apps/account/custom_openapi.py": ["/apps/account/serializers.py"], "/apps/account/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/integration/urls.py": ["/apps/integration/views.py"], "/apps/setting/views.py": ["/apps/setting/models.py", "/apps/setting/serializers.py"], "/apps/brand/migrations/0001_initial.py": ["/core/utils.py"], "/apps/brand/serializers.py": ["/apps/brand/models.py", "/apps/brand/service.py"], "/apps/integration/service.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/integration/serializers.py", "/apps/setting/models.py"], "/apps/check/serializers.py": ["/apps/account/models.py", "/apps/brand/models.py", "/apps/brand/serializers.py", "/apps/check/models.py", "/apps/setting/models.py", "/apps/notifications/models.py"], "/apps/account/tests/factories.py": ["/apps/account/models.py"], "/apps/info/tests/test_views.py": ["/apps/info/models.py", "/apps/info/tests/factories.py"], "/apps/notifications/views.py": ["/apps/notifications/models.py", "/apps/notifications/pagination.py", "/apps/notifications/serializers.py"], "/apps/check/service.py": ["/apps/notifications/tasks.py"], "/apps/setting/serializers.py": ["/apps/setting/models.py"], "/apps/info/models.py": ["/core/constants.py", "/core/utils.py"], "/apps/setting/tests/test_views.py": ["/apps/setting/models.py", "/apps/setting/tests/factories.py"]}
6,620
calarts/othertownsend
refs/heads/master
/_config.py.example.py
# RENAME THIS FILE TO _config.py AND PUT A REAL TELEGRAM TOKEN INSIDE # devothertowbsend # t.me/devothertowbsend_bot # TOKEN = "627805063:kpqwouepkjdlnasdmnlamsncv;lnsdc" # other.townsend # t.me/OtherTownsendBot # /setinline # /setuserpic TOKEN = "746808563:klsadlkjasldkjlaksjdlasd" DEBUG = True
{"/utils.py": ["/models.py", "/vars.py"], "/ticker.py": ["/models.py", "/vars.py", "/utils.py", "/commands.py"], "/commands.py": ["/models.py", "/utils.py"], "/api.py": ["/models.py", "/utils.py"]}
6,621
calarts/othertownsend
refs/heads/master
/vars.py
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # VARIABLES # from vars import heartratedata, sleepdata, timepointdata, stepdata, lookdata # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # heartratedata = "data/heartrate.json" # this is 24 hours of heart-rate sampled on average every 2.76 seconds # time has the format "19:14:00" "%H:%M:%S" # appears to be UTC/GMT! Do we wnt to transform to local time? YES # [{ # "time" : "08:00:07", # "value" : { # "bpm" : 78, # "confidence" : 2 # } # } sleepdata = "data/sleep.json" lookdata = "data/amazon.csv" timepointdata = "data/locations.csv" # Start Time,End Time,Name,Latitude,Longitude # lat/lng has been transformed and spoofed for Northern CA # ten days were compressed into one for variety. stepdata = "data/steps_monday.json" # datetime has the format "Tue 19:14:00" "%a %H:%M:%S" # appears to be UTC/GMT # [{ # "dateTime" : "Sat 08:03:00", # "value" : "0" # },
{"/utils.py": ["/models.py", "/vars.py"], "/ticker.py": ["/models.py", "/vars.py", "/utils.py", "/commands.py"], "/commands.py": ["/models.py", "/utils.py"], "/api.py": ["/models.py", "/utils.py"]}
6,622
calarts/othertownsend
refs/heads/master
/utils.py
import random from datetime import datetime import json, csv from shapely.geometry import Point from shapely.wkt import dumps, loads from models import Person, Heart, Place, Step, Look, Conversation from vars import heartratedata, sleepdata, timepointdata, stepdata, lookdata # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Utils # from utils import gimmeLongLat, gimmeGeojson, gimmeSeconds, random_line # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # from Knuth... def random_line(afile): line = next(afile) for num, aline in enumerate(afile, 2): if random.randrange(num): continue line = aline return line # Get a line: # with open("data/townsendtalk.txt") as f: # print(random_line(f)) def gimmeLongLat(stups): # ugh, must reverse lat and lng revtups = [] for tup in stups: revtups.append(tup[::-1]) return revtups def gimmeGeojson(atrip,myloc): feature_collection = [] # ugh, must reverse lat and lng revtups = gimmeLongLat(atrip) myline = LineString(revtups) mylocrev = Point( gimmeLongLat([myloc])[0] ) mylocrevfeature = Feature(geometry=mylocrev,name="my current point") mylinefeature = Feature(geometry=myline,name="my trip") feature_collection = [mylocrevfeature,mylinefeature] myfeaturecollection = FeatureCollection(feature_collection) return myfeaturecollection def gimmeSeconds(thetime="08:02:02", thefmt="%H:%M:%S", timeadjust=0): s = datetime.strptime(thetime, thefmt).second * 1 ms = datetime.strptime(thetime, thefmt).minute * 60 hs = datetime.strptime(thetime, thefmt).hour * 3600 if (timeadjust != 0): # timeadjust is set in hours correction = (timeadjust*360) utcsecs = int(s+ms+hs) # LAX is 7 hours behind UTC, -2520 seconds localsecs = (utcsecs-correction)% 86400 else: localsecs = int(s+ms+hs) return int(localsecs) def gimmecurseconds(): now = datetime.now() # should be local time! secs_since_midnight = (now - now.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds() return int(secs_since_midnight) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Build the Tables # from utils import createPersondb, createHeartdb, createPlacedb, createStepdb, CreateLookdb, createConversationdb # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # def createPersondb(mydb): try: other = Person.get(name='OTHER') created = False except: mydb.create_tables([Person]) other = Person.create( name='OTHER', telegram_id=123456789, created_at=datetime.now(), chat_name='othertownsend', first_name='Other', last_name="Townsend", login="othertownsend", language_code="en" ) created = True # telegram_id = BigIntegerField() # created_at = DateTimeField() # chat_name = CharField() # first_name = CharField() # last_name = CharField() # login = CharField() # language_code = CharField() print("Person table is ready and 'OTHER' was created", created) return other # Create the CONVERSATION table. # Run this ONLY ONE TIME IN PRODUCTION! def createConversationdb(mydb): try: print("The Conversation table has", len(Conversation), "entries and it's ready!") except: mydb.create_tables([Conversation]) print("Your new Conversation table is ready") def createHeartdb(mydb,other): with open(heartratedata, 'r') as f: json_text = f.read() heartrate_list = json.loads(json_text) for rec in heartrate_list: secs = gimmeSeconds(thetime=rec['time'], thefmt="%H:%M:%S", timeadjust=-7) bpm = rec['value']['bpm'] try: beats, created = Heart.get_or_create(actor=other, timestamp=secs, bpm=bpm) except: mydb.create_tables([Heart]) beats = Heart.create(actor=other, timestamp=secs, bpm=bpm) beats.save() print("Heart table is ready and 'beats' was created", created) def createPlacedb(mydb,other): with open(timepointdata, 'r') as csvfile: csvreader = csv.reader(csvfile) # This skips the first row of the CSV file. next(csvreader) for row in csvreader: mypoint = Point(float(row[3]), float(row[4])) try: tp, created = Place.get_or_create(actor=other, timestamp=gimmeSeconds(thetime=row[0], timeadjust=-7), point=dumps(mypoint), mode="WALK") except: mydb.create_tables([Place]) tp = Place.create(actor=other, timestamp=gimmeSeconds(thetime=row[0], timeadjust=-7), point=dumps(mypoint), mode="WALK") tp.save() print("Place table is ready and 'steps' was created", created) def createLookdb(mydb,other): with open(lookdata, 'r') as csvfile: csvreader = csv.reader(csvfile) # This skips the first row of the CSV file. next(csvreader) for row in csvreader: look = str(row[0]) link = str(row[1]) try: mylook, created = Look.get_or_create(actor=other,look=look,link=link) except: mydb.create_tables([Look]) mylook = Look.create(actor=other,look=look,link=link) mylook.save() print("Look table is ready and 'looks' was created", created) def createStepdb(mydb,other): with open(stepdata, 'r') as f: json_text = f.read() step_list = json.loads(json_text) for rec in step_list: secs = gimmeSeconds(rec['dateTime'], thefmt="%a %H:%M:%S", timeadjust=0) val = rec['value'] try: steps, created = Step.get_or_create(actor=other, timestamp=secs, steps=val) except: mydb.create_tables([Step]) steps = Step.create(actor=other, timestamp=secs, steps=val) steps.save() print("Step table is ready and 'steps' was created", created)
{"/utils.py": ["/models.py", "/vars.py"], "/ticker.py": ["/models.py", "/vars.py", "/utils.py", "/commands.py"], "/commands.py": ["/models.py", "/utils.py"], "/api.py": ["/models.py", "/utils.py"]}
6,623
calarts/othertownsend
refs/heads/master
/ticker.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # """ This Bot uses the Updater class to handle the bot and the JobQueue to send timed messages. First, a few handler functions are defined. Then, those functions are passed to the Dispatcher and registered at their respective places. Then, the bot is started and runs until we press Ctrl-C on the command line. Usage: Basic Alarm Bot example, sends a message after a set time. Press Ctrl-C on the command line or send a signal to the process to stop the bot. """ import logging import threading from datetime import datetime, date, timedelta, time import simplejson as json import csv, sys, os from random import choice from shapely.geometry import Point from shapely.wkt import dumps, loads from peewee import * from telegram.ext import Updater, CommandHandler, MessageHandler from telegram.ext import BaseFilter, Filters # buttons from telegram import InlineKeyboardButton, InlineKeyboardMarkup from telegram.ext import Updater, CommandHandler, CallbackQueryHandler from geojson import LineString, Feature, Point, FeatureCollection # import geojsonio from models import Person, Heart, Step, Conversation from vars import heartratedata, sleepdata, timepointdata, stepdata # from utils import gimmeLongLat, gimmeGeojson # from utils import gimmeSeconds, gimmecurseconds from utils import createPersondb, createHeartdb, random_line from utils import createPlacedb, createStepdb, createLookdb, createConversationdb # from commands import pulse, feeling, sleep, loc from commands import error, start, hidden from commands import alarm, set_timer, unset, shutdown, stop from _config import TOKEN, DEBUG # Enable logging logging.FileHandler('logs/tickererror.log') logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) timestr = datetime.now().strftime("%H:%M:%S") if DEBUG: mydb = SqliteDatabase(':memory:') else: mydb = SqliteDatabase("other.db") # # # # # # # # # # # # # # # # # # # # # # # # # # # create the tables and populate them if necessary # # # # # # # # # # # # # # # # # # # # # # # # # # createConversationdb(mydb) other = createPersondb(mydb) createHeartdb(mydb,other) createStepdb(mydb,other) createPlacedb(mydb,other) createLookdb(mydb,other) # You don't want to run these on every query! heartrate_keylist = [] q = Heart.select(Heart.timestamp) for t in q: heartrate_keylist.append( int(t.timestamp) ) # You don't want to run this on every query step_keylist = [] q = Step.select(Step.timestamp) for t in q: step_keylist.append( int(t.timestamp) ) # # # # # # # # # # # # # # # # # # # # # # # # # # # conversations # # # # # # # # # # # # # # # # # # # # # # # # # # # # Here's what's in a MESSAGE # { # 'message_id': 2497, # 'date': 1560323509, # 'chat': { # 'id': 730104154, # 'type': 'private', # 'username': 'dgoodwin', # 'first_name': 'Douglas', # 'last_name': 'Goodwin' # }, # 'text': 'are you recording this?', # 'entities': [], # 'caption_entities': [], # 'photo': [], # 'new_chat_members': [], # 'new_chat_photo': [], # 'delete_chat_photo': False, # 'group_chat_created': False, # 'supergroup_chat_created': False, # 'channel_chat_created': False, # 'from': { # 'id': 730104154, # 'first_name': 'Douglas', # 'is_bot': False, # 'last_name': 'Goodwin', # 'username': 'dgoodwin', # 'language_code': 'en' # } # } def reply_withgreeting(update, context): """reply with simple hallos""" with open("data/townsendtalk.txt") as f: rando = random_line(f) feelings = other.get_mymood() # this sets mood if other.mood == 1: replies = ["hi", "hey,", "what's up", "yo", "how you been", "I saw you here before,", "👋", "🤝", "🖐️", "🖖"] else: replies = ["👋", "👾", "yo", "🖐️", "k", "where you been", "dunno", "howdy"] # give the replies some variety if update.message.from_user.first_name: personalreply = str(update.message.from_user.first_name) else: personalreply = str(update.message.from_user.full_name) msg = choice(replies) +" "+ personalreply +"\r\n"+ rando update.message.reply_text(msg) def reply_withfeeling(update, context): """How do you feel?""" mypulse = other.gimmebeats(heartrate_keylist) feelings = other.get_mymood() # this sets mood if other.mood == 1: replies = ["Thanks for asking! I feel great. ", "I'm doing pretty well today, thanks! ", "Good, see for yourself. ", "What could go wrong with numbers like these? ", "Never better! ", "See for yourself! ", "Great! ", "Check me owwt! ", "Good, thanks. " ""] else: replies = ["Good! Why do you ask? ", "What do you think? ", "Maybe you can tell me? ", "Why do you want to know? ", "Who's asking? ", "ok, thanks. ", "Does it matter? ", "Why would I want to tell you? ", "Been better ", "Does it matter? " ""] # if update.message.from_user.first_name: # personalreply = "Hey " + str(update.message.from_user.first_name) + "!\n" # else: # personalreply = "Hi " + str(update.message.from_user.name) + ".\n" msg = choice(replies) + str(other.get_mymood()) + str(mypulse) + " BPM" update.message.reply_text(msg) def reply_withsleep(update, context): """How did you sleep?""" reply = other.get_mysleep() update.message.reply_text(reply) def reply_withphoto(update,context): """Where are you? Send a photo of a place.""" reply = other.get_personalreply(update,themeat=str(other.get_mymood())) imgs = ["media/37.64961_-122.45323.jpg", "media/37.7919_-122.4038.jpg", "media/37.914996_-122.533479.jpg" "media/37.74006_-121.95199.jpg", "media/37.880985_-122.526087.jpg", "media/37.927329_-122.580594.jpg", "media/37.77838_-122.389240.jpg", "media/37.905995_-122.554277.jpg"] update.message.reply_photo(photo=open(choice(imgs), 'rb')) def reply_withrandom(update,context): with open("data/townsendtalk.txt") as f: update.message.reply_text( random_line(f) ) def reply_withhtml(update,context): """What are you looking at?""" looklist = other.gimmecurrlooks() lk = choice(looklist) update.message.reply_html( str(lk) ) def recordconvo(message): """Record contact from humans and others""" fn = message.from_user.first_name or "" ln = message.from_user.last_name or "" lg = message.from_user.username or "" lc = message.from_user.language_code or "en" ti = message.from_user.id cn = message.from_user.name msg = message.text try: chatee = Person.get(Person.telegram_id == ti) except Person.DoesNotExist: chatee = Person.create( name=lg, login=lg, chat_name=cn, telegram_id=ti, created_at=datetime.now(), first_name=fn, last_name=ln, language_code=lc ) try: chatee.save() except: print("couldn't save this Chatee!",fn,ln,ti) convo = Conversation.create( actor=chatee, message=msg ) try: convo.save() except: print("couldn't save this Conversation!",chatee,msg) def button(update, context): query = update.callback_query query.edit_message_text(text="Selected option: {}".format(query.data)) def main(): # """Run bot.""" # Create the Updater and pass it your bot's token. # Make sure to set use_context=True to use the new context based callbacks # Post version 12 this will no longer be necessary updater = Updater(TOKEN, use_context=True) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Let's listen for specific questions: # ADD LOGGING to display on the Feather! # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # simple greetings class FilterGreetings(BaseFilter): def filter(self, message): amitrue = ('hi' in message.text or 'hey' in message.text or 'Hey' in message.text or 'Hey!' in message.text or 'Hello' in message.text or 'Hi' in message.text or 'Hi!' in message.text or 'Hello!' in message.text or 'howdy' in message.text or 'Yo!' in message.text or '👋' in message.text or '🖐️' in message.text ) return amitrue filter_greetings = FilterGreetings() greetings_handler = MessageHandler(filter_greetings, reply_withgreeting) # What are you looking at?? class FilterLook(BaseFilter): def filter(self, message): amitrue = ('looking' in message.text or 'look' in message.text or 'buy' in message.text) # this little hack will record all text messages if amitrue: recordconvo(message) else: recordconvo(message) return amitrue filter_look = FilterLook() look_handler = MessageHandler(filter_look, reply_withhtml) # Where are you? class FilterWhere(BaseFilter): def filter(self, message): amitrue = ('where' in message.text or 'Where' in message.text) return amitrue filter_where = FilterWhere() where_handler = MessageHandler(filter_where, reply_withphoto) # Many questions about feelings, same response # How are you feeling/How do you feel/How has your day been? (Mood, BPM) class FilterFeel(BaseFilter): def filter(self, message): amitrue = ('feel' in message.text or 'feeling' in message.text or 'been?' in message.text) return amitrue filter_feel = FilterFeel() feel_handler = MessageHandler(filter_feel, reply_withfeeling) # One question about sleep, same response # How did you sleep? (sleep) class FilterSleep(BaseFilter): def filter(self, message): amitrue = ('sleep' in message.text or 'Sleep' in message.text or 'Sleep?' in message.text or 'sleep?' in message.text) return amitrue filter_sleep = FilterSleep() sleep_handler = MessageHandler(filter_sleep, reply_withsleep) # Get the dispatcher to register handlers dp = updater.dispatcher # listening for "feelings" and "sleep" dp.add_handler(greetings_handler) dp.add_handler(feel_handler) dp.add_handler(sleep_handler) dp.add_handler(where_handler) dp.add_handler(look_handler) # on different commands - answer in Telegram dp.add_handler(CallbackQueryHandler(button)) dp.add_handler(CommandHandler("start", start)) dp.add_handler(CommandHandler("help", start)) dp.add_handler(CommandHandler("hidden", hidden)) dp.add_handler(CommandHandler("set", set_timer, pass_args=True, pass_job_queue=True, pass_chat_data=True)) dp.add_handler(CommandHandler("unset", unset, pass_chat_data=True)) # log all errors dp.add_error_handler(error) # add a stop handler # dp.add_handler(CommandHandler('stop', stop)) # dp.add_handler(CommandHandler('pulse', pulse, pass_chat_data=True)) # dp.add_handler(CommandHandler('loc', loc, pass_chat_data=True)) # dp.add_handler(CommandHandler('feeling', feeling, pass_chat_data=True)) # dp.add_handler(CommandHandler('sleep', sleep, pass_chat_data=True)) # Start the Bot updater.start_polling() # Block until you press Ctrl-C or the process receives SIGINT, SIGTERM or # SIGABRT. This should be used most of the time, since start_polling() is # non-blocking and will stop the bot gracefully. updater.idle() if __name__ == '__main__': main()
{"/utils.py": ["/models.py", "/vars.py"], "/ticker.py": ["/models.py", "/vars.py", "/utils.py", "/commands.py"], "/commands.py": ["/models.py", "/utils.py"], "/api.py": ["/models.py", "/utils.py"]}
6,624
calarts/othertownsend
refs/heads/master
/commands.py
import logging from datetime import datetime, date, timedelta, time from models import Person from utils import gimmeLongLat, gimmeGeojson # buttons from telegram import InlineKeyboardButton, InlineKeyboardMarkup from telegram.ext import Updater, CommandHandler, CallbackQueryHandler from models import Heart, Step # Enable logging logging.FileHandler('logs/tickererror.log') logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) other = Person.get(name='OTHER') timestr = datetime.now().strftime("%H:%M:%S") # You don't want to run these on every query! heartrate_keylist = [] q = Heart.select(Heart.timestamp) for t in q: heartrate_keylist.append( int(t.timestamp) ) # You don't want to run this on every query step_keylist = [] q = Step.select(Step.timestamp) for t in q: step_keylist.append( int(t.timestamp) ) # # # # # # # # # # # # # # # # # # # # # # # # # # # Define the command handlers. These usually take the two arguments bot and # update. Error handlers also receive the raised TelegramError object in error. # from commands import start, pulse, feeling, sleep, loc, alarm, set_timer, unset, shutdown, stop # # # # # # # # # # # # # # # # # # # # # # # # # # def start(update, context): mymsg = """Hi, I am the Other Townsend! Say 'hi" then ask me questions "How are you feeling?", "How did you sleep?", "Where are you?" and "What are you looking at?" """ update.message.reply_text(mymsg) def hidden(update, context): message = 'Please press the Help button for more instructions.' keyboard = [[InlineKeyboardButton("Option 1", callback_data='1'), InlineKeyboardButton("Option 2", callback_data='2')], [InlineKeyboardButton("Option 3", callback_data='3')]] reply_markup = InlineKeyboardMarkup(keyboard) update.message.reply_text('Please choose:', reply_markup=reply_markup) # def pulse(update, context): # """Gimme your current heart-rate""" # mypulse = other.gimmebeats(heartrate_keylist) # msg = "♥ " + str(mypulse) + " BPM ("+timestr+")️" # update.message.reply_text(msg) # def feeling(update, context): # """Gimme your current mood""" # mypulse = other.gimmebeats(heartrate_keylist) # msg = str(other.get_mymood()) + " ("+timestr+")️" # update.message.reply_text(msg) # def sleep(update, context): # """Gimme your current heart-rate""" # mypulse = other.gimmebeats(heartrate_keylist) # msg = str(other.get_mysleep()) + " ("+timestr+")️" # update.message.reply_text(msg) # def loc(update, context): # """Gimme your current location STUB""" # # hacky! -- get the first position on our trip # # you need to get the position in the duration # msg = other.gimmeclosestplace() # update.message.reply_text(msg) def alarm(context): """Send the alarm message.""" job = context.job mypulse = other.gimmebeats(heartrate_keylist) msg = str(other.get_mymood()) + str(other.get_mysleep()) + str(other.gimmeclosestplace()) + str(mypulse) + " BPM ("+ str(timestr) +")" context.bot.send_message(job.context, text=msg) def set_timer(update, context): """Add a job to the queue.""" chat_id = update.message.chat_id try: # args[0] should contain the time for the timer in seconds due = int(context.args[0]) if due < 0: update.message.reply_text('Sorry we can not go back to future!') return # Add job to queue # job = context.job_queue.run_once(alarm, due, context=chat_id) job = context.job_queue.run_repeating(alarm, due, context=chat_id) context.chat_data['job'] = job update.message.reply_text('👍') except (IndexError, ValueError): update.message.reply_text('Usage: /set <seconds>') def unset(update, context): """Remove the job if the user changed their mind.""" if 'job' not in context.chat_data: update.message.reply_text('You have no active timer') return job = context.chat_data['job'] job.schedule_removal() del context.chat_data['job'] update.message.reply_text('Timer successfully unset!') def error(update, context): """Log Errors caused by Updates.""" logger.warning('Update "%s" caused error "%s"', update, context.error) # context.bot.send_message(context, text='Update "%s" caused error "%s"', update, context.error) def shutdown(): # context.bot.send_message(job.context, text='Stopping...') updater.stop() updater.is_idle = False def stop(update, context): threading.Thread(target=shutdown).start()
{"/utils.py": ["/models.py", "/vars.py"], "/ticker.py": ["/models.py", "/vars.py", "/utils.py", "/commands.py"], "/commands.py": ["/models.py", "/utils.py"], "/api.py": ["/models.py", "/utils.py"]}
6,625
calarts/othertownsend
refs/heads/master
/api.py
from datetime import datetime from shapely.geometry import Point from shapely.wkt import dumps, loads from peewee import * from flask import Flask, Blueprint from flask_restplus import Resource, Api from models import Person, Heart, Place, Step, Look, Conversation from utils import gimmeLongLat, gimmeGeojson, gimmeSeconds from utils import gimmecurseconds heartrate_keylist = [] q = Heart.select(Heart.timestamp) for t in q: heartrate_keylist.append( int(t.timestamp) ) # You don't want to run this on every query step_keylist = [] q = Step.select(Step.timestamp) for t in q: step_keylist.append( int(t.timestamp) ) other = Person.get(name='OTHER') mood = other.get_mymood()[1] app = Flask(__name__) # set the base URL with a blueprint blueprint = Blueprint('api', __name__, url_prefix='/api') api = Api(blueprint) app.register_blueprint(blueprint) @api.route('/heartrate') class HeartRate(Resource): def get(self): timestr = datetime.now().strftime("%H:%M:%S") mypulse = other.gimmebeats(heartrate_keylist) return {'heartrate': mypulse, 'timestr': timestr} @api.route('/location') class CurrentLocation(Resource): def get(self): timestr = datetime.now().strftime("%H:%M:%S") mykey, myplace = other.gimmeclosestplace() return {'myplace': myplace, 'mykey': mykey, 'timestr': timestr} @api.route('/feelings') class CurrentFeelings(Resource): def get(self): timestr = datetime.now().strftime("%H:%M:%S") return {'feelings': str(other.get_mymood()), 'timestr': timestr} @api.route('/state') class CurrentState(Resource): """an aggregate of feelings prepared for ArduinoJson""" def get(self): timestr = datetime.now().strftime("%s") # we want a UNIX timestring mymood = "❤" # this seems to be legal mysleep = "--" # but this one gives you 0 or 1 if other.get_mymood()[1] == 1: mymood = "❤" else: mymood = "o" mylat,mylon= other.gimmeclosestpoint() return {'mymood': str(mymood), 'mood': other.get_mymood()[1], 'timestr': int(timestr), 'sleep': str(other.get_mysleep()), 'heartrate': other.gimmebeats(heartrate_keylist), 'steps': other.gimmecurrsteps(step_keylist), 'location': [mylat,mylon]} @api.route('/sleep') class SleepQuality(Resource): def get(self): timestr = datetime.now().strftime("%H:%M:%S") return {'sleep': str(other.get_mysleep()), 'timestr': timestr} @api.route('/conversations/-1') class LatestConversation(Resource): def get(self): convo = Conversation.select().order_by(Conversation.timestamp.desc()).get() myd = {'first_name': str(convo.actor.first_name), 'last_name': str(convo.actor.last_name), 'message': str(convo.message), 'timestamp': str(convo.timestamp) } return myd @api.route('/conversations') class MyConversations(Resource): def get(self): myconvos = [] query = (Conversation .select() .join(Person, on=(Conversation.actor == Person.id))) for convo in query: myd = {'first_name': str(convo.actor.first_name), 'last_name': str(convo.actor.last_name), 'message': str(convo.message), 'timestamp': str(convo.timestamp) } print(myd) myconvos.append(myd) return myconvos if __name__ == '__main__': app.run(debug=True)
{"/utils.py": ["/models.py", "/vars.py"], "/ticker.py": ["/models.py", "/vars.py", "/utils.py", "/commands.py"], "/commands.py": ["/models.py", "/utils.py"], "/api.py": ["/models.py", "/utils.py"]}
6,626
calarts/othertownsend
refs/heads/master
/models.py
from random import choice from datetime import time, datetime from peewee import * from shapely.wkt import dumps, loads from _config import DEBUG if DEBUG: mydb = SqliteDatabase(':memory:') else: mydb = SqliteDatabase("other.db") def gimmecurseconds(): now = datetime.now() # should be local time! secs_since_midnight = (now - now.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds() return int(secs_since_midnight) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # MODELS # from models import Person, Heart, Brain, Place, Step, Look, Conversation # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # class BaseModel(Model): class Meta: database = mydb class Person(BaseModel): name = CharField() telegram_id = BigIntegerField() created_at = DateTimeField() chat_name = CharField() first_name = CharField() last_name = CharField() login = CharField() language_code = CharField() def get_mytimepoints(self): return self.timepoints def get_myheartbeats(self): return self.heartbeats def get_myconversations(self): return self.conversations def get_personalreply(self,update,themeat): pleasentries = ['Hi', 'yawn', 'are you still here?' 'I was just getting back to it.', 'could you ask me in a few minutes?', "I'll sleep when I'm dead."] personalreply = "Hi again " + str(update.message.from_user.name) + "!\n" personalreply = personalreply + choice(pleasentries) personalreply = personalreply + themeat return personalreply def get_mymood(self,myday=int(datetime.today().day)): feels = ["💛","💜","💜","💛","💜","💜","💛", "💛","💛","💛","💛","💛","💜","💜", "💛","💜","💜","💛","💛","💜","💛", "💜","💛","💛","💜","💜","💛","💛", "💜","💛","💛","💛","💜","💛","💜"] self.feels = feels[myday] if self.feels == "💜": self.mood = 0 if self.feels == "💛": self.mood = 1 return self.feels, self.mood def get_mysleep(self,myday=int(datetime.today().day)): sleeps = ["--","~","--","--","--","--","~", "--","~","--","~","--","--","--", "--","--","--","~","--","--","--", "--","--","--","--","~","--","~", "--","~","--","--","--","--","--"] self.sleep = sleeps[myday] return self.sleep def gimmebeats(self,mykeys): # mykeys = set().union(*(d.keys() for d in alistofdicts)) mykey = min(mykeys, key=lambda x:abs(x - gimmecurseconds() )) q = Heart.select().where(Heart.timestamp == int(mykey)) for entry in q: self.mybpm = entry.bpm return self.mybpm def gimmecurrsteps(self,mykeys): mykey = min(mykeys, key=lambda x:abs(x - gimmecurseconds() )) q = Step.select().where(Step.timestamp == int(mykey)) for entry in q: self.mysteps = entry.steps return self.mysteps def gimmecurrlooks(self): looklist = [] for l in Look.select(): mystr = "<a href='%s'>%s</a>" %(l.link,l.look) looklist.append(mystr) self.looklist = looklist return self.looklist def gimmeclosestpoint(self): # mykeys = set().union(*(d.keys() for d in alistofdicts)) # get the keys by querying the places mykeys = [] q = Place.select() for entry in q: mykeys.append(int(entry.timestamp)) mykey = min(mykeys, key=lambda x:abs(x - gimmecurseconds() )) q = Place.select().where(Place.timestamp == int(mykey)) for entry in q: self.myplce = entry.point geom = loads(self.myplce) return geom.x, geom.y # (37.9609969049851, -122.404216421264) def gimmeclosestplace(self): # mykeys = set().union(*(d.keys() for d in alistofdicts)) # get the keys by querying the places mykeys = [] q = Place.select() for entry in q: mykeys.append(int(entry.timestamp)) mykey = min(mykeys, key=lambda x:abs(x - gimmecurseconds() )) q = Place.select().where(Place.timestamp == int(mykey)) for entry in q: self.myplce = entry.point return self.myplce class Conversation(BaseModel): # record conversations with users actor = ForeignKeyField(Person, backref='conversations') message = TextField() timestamp = DateTimeField(default=datetime.now) class Heart(BaseModel): actor = ForeignKeyField(Person, backref='heartbeats') timestamp = IntegerField() bpm = IntegerField() class Place(BaseModel): actor = ForeignKeyField(Person, backref='timepoints') timestamp = IntegerField() point = CharField() mode = CharField() def __repr__(self): return self.timestamp, self.mode, loads(self.point) class Step(BaseModel): # do we count steps individually # or count them in a 24 hour period? actor = ForeignKeyField(Person, backref='steps') steps = IntegerField() timestamp = IntegerField() class Look(BaseModel): # do we count steps individually # or count them in a 24 hour period? actor = ForeignKeyField(Person, backref='looks') look = CharField() link = CharField() # timestamp = IntegerField()
{"/utils.py": ["/models.py", "/vars.py"], "/ticker.py": ["/models.py", "/vars.py", "/utils.py", "/commands.py"], "/commands.py": ["/models.py", "/utils.py"], "/api.py": ["/models.py", "/utils.py"]}
6,627
yongduek/conv-ensemble-str
refs/heads/master
/utils/utils.py
# -*- coding: utf-8 -*- import functools import re import tensorflow as tf import inception_preprocessing class CharsetMapper(object): """A simple class to map tensor ids into strings. It works only when the character set is 1:1 mapping between individual characters and individual ids. Make sure you call tf.tables_initializer().run() as part of the init op. """ def __init__(self, filename, max_sequence_length=30, default_character='?', null_character=u'\u2591'): """Creates a lookup table. Args: charset: a dictionary with id-to-character mapping. """ self.null_character = null_character self.charset = self._read_charset(filename) self.max_sequence_length = max_sequence_length charset_array = self._dict_to_array(self.charset, default_character) mapping_strings = tf.constant(charset_array) self.table = tf.contrib.lookup.index_to_string_table_from_tensor( mapping=mapping_strings, default_value=default_character) self.invert_table = tf.contrib.lookup.index_table_from_tensor( mapping=mapping_strings) @property def num_charset(self): return len(self.charset) def get_text(self, ids): """ Returns a string corresponding to a sequence of character ids. Args: ids: a tensor with shape [batch_size, max_sequence_length] """ return tf.reduce_join( self.table.lookup(tf.to_int64(ids)), reduction_indices=1) def get_label(self, text, null_character=u'\u2591'): """ Returns the ids of the corresponding text, Args: text: a tensor with shape [batch_size, lexicon_size] and type string null_character: a unicode character used to replace '<null>' character. the default value is a light shade block '░'. """ batch_size = text.shape[0].value lexicon_size = text.shape[1].value text = tf.reshape(text, [-1]) sp_text = tf.string_split(text, delimiter='') sp_text = tf.sparse_reset_shape(sp_text, [batch_size*lexicon_size, self.max_sequence_length]) sp_text = tf.sparse_tensor_to_dense(sp_text, default_value=null_character) ids = self.invert_table.lookup(sp_text) ids = tf.reshape(ids, [batch_size, lexicon_size, self.max_sequence_length]) return tf.to_int32(ids) def _dict_to_array(self, id_to_char, default_character): num_char_classes = max(id_to_char.keys()) + 1 array = [default_character] * num_char_classes for k, v in id_to_char.iteritems(): array[k] = v return array def _read_charset(self, filename): """Reads a charset definition from a tab separated text file. charset file has to have format compatible with the FSNS dataset. Args: filename: a path to the charset file. Returns: a dictionary with keys equal to character codes and values - unicode characters. """ pattern = re.compile(r'(\d+)\t(.+)') charset = {} with tf.gfile.GFile(filename) as f: for i, line in enumerate(f): m = pattern.match(line) if m is None: tf.logging.warning('incorrect charset file. line #%d: %s', i, line) continue code = int(m.group(1)) char = m.group(2).decode('utf-8') if char == '<nul>': char = self.null_character charset[code] = char return charset def augment_image(image): """Augmentation the image with a random modification. Args: image: input Tensor image of rank 3, with the last dimension of size 3. Returns: Distorted Tensor image of the same shape. """ with tf.variable_scope('AugmentImage'): height = image.get_shape().dims[0].value width = image.get_shape().dims[1].value # Random crop cut from the street sign image, resized to the same size. # Assures that the crop is covers at least 0.8 area of the input image. bbox_begin, bbox_size, _ = tf.image.sample_distorted_bounding_box( tf.shape(image), bounding_boxes=tf.zeros([0, 0, 4]), min_object_covered=0.8, aspect_ratio_range=[0.8, 1.2], area_range=[0.8, 1.0], use_image_if_no_bounding_boxes=True) distorted_image = tf.slice(image, bbox_begin, bbox_size) # Randomly chooses one of the 4 interpolation methods distorted_image = inception_preprocessing.apply_with_random_selector( distorted_image, lambda x, method: tf.image.resize_images(x, [height, width], method), num_cases=4) distorted_image.set_shape([height, width, 3]) # Color distortion # TODO:incompatible with clip value in inception_preprocessing.distort_color distorted_image = inception_preprocessing.apply_with_random_selector( distorted_image, functools.partial( inception_preprocessing.distort_color, fast_mode=False), num_cases=4) distorted_image = tf.clip_by_value(distorted_image, -1.5, 1.5) return distorted_image
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,628
yongduek/conv-ensemble-str
refs/heads/master
/utils/hooks.py
""" Hooks used for learn.Experiment """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import abc import os import six import tensorflow as tf @six.add_metaclass(abc.ABCMeta) class Prediction(tf.train.SessionRunHook): """ Write predictions to file. """ def __init__(self, params, output_dir): self.params = params self.output_dir = output_dir def begin(self): # pylint: disable=attribute-defined-outside-init # fetch tensors self.predicted_text = tf.get_collection('prediction')[0]["predicted_text"] self.image_names = tf.get_collection('prediction')[0]["image_names"] # file handle file_name = "{}.log".format(self.params['dataset']['dataset_name']) file_name = os.path.join(self.output_dir, file_name) # log to file self.file = open(file_name, 'w') def before_run(self, _run_context): fetches = {} fetches["predicted_text"] = self.predicted_text fetches["image_names"] = self.image_names return tf.train.SessionRunArgs(fetches) def after_run(self, _run_context, run_values): predicted_text_batch = run_values.results["predicted_text"] image_name_batch = run_values.results["image_names"] assert len(predicted_text_batch) == len(image_name_batch) for i in range(len(predicted_text_batch)): image_name = image_name_batch[i] text = predicted_text_batch[i].decode('utf-8').replace(u'\u2591', '') text = text.encode("ascii") line = '{}, "{}"'.format(image_name, text) tf.logging.info(line) self.file.write(line + '\r\n') self.file.flush() def end(self, _session): # disable log to file self.file.close() @six.add_metaclass(abc.ABCMeta) class FalsePrediction(tf.train.SessionRunHook): """ Write false predictions to file. """ def __init__(self, params, output_dir): self.params = params self.output_dir = output_dir def begin(self): # pylint: disable=attribute-defined-outside-init # fetch tensors self.predicted_text = tf.get_collection('prediction')[0]["predicted_text"] self.gt_text = tf.get_collection('prediction')[0]["gt_text"] self.image_names = tf.get_collection('prediction')[0]["image_names"] self.predicted_mask = tf.get_collection('predicted_mask')[0] # file handle file_name = "{}-false.log".format(self.params['dataset']['dataset_name']) file_name = os.path.join(self.output_dir, file_name) # log to file self.file = open(file_name, 'w') self.file.write("image name, ground-truth text, predicted text\r\n") def before_run(self, _run_context): fetches = {} fetches["predicted_text"] = self.predicted_text fetches["gt_text"] = self.gt_text fetches["image_names"] = self.image_names fetches["predicted_mask"] = self.predicted_mask return tf.train.SessionRunArgs(fetches) def after_run(self, _run_context, run_values): predicted_text = run_values.results["predicted_text"] true_text = run_values.results["gt_text"] image_names = run_values.results["image_names"] predicted_mask = run_values.results["predicted_mask"] assert len(predicted_text) == len(image_names) assert len(true_text) == len(predicted_mask) for i in range(len(predicted_text)): if predicted_mask[i]: # true prediction continue image_name = image_names[i] pt_text = predicted_text[i].decode('utf-8').replace(u'\u2591', '') pt_text = pt_text.encode("ascii") gt_text = true_text[i].decode('utf-8').replace(u'\u2591', '') gt_text = gt_text.encode("ascii") line = '{}, {}, {}\r\n'.format(image_name, gt_text, pt_text) self.file.write(line) self.file.flush() def end(self, _session): # disable log to file self.file.close()
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,629
yongduek/conv-ensemble-str
refs/heads/master
/model/model.py
""" Top view model interface. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os import logging import yaml import numpy as np import tensorflow as tf from tensorflow.contrib.learn import ModeKeys from tensorflow.python.framework import ops from tensorflow.contrib.framework.python.framework import init_from_checkpoint from tensorflow.contrib.framework.python.framework import list_variables from tensorflow.contrib.framework.python.ops import get_variables_to_restore from tensorflow.contrib.seq2seq.python.ops.decoder import _transpose_batch_time from model.encoder_resnet import EncoderResnet from model.decoder_conv import DecoderConv from utils.utils import augment_image from utils.utils import CharsetMapper class Model(object): """ Top view model. """ def __init__(self, params, mode): # params self.params = params self.mode = mode # charset charset_file = os.path.join(self.params['dataset']['dataset_dir'], self.params['dataset']['charset_filename']) self.charset = CharsetMapper(charset_file, self.params['dataset']['max_sequence_length']) # endcoder and decoder self.encoder = EncoderResnet(params, mode) self.decoder = DecoderConv(params, mode, self.charset.num_charset) tf.logging.info("Model params in mode=%s", self.mode) tf.logging.info("\n%s", yaml.dump({"Model": self.params})) def __call__(self, features, labels): with tf.variable_scope('model'): # Pre-process features and labels tf.logging.info('Preprocess data.') features, labels = self._preprocess(features, labels) tf.logging.info('Create encoder.') encoder_output = self.encoder(features) tf.logging.info('Create decoder.') decoder_output = self.decoder(encoder_output, labels) if self.params['checkpoint']: self._restore_variables(self.params['checkpoint']) # loss is zero during eval loss = tf.zeros([]) train_op = None if self.mode == ModeKeys.TRAIN: tf.logging.info('Compute loss.') loss = self._compute_loss(decoder_output, labels) # TODO(Shancheng): gradient multipliers train_op = self._build_train_op(loss) tf.logging.info('Compute Statistics.') self._compute_statistics() if self.params['summary']: tf.logging.info('Create summaries.') self._create_summaries(decoder_output, features, labels) tf.logging.info('Create predictions.') predictions = self._create_predictions(decoder_output, features, labels) tf.logging.info('Model done.') return predictions, loss, train_op def _restore_variables(self, checkpoint): """ restore variables from checkpoint as much as possible """ checkpoint_variables_map = list_variables(checkpoint) valid_variable = lambda name: name.startswith('model/encoder') or \ name.startswith('model/decoder') checkpoint_variable_names = [name for (name, _) in checkpoint_variables_map if valid_variable(name)] variables = get_variables_to_restore() variable_names = [v.name.split(':')[0] for v in variables] assignment_map = {} for var in checkpoint_variable_names: if var in variable_names: assignment_map[var] = var init_from_checkpoint(checkpoint, assignment_map) def _preprocess(self, features, labels): """ Data augmentation and label process. """ with tf.variable_scope('preprocess'): with tf.variable_scope('image'): features['image_orig'] = features['image'] image = tf.image.convert_image_dtype(features['image_orig'], dtype=tf.float32) if self.mode == ModeKeys.TRAIN: images = tf.unstack(image) images = [augment_image(img) for img in images] image = tf.stack(images) image = tf.subtract(image, 0.5) image = tf.multiply(image, 2.0) features['image'] = image if labels is None: return features, None with tf.variable_scope('label'): # TODO(Shancheng): use start token and end token rather constant 0 # labels for decoder input labels['label_input'] = tf.concat([labels['label'][:, -1:], labels['label'][:, 0:-1]], axis=1) # from text length to training label length labels['length'] = tf.reshape(labels['length'], [-1]) labels['length'] = labels['length'] + 1 return features, labels def _build_train_op(self, loss, gradient_multipliers=None): """Creates the training operation""" # Creates the optimizer name = self.params["optimizer"] optimizer = tf.contrib.layers.OPTIMIZER_CLS_NAMES[name]( learning_rate=self.params["learning_rate"], **self.params["optimizer_params"]) train_op = tf.contrib.layers.optimize_loss( loss=loss, global_step=tf.contrib.framework.get_global_step(), learning_rate=self.params["learning_rate"], learning_rate_decay_fn=None, clip_gradients=self.params['clip_gradients'], optimizer=optimizer, gradient_multipliers=gradient_multipliers, summaries=["learning_rate", "loss", "gradients", "gradient_norm"]) return train_op def _create_predictions(self, decoder_output, features, labels=None): """Creates the dictionary of predictions that is returned by the model. """ with tf.name_scope("create_predictions"): predicted_ids = _transpose_batch_time(decoder_output.predicted_ids) predicted_text = self.charset.get_text(predicted_ids) attention_scores = decoder_output.attention_scores original_images = features["image_orig"] prediction = {"predicted_ids": predicted_ids, "predicted_text": predicted_text, "images": original_images, "attention_scores": attention_scores} if "name" in features: prediction["image_names"] = features['name'] if labels: gt_text = self.charset.get_text(labels["label"]) prediction["gt_text"] = gt_text tf.add_to_collection("prediction", prediction) return prediction def _create_summaries(self, decoder_output, features, labels=None): """Create summaries for tensorboard. """ with tf.name_scope("create_summaries"): max_outputs = self.params['max_outputs'] # input images image = features['image'] tf.summary.image(self._sname('image'), image, max_outputs) if self.mode == ModeKeys.TRAIN: image_orig = features['image_orig'] tf.summary.image(self._sname('image_orig'), image_orig, max_outputs) # ground-truth text if self.mode != ModeKeys.INFER: gt_text = self.charset.get_text(labels["label"][:max_outputs, :]) tf.summary.text(self._sname('text/gt'), gt_text) # predicted text predicted_ids = _transpose_batch_time(decoder_output.predicted_ids) predicted_ids = tf.to_int64(predicted_ids[:max_outputs, :]) predicted_text = self.charset.get_text(predicted_ids) tf.summary.text(self._sname('text/pt'), predicted_text) def add_attention_summary(att_scores, family='attention'): for att_score in att_scores: name = att_score.name.replace(":", "_") shape = tf.shape(att_score) # pylint: disable=invalid-name N, M, H, W = shape[0], shape[1], shape[2], shape[3] score = tf.reshape(att_score, [N, M * H, W]) score = tf.expand_dims(score, 3) tf.summary.image(name, score, max_outputs=max_outputs, family=family) def add_std_max_summary(tensors, family): for tensor in tensors: name = tensor.name.replace(":", "_") _, var = tf.nn.moments(tf.reshape(tensor, [-1]), [0]) tf.summary.scalar(name, tf.sqrt(var), family=family + "_std") max_value = tf.reduce_max(tensor) tf.summary.scalar(name, max_value, family=family + "_max") # attention scores [N, L, M, H, W] attention_scores = decoder_output.attention_scores # unstack layer attention_scores = tf.unstack(attention_scores, axis=1) add_attention_summary(attention_scores, 'attention') # weight weigths = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES) add_std_max_summary(weigths, 'weights') # conv1 and encoder output activation encoder_outputs = tf.get_collection('model/encoder/') add_std_max_summary(encoder_outputs, 'activation') # encoder activation encoder_outputs = tf.get_collection('model/encoder/resnet/_end_points') add_std_max_summary(encoder_outputs, 'activation') # decoder activation decoder_outputs = tf.get_collection('model/decoder') add_std_max_summary(decoder_outputs, 'activation') # TODO(Shancheng): use tensorflow loss interface def _compute_loss(self, decoder_output, labels): """Computes the loss for this model. """ with tf.name_scope("compute_loss"): language_logit = decoder_output.logits[0] attention_logit = decoder_output.logits[1] batch_size = self.params['dataset']['batch_size'] language_losses = self._cross_entropy_sequence_loss( logits=language_logit, targets=tf.transpose(labels["label"], [1, 0]), sequence_length=labels["length"]) attention_losses = self._cross_entropy_sequence_loss( logits=attention_logit, targets=tf.transpose(labels["label"], [1, 0]), sequence_length=labels["length"]) language_loss = tf.reduce_sum(language_losses) / batch_size attention_loss = tf.reduce_sum(attention_losses) / batch_size loss = language_loss + attention_loss return loss def _cross_entropy_sequence_loss(self, logits, targets, sequence_length): """Calculates the per-example cross-entropy loss for a sequence of logits and masks out all losses passed the sequence length. Args: logits: Logits of shape `[T, B, vocab_size]` targets: Target classes of shape `[T, B]` sequence_length: An int32 tensor of shape `[B]` corresponding to the length of each input Returns: A tensor of shape [T, B] that contains the loss per example, per time step. """ with tf.name_scope("cross_entropy_sequence_loss"): losses = tf.nn.sparse_softmax_cross_entropy_with_logits( logits=logits, labels=targets) # Mask out the losses we don't care about loss_mask = tf.sequence_mask( tf.to_int32(sequence_length), tf.to_int32(tf.shape(targets)[0])) losses = losses * tf.transpose(tf.to_float(loss_mask), [1, 0]) return losses def _compute_statistics(self): """ Compute parameter number and flops. """ # log to file output_dir = self.params['output_dir'] if not os.path.exists(output_dir): os.mkdir(output_dir) output_dir = os.path.join(output_dir, 'statistics.log') log = logging.getLogger('tensorflow') handle = logging.FileHandler(output_dir) log.addHandler(handle) # FLOPS encoder_flops, decoder_flops = 0, 0 encoder_count, decoder_count = 0, 0 graph = tf.get_default_graph() for operation in graph.get_operations(): flops = ops.get_stats_for_node_def(graph, operation.node_def, 'flops').value if flops is None: continue if operation.name.startswith('model/encoder'): # encoder encoder_flops += flops encoder_count += 1 tf.logging.info('encoder operation %s : %d', operation.name, flops) elif operation.name.startswith('model/decoder'): # decoder decoder_flops += flops decoder_count += 1 tf.logging.info('decoder operation %s : %d', operation.name, flops) else: # gradient pass tf.logging.info('flops of %d encoder tensor: %d', encoder_count, encoder_flops) tf.logging.info('flops of %d decoder tensor: %d', decoder_count, decoder_flops) tf.logging.info('flops of total %d tensor: %d', encoder_count + decoder_count, encoder_flops + decoder_flops) # parameters encoder_parameters, decoder_parameters = 0, 0 encoder_count, decoder_count = 0, 0 for var in tf.trainable_variables(): parameters = np.prod(var.get_shape().as_list()) if var.name.startswith('model/encoder'): # encoder encoder_parameters += parameters encoder_count += 1 tf.logging.info('encoder variable %s : %d', var.name, parameters) elif var.name.startswith('model/decoder'): # decoder decoder_parameters += parameters decoder_count += 1 tf.logging.info('decoder variable %s : %d', var.name, parameters) tf.logging.info('parameters of %d encoder tensor: %d', encoder_count, encoder_parameters) tf.logging.info('parameters of %d decoder tensor: %d', decoder_count, decoder_parameters) tf.logging.info('parameters of total %d tensor: %d', encoder_count + decoder_count, encoder_parameters + decoder_parameters) # disable log to file log.removeHandler(handle) def _sname(self, label): """ Utility. """ if self.mode == ModeKeys.TRAIN: prefix = 'train' elif self.mode == ModeKeys.EVAL: prefix = 'eval' else: prefix = 'infer' return '%s/%s' % (prefix, label)
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,630
yongduek/conv-ensemble-str
refs/heads/master
/train_eval.py
#!/usr/bin/env python # Copyright 2017 IIE, CAS. # Written by Shancheng Fang # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================= """Main script to run training and evaluation of models. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os import logging import tensorflow as tf from tensorflow.contrib.learn.python.learn import Experiment from tensorflow.contrib.learn.python.learn import learn_runner from tensorflow.contrib.learn.python.learn.estimators import run_config import config import datasets from model.model import Model from utils.hooks import Prediction, FalsePrediction from utils.metrics import sequence_accuracy, char_accuracy FLAGS = tf.flags.FLAGS config.define() def _create_dataset_params(): """Create dataset params """ dparams = { "dataset_name": FLAGS.dataset_name, "dataset_dir": FLAGS.dataset_dir, "batch_size": FLAGS.batch_size } if FLAGS.schedule == 'train': split_name = FLAGS.split_name or 'train' dparams.update({ 'shuffle': True, 'smaller_final_batch': False, 'num_epochs': None, 'split_name': split_name}) elif FLAGS.schedule == 'evaluate': split_name = FLAGS.split_name or 'test' dparams.update({ 'shuffle': False, 'smaller_final_batch': True, 'num_epochs': 1, 'split_name': split_name}) else: split_name = FLAGS.split_name or 'test' dparams.update({ 'shuffle': False, 'smaller_final_batch': False, 'num_epochs': None, 'split_name': split_name}) return dparams def _create_model_params(dataset): """Create model params """ mparams = { "optimizer": FLAGS.optimizer, "learning_rate": FLAGS.learning_rate, "clip_gradients": FLAGS.clip_gradients, "dataset": dataset.params, "optimizer_params": { "momentum": FLAGS.momentum, "use_nesterov": FLAGS.use_nesterov }, "summary": FLAGS.summary, "max_outputs": FLAGS.max_outputs, "beam_width": FLAGS.beam_width, "output_dir": FLAGS.output_dir, "checkpoint": FLAGS.checkpoint } return mparams def _create_hooks(mparams, output_dir): """Create hooks """ # Create training hooks train_hooks = [] # Create evaluating hooks and eval config eval_hooks = [] # Write prediction to file prediction_hook = Prediction(mparams, FLAGS.output_dir) eval_hooks.append(prediction_hook) # Write false prediction to file false_prediction_hook = FalsePrediction(mparams, FLAGS.output_dir) eval_hooks.append(false_prediction_hook) if FLAGS.schedule == 'continuous_eval': eval_output_dir = os.path.join(output_dir, 'eval_continuous') eval_hooks.append(tf.contrib.training.SummaryAtEndHook(eval_output_dir)) elif FLAGS.schedule == 'evaluate': # stop until data are exhausted FLAGS.eval_steps = None if FLAGS.debug: from tensorflow.python import debug as tf_debug debug_hook = tf_debug.LocalCLIDebugHook() train_hooks.append(debug_hook) eval_hooks.append(debug_hook) return train_hooks, eval_hooks def _create_experiment(output_dir): """ Creates a new Experiment instance. Args: output_dir: Output directory for model checkpoints and summaries. """ # Runconfig session_config = tf.ConfigProto(gpu_options=tf.GPUOptions( per_process_gpu_memory_fraction=FLAGS.gpu_memory_fraction, allow_growth=FLAGS.gpu_allow_growth)) estimator_config = run_config.RunConfig( session_config=session_config, gpu_memory_fraction=FLAGS.gpu_memory_fraction, tf_random_seed=FLAGS.tf_random_seed, log_step_count_steps=FLAGS.log_step, save_checkpoints_secs=FLAGS.save_checkpoints_secs, save_checkpoints_steps=FLAGS.save_checkpoints_steps, keep_checkpoint_max=FLAGS.keep_checkpoint_max, keep_checkpoint_every_n_hours=FLAGS.keep_checkpoint_every_n_hours) # Dataset mode = tf.contrib.learn.ModeKeys.TRAIN if FLAGS.schedule == 'train' \ else tf.contrib.learn.ModeKeys.EVAL dataset = datasets.create_dataset( def_dict=_create_dataset_params(), mode=mode, use_beam_search=FLAGS.beam_width) # Model function def model_fn(features, labels, params, mode): """Builds the model graph""" model = Model(params, mode) predictions, loss, train_op = model(features, labels) eval_metrics = { 'character': char_accuracy(predictions['predicted_ids'], labels['label']), 'sequence': sequence_accuracy(predictions['predicted_ids'], labels['label']) } return tf.estimator.EstimatorSpec( mode=mode, predictions=predictions, loss=loss, train_op=train_op, eval_metric_ops=eval_metrics) # Model parameters mparams = _create_model_params(dataset) # Estimator estimator = tf.estimator.Estimator( model_fn=model_fn, model_dir=output_dir, config=estimator_config, params=mparams) train_hooks, eval_hooks = _create_hooks(mparams, output_dir) if FLAGS.schedule != 'train': # log to file file_name = "{}-tensorflow.log".format(mparams['dataset']['dataset_name']) file_name = os.path.join(FLAGS.output_dir, file_name) log = logging.getLogger('tensorflow') handle = logging.FileHandler(file_name) log.addHandler(handle) return Experiment( estimator=estimator, train_input_fn=dataset.create_input_fn, eval_input_fn=dataset.create_input_fn, train_steps=FLAGS.train_steps, eval_steps=FLAGS.eval_steps, train_monitors=train_hooks, eval_hooks=eval_hooks, eval_delay_secs=0) def main(_argv): """Main function """ schedules = ['train', 'evaluate', 'continuous_eval'] assert FLAGS.schedule in schedules,\ "Only schedules: %s supported!"%(','.join(schedules)) learn_runner.run( experiment_fn=_create_experiment, output_dir=FLAGS.output_dir, schedule=FLAGS.schedule) if __name__ == "__main__": tf.logging.set_verbosity(tf.logging.INFO) tf.app.run()
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,631
yongduek/conv-ensemble-str
refs/heads/master
/utils/metrics.py
"""Quality metrics for the model.""" import tensorflow as tf def char_accuracy(predictions, labels, rej_char=0, streaming=True, ignore_case=True): """ Evaluate in character level. """ with tf.variable_scope('CharAccuracy'): predictions.get_shape().assert_is_compatible_with(labels.get_shape()) targets = tf.to_int32(labels) if ignore_case: predictions = _lower_to_captical_case(predictions) targets = _lower_to_captical_case(targets) const_rej_char = tf.fill(tf.shape(targets), rej_char) weights = tf.to_float(tf.not_equal(targets, const_rej_char)) correct_chars = tf.to_float(tf.equal(predictions, targets)) accuracy_per_example = tf.div( tf.reduce_sum(tf.multiply(correct_chars, weights), 1), tf.reduce_sum(weights, 1)) if streaming: streaming_mean = tf.contrib.metrics.streaming_mean(accuracy_per_example) return streaming_mean else: return tf.reduce_mean(accuracy_per_example) def sequence_accuracy(predictions, labels, streaming=True, ignore_case=True): """ Evaluate in word level. """ with tf.variable_scope('SequenceAccuracy'): predictions.get_shape().assert_is_compatible_with(labels.get_shape()) targets = tf.to_int32(labels) include_predictions = predictions if ignore_case: include_predictions = _lower_to_captical_case(include_predictions) targets = _lower_to_captical_case(targets) correct_chars = tf.to_float(tf.equal(include_predictions, targets)) correct_chars_counts = tf.cast( tf.reduce_sum(correct_chars, reduction_indices=[1]), dtype=tf.int32) target_length = targets.get_shape().dims[1].value target_chars_counts = tf.fill(tf.shape(correct_chars_counts), target_length) accuracy_per_example = tf.to_float( tf.equal(correct_chars_counts, target_chars_counts)) if streaming: streaming_mean = tf.contrib.metrics.streaming_mean(accuracy_per_example) tf.add_to_collection('predicted_mask', accuracy_per_example) return streaming_mean else: return tf.reduce_mean(accuracy_per_example) def _lower_to_captical_case(src): # ranks of src can be any low, high = 11, 62 space = (high - low + 1) / 2 mid_tf = tf.fill(tf.shape(src), high - space + 1) high_tf = tf.fill(tf.shape(src), high) mid_mask = tf.greater_equal(src, mid_tf) high_mask = tf.less_equal(src, high_tf) case_mask = tf.logical_and(mid_mask, high_mask) return tf.where(case_mask, src - space, src)
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,632
yongduek/conv-ensemble-str
refs/heads/master
/model/decoder_conv.py
"""Convoltuional decoder with attention and language ensemble. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import abc import collections import six import tensorflow as tf from tensorflow.contrib.learn import ModeKeys from tensorflow.contrib.seq2seq.python.ops.decoder import Decoder from tensorflow.contrib.seq2seq.python.ops.decoder import _transpose_batch_time from tensorflow.contrib.seq2seq.python.ops.decoder import dynamic_decode from tensorflow.contrib.layers.python.layers import initializers from tensorflow.contrib.layers import layer_norm from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from utils import beam_search DecoderOutput = collections.namedtuple( "DecoderOutput", ["logits", "predicted_ids", "attention_scores"] ) BeamDecoderOutput = collections.namedtuple( "BeamDecoderOutput", ["logits", "predicted_ids", "attention_scores", "log_probs", "scores", "beam_parent_ids"] ) DECODER_DEFUALT_PARAM = { "cnn_layers": 6, "cnn_hiddens": [512, 512, 512, 512, 512, 512], "cnn_kernel": 3, "position_embeddings": True, "nout_embed": 256, "embedding_dim": 512 } class DecoderConv(object): """ Main decoder class. """ def __init__(self, params, mode, num_charset): self.params = params self.params.update(DECODER_DEFUALT_PARAM) self.mode = mode self.num_charset = num_charset self.max_sequence_length = self.params['dataset']['max_sequence_length'] def __call__(self, encoder_output, labels): if self.mode == ModeKeys.TRAIN: with tf.variable_scope("decoder"): outputs = self.conv_decoder_train(encoder_output, labels) return outputs else: outputs, _, __ = self.conv_decoder_infer(encoder_output) return outputs def conv_decoder_train(self, encoder_output, labels): label_input = labels['label_input'] length = labels['length'] conv_block = ConvBlock(self.params, self.num_charset, is_training=True) next_layer = self.add_embedding(label_input, length) language, attention, att_scores = conv_block(encoder_output, next_layer) language_logit = _transpose_batch_time(language) attention_logit = _transpose_batch_time(attention) ensemble_logit = language_logit + attention_logit sample_ids = tf.cast(tf.argmax(ensemble_logit, axis=-1), tf.int32) return DecoderOutput(logits=(language_logit, attention_logit), predicted_ids=sample_ids, attention_scores=att_scores) def conv_decoder_infer(self, encoder_output): beam_decoder = BeamDecoder(self.params, self.mode, encoder_output, self.num_charset) # As tensorflow does not support initializing variable with tensor # in a loop or conditional beam_decoder.init_params_in_loop() tf.get_variable_scope().reuse_variables() outputs, final_state, final_sequence_lengths = dynamic_decode( decoder=beam_decoder, output_time_major=True, impute_finished=False, maximum_iterations=self.max_sequence_length, scope='decoder') return outputs, final_state, final_sequence_lengths def add_embedding(self, labels, length): """ Add embeddings for labels Args: labels: The labels with shape [N, T], where N is batch size and T s time steps. length: The length for time steps with shape [N] Returns: The embeded labels """ with tf.variable_scope("embedding"): # label embedding label_embedding = tf.get_variable( name="W", shape=[self.num_charset, self.params["embedding_dim"]], initializer=tf.random_normal_initializer(mean=0.0, stddev=1)) next_layer = tf.nn.embedding_lookup(label_embedding, labels) # position embedding if self.params["position_embeddings"]: position_embeding = tf.get_variable( name="W_pos", shape=[self.max_sequence_length, self.params["embedding_dim"]], initializer=tf.random_normal_initializer(mean=0.0, stddev=1)) # Replicate encodings for each element in the batch batch_size = tf.shape(length)[0] pe_batch = tf.tile([position_embeding], [batch_size, 1, 1]) # Mask out positions that are padded positions_mask = tf.sequence_mask( lengths=length, maxlen=self.max_sequence_length, dtype=tf.float32) positions_embed = pe_batch * tf.expand_dims(positions_mask, 2) next_layer = tf.add(next_layer, positions_embed) return next_layer @six.add_metaclass(abc.ABCMeta) class BeamDecoder(Decoder): """Decoder using beam search in eval and infer. """ def __init__(self, params, mode, encoder_outputs, num_charset): self.params = params self.mode = mode self.num_charset = num_charset self.max_sequence_length = self.params['dataset']['max_sequence_length'] self.initial_state = encoder_outputs self.fm_height = encoder_outputs.get_shape()[1] self.fm_width = encoder_outputs.get_shape()[2] # convolution net self.conv_block = ConvBlock(self.params, self.num_charset, is_training=False) # TODO(Shancheng): use start token and end token rather constant 0 self.start_token = 0 self.end_token = 0 # beam search config self.config = beam_search.BeamSearchConfig( beam_width=self.params['beam_width'], vocab_size=self.num_charset, eos_token=self.end_token, length_penalty_weight=1.0, choose_successors_fn=beam_search.choose_top_k) @property def batch_size(self): return self.params['beam_width'] @property def output_size(self): return BeamDecoderOutput( logits=tf.TensorShape([self.num_charset]), predicted_ids=tf.TensorShape([]), attention_scores=tf.TensorShape([self.params['cnn_layers'], self.fm_height, self.fm_width]), log_probs=tf.TensorShape([]), scores=tf.TensorShape([]), beam_parent_ids=tf.TensorShape([])) @property def output_dtype(self): return BeamDecoderOutput( logits=tf.float32, predicted_ids=tf.int32, attention_scores=tf.float32, log_probs=tf.float32, scores=tf.float32, beam_parent_ids=tf.int32) def initialize(self, name=None): finished = tf.tile([False], [self.params['beam_width']]) start_tokens_batch = tf.fill([self.params['beam_width']], self.start_token) first_inputs = self.add_embedding(start_tokens_batch, time=tf.constant(0)) zeros_padding = tf.zeros([self.params['beam_width'], self.max_sequence_length - 1, first_inputs.get_shape().as_list()[-1]]) first_inputs = tf.concat([first_inputs, zeros_padding], axis=1) beam_state = beam_search.create_initial_beam_state(self.config) encoder_output = tf.tile(self.initial_state, [self.params['beam_width'], 1, 1, 1]) return finished, first_inputs, (encoder_output, beam_state) def step(self, time, inputs, state, name=None): encoder_output, beam_state = state cur_inputs = inputs[:, 0:time + 1, :] zeros_padding = inputs[:, time + 2:, :] language, attention, scores = self.conv_block(encoder_output, cur_inputs) # TODO(Shancheng): now it is add operation logits = language + attention shape = logits.get_shape().as_list() logits = tf.reshape(logits, [-1, shape[-1]]) bs_output, beam_state = beam_search.beam_search_step( time_=time, logits=logits, beam_state=beam_state, config=self.config) finished, next_inputs = self.next_inputs(bs_output.predicted_ids, (time+1)) next_inputs = tf.reshape(next_inputs, [self.params['beam_width'], 1, inputs.get_shape().as_list()[-1]]) next_inputs = tf.concat([cur_inputs, next_inputs], axis=1) next_inputs = tf.concat([next_inputs, zeros_padding], axis=1) next_inputs.set_shape([self.params['beam_width'], self.max_sequence_length, inputs.get_shape().as_list()[-1]]) outputs = BeamDecoderOutput( logits=logits, predicted_ids=bs_output.predicted_ids, attention_scores=scores, log_probs=beam_state.log_probs, scores=bs_output.scores, beam_parent_ids=bs_output.beam_parent_ids) return outputs, (encoder_output, beam_state), next_inputs, finished def finalize(self, output, final_state, sequence_lengths): # Gather according to beam search result # now predicted_ids is [M, N/B] predicted_ids = beam_search.gather_tree(output.predicted_ids, output.beam_parent_ids) # TODO(Shancheng): pay attention beam_width = output.beam_parent_ids.get_shape().as_list() parent_ids = tf.concat([tf.zeros([1, beam_width[-1]], dtype=tf.int32), output.beam_parent_ids[:-1, :]], 0) # now logits is [M, N/B, C] logits = beam_search.gather_tree(output.logits, parent_ids) # now attention scores is [M, N/B, L, H, W] attention_scores = beam_search.gather_tree(output.attention_scores, parent_ids) # orginal length is the length of ungathered logits sequence_lengths = math_ops.not_equal(predicted_ids, self.end_token) sequence_lengths = tf.to_int32(sequence_lengths) sequence_lengths = tf.reduce_sum(sequence_lengths, axis=0) + 1 # choose the top score item predicted_ids = predicted_ids[:, 0:1] logits = logits[:, 0:1] attention_scores = attention_scores[:, 0:1] # mask out length = sequence_lengths[0] logits = logits[0:length, :] attention_scores = attention_scores[0:length, :] final_outputs = DecoderOutput( logits=self._padding(logits), predicted_ids=self._padding(predicted_ids), attention_scores=attention_scores) return final_outputs, final_state def add_embedding(self, labels, time): """ Add embedding in current time step. Args: labels: The labels with shape [beam_width,] or [beam_width,1] time: The time index Rreturn: The embeded labels """ with tf.variable_scope("embedding"): rank = len(labels.shape) assert rank == 1 or rank == 2, "labels must be rank 1 or 2" if rank == 1: labels = tf.expand_dims(labels, axis=1) # label embedding label_embedding = tf.get_variable( name="W", shape=[self.num_charset, self.params["embedding_dim"]], initializer=tf.random_normal_initializer(mean=0.0, stddev=1)) next_input = tf.nn.embedding_lookup(label_embedding, labels) # position embedding if self.params["position_embeddings"]: position_embeding = tf.get_variable( name="W_pos", shape=[self.max_sequence_length, self.params["embedding_dim"]], initializer=tf.random_normal_initializer(mean=0.0, stddev=1)) seq_pos_embed = position_embeding[time, :] seq_pos_embed = tf.reshape(seq_pos_embed, [1, 1, -1]) seq_pos_embed_batch = tf.tile(seq_pos_embed, [self.params['beam_width'], 1, 1]) next_input = tf.add(next_input, seq_pos_embed_batch) return next_input def next_inputs(self, sample_ids, time): def true_fn(): # If we're in the last time step finished = tf.fill(sample_ids.get_shape().as_list(), True) next_inputs = tf.zeros([self.params['beam_width'], 1, self.params["embedding_dim"]]) return finished, next_inputs def false_fn(): finished = math_ops.equal(sample_ids, self.end_token) all_finished = math_ops.reduce_all(finished) end_tokens = tf.tile([self.end_token], [self.params['beam_width']]) next_inputs = control_flow_ops.cond( all_finished, # If we're finished, the next_inputs value doesn't matter lambda: self.add_embedding(end_tokens, time), lambda: self.add_embedding(sample_ids, time)) return finished, next_inputs finished = (time >= self.max_sequence_length) return control_flow_ops.cond(finished, true_fn, false_fn) def init_params_in_loop(self): with tf.variable_scope("decoder"): _, initial_inputs, initial_state = self.initialize() enc_output, _ = initial_state # pylint: disable=attribute-defined-outside-init self.conv_block.is_init = True self.conv_block(enc_output, initial_inputs) self.conv_block.is_init = False def _padding(self, tensor): """ Pad output to max_sequence length, for example, paddings = [[0, pad_time],[0,0]] """ shape = tf.shape(tensor) pad_time = tf.expand_dims(self.max_sequence_length - shape[0], 0) zeros = tf.zeros_like(shape, dtype=shape.dtype) paddings = tf.concat([pad_time, zeros[1:]], 0) paddings = tf.stack([zeros, paddings], 1) return tf.pad(tensor, paddings) class ConvBlock(object): """Basic operation. """ def __init__(self, params, num_charset, is_training=True): self.num_charset = num_charset self.is_training = is_training self.params = params self.max_sequence_length = self.params['dataset']['max_sequence_length'] def __call__(self, encoder_output, input_embed): output_collection = tf.get_variable_scope().name next_layer = input_embed att_scores = [] # 1D convolution for layer_idx in range(self.params['cnn_layers']): with tf.variable_scope("conv" + str(layer_idx)): nout = self.params['cnn_hiddens'][layer_idx] # language module # special process here, first padd then conv, # because tf does not suport padding other than SAME and VALID kernal_width = self.params['cnn_kernel'] paddings = [[0, 0], [kernal_width - 1, kernal_width - 1], [0, 0]] language_layer = tf.pad(next_layer, paddings, "CONSTANT") # 1D convolution language_layer = self.conv1d_weightnorm( inputs=language_layer, out_dim=nout * 2, kernel_size=kernal_width, padding="VALID", output_collection=output_collection) # to avoid using future information language_layer = language_layer[:, 0:-kernal_width + 1, :] # add GLU language_layer = self.gated_linear_units(language_layer, output_collection) # shortcut and layer norm language_layer = language_layer + next_layer language_layer = layer_norm(language_layer, begin_norm_axis=2, scope='glu') # attention module att_out, att_score = self.make_attention(input_embed, encoder_output, next_layer, output_collection) # shortcut and layer norm attention_layer = att_out + next_layer attention_layer = layer_norm(attention_layer, begin_norm_axis=2, scope='attention') # TODO(Shancheng): now it is add operation next_layer = language_layer + attention_layer if self.is_training: tf.add_to_collection(output_collection, next_layer) att_scores.append(att_score) # shape=[layer_num, batch_size / beam_width, step, height, width] att_scores = tf.stack(att_scores) # shape=[batch_size / beam_width, layer_num, step, height, width] att_scores = tf.transpose(att_scores, [1, 0, 2, 3, 4]) language_logit, scores = self.create_logit(language_layer, att_scores, output_collection, "language_logit") attention_logit, scores = self.create_logit(attention_layer, att_scores, output_collection, "attention_logit") return language_logit, attention_logit, scores def create_logit(self, next_layer, att_scores, output_collection, scope): # output with tf.variable_scope(scope): if not self.is_training: # only keep the last time step # [N/B, M, C] --> [N/B, 1, C] next_layer = next_layer[:, -1:, :] # [N/B, L, M, H, W] --> [N/B, L, H, W] att_scores = att_scores[:, :, -1, :, :] next_layer = self.linear_mapping_weightnorm( next_layer, out_dim=self.params["nout_embed"], output_collection=output_collection) next_layer = layer_norm(next_layer, begin_norm_axis=2) next_layer = self.linear_mapping_weightnorm( next_layer, out_dim=self.num_charset, var_scope_name="liear_logits", output_collection=output_collection) return next_layer, att_scores def linear_mapping_weightnorm(self, inputs, out_dim, var_scope_name="linear", output_collection=None): with tf.variable_scope(var_scope_name): # pylint: disable=invalid-name input_shape = inputs.get_shape().as_list() # static shape. may has None # use weight normalization (Salimans & Kingma, 2016) w = g* v/2-norm(v) V = tf.get_variable( name='V', shape=[int(input_shape[-1]), out_dim], dtype=tf.float32, initializer=initializers.variance_scaling_initializer()) # V shape is M*N, V_norm shape is N V_norm = tf.norm(V.initialized_value(), axis=0) g = tf.get_variable('g', dtype=tf.float32, initializer=V_norm) # weightnorm bias is init zero b = tf.get_variable( name='b', shape=[out_dim], dtype=tf.float32, initializer=tf.zeros_initializer()) assert len(input_shape) == 3 if input_shape[0] is None: input_shape = tf.shape(inputs) inputs = tf.reshape(inputs, [-1, input_shape[-1]]) inputs = tf.matmul(inputs, V) inputs = tf.reshape(inputs, [input_shape[0], -1, out_dim]) # g/2-norm(v) scaler = tf.div(g, tf.norm(V, axis=0)) # x*v g/2-norm(v) + b inputs = tf.reshape(scaler, [1, out_dim]) * inputs + tf.reshape(b, [1, out_dim]) if self.is_training: tf.add_to_collection(output_collection, inputs) return inputs def conv1d_weightnorm(self, inputs, out_dim, kernel_size, padding="SAME", var_scope_name="conv1d", output_collection=None): with tf.variable_scope(var_scope_name): # pylint: disable=invalid-name in_dim = int(inputs.get_shape()[-1]) V = tf.get_variable( name='V', shape=[kernel_size, in_dim, out_dim], dtype=tf.float32, initializer=initializers.variance_scaling_initializer()) # V shape is M*N*k, V_norm shape is k V_norm = tf.norm(V.initialized_value(), axis=[0, 1]) g = tf.get_variable('g', dtype=tf.float32, initializer=V_norm) b = tf.get_variable( name='b', shape=[out_dim], dtype=tf.float32, initializer=tf.zeros_initializer()) # use weight normalization (Salimans & Kingma, 2016) W = tf.reshape(g, [1, 1, out_dim]) * tf.nn.l2_normalize(V, [0, 1]) inputs = tf.nn.conv1d(value=inputs, filters=W, stride=1, padding=padding) inputs = tf.nn.bias_add(inputs, b) if self.is_training: tf.add_to_collection(output_collection, inputs) return inputs def gated_linear_units(self, inputs, output_collection=None): input_shape = inputs.get_shape().as_list() assert len(input_shape) == 3 input_pass = inputs[:, :, 0:int(input_shape[2] / 2)] input_gate = inputs[:, :, int(input_shape[2] / 2):] input_gate = tf.sigmoid(input_gate) inputs = tf.multiply(input_pass, input_gate) if self.is_training: tf.add_to_collection(output_collection, inputs) return inputs def make_attention(self, target_embed, encoder_output, decoder_hidden, output_collection): with tf.variable_scope("attention"): embed_size = target_embed.get_shape().as_list()[-1] hidden_size = decoder_hidden.get_shape().as_list()[-1] decoder_rep = decoder_hidden + target_embed # character project to image decoder_rep = self.linear_mapping_weightnorm( decoder_rep, out_dim=embed_size, var_scope_name="linear_query", output_collection=output_collection) att_out, att_score = self.attention_score_pooling(decoder_rep, encoder_output) # image project to character att_out = self.linear_mapping_weightnorm( att_out, out_dim=hidden_size, var_scope_name="linear_out", output_collection=output_collection) return att_out, att_score def attention_score_pooling(self, dec_rep, encoder_output): # pylint: disable=invalid-name # static shape N, H, W, C = encoder_output.get_shape().as_list() # static shape in train, dynamic shape in infer N = N or tf.shape(dec_rep)[0] M = dec_rep.get_shape().as_list()[1] or tf.shape(dec_rep)[1] encoder_reshape = tf.reshape(encoder_output, [N, H * W, C]) # N*(H*W)*C # N*M*C ** N*(H*W)*C --> N*M*(H*W) att_score = tf.matmul(dec_rep, encoder_reshape, transpose_b=True) * tf.sqrt(1.0 / C) att_score = tf.transpose(att_score, [0, 2, 1]) # N*(H*W)*M att_score = tf.reshape(att_score, [N, H, W, M]) # N*H*W*M att_score = tf.pad(att_score, [[0, 0], [1, 1], [1, 1], [0, 0]], "SYMMETRIC") att_score = tf.nn.avg_pool(att_score, [1, 3, 3, 1], [1, 1, 1, 1], padding='VALID') # N*H*W*M att_score = tf.reshape(att_score, [N, H * W, M]) # N*(H*W)*M att_score = tf.transpose(att_score, [0, 2, 1]) # N*M*(H*W) att_score = tf.nn.softmax(att_score) # N*M*(H*W) # N*M*(H*W) ** N*(H*W)*C --> N*M*C att_out = tf.matmul(att_score, encoder_reshape) att_score = tf.reshape(att_score, [N, M, H, W]) return att_out, att_score def attention_score(self, dec_rep, encoder_output): # pylint: disable=invalid-name # static shape N, H, W, C = encoder_output.get_shape().as_list() # static shape in train, dynamic shape in infer N = N or tf.shape(dec_rep)[0] M = dec_rep.get_shape().as_list()[1] or tf.shape(dec_rep)[1] encoder_reshape = tf.reshape(encoder_output, [N, H * W, C]) # N*(H*W)*C # N*M*C ** N*(H*W)*C --> N*M*(H*W) att_score = tf.matmul(dec_rep, encoder_reshape, transpose_b=True) * tf.sqrt(1.0 / C) att_score = tf.nn.softmax(att_score) # N*M*(H*W) # N*M*(H*W) ** N*(H*W)*C --> N*M*C att_out = tf.matmul(att_score, encoder_reshape) att_score = tf.reshape(att_score, [N, M, H, W]) return att_out, att_score
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,633
yongduek/conv-ensemble-str
refs/heads/master
/config.py
# Copyright 2017 IIE, CAS. # Written by Shancheng Fang # ============================================================================== """Define flags are common for train_eval.py scripts.""" import tensorflow as tf def define(): """Define common flags.""" # yapf: disable tf.flags.DEFINE_string("output_dir", "/tmp/workdir", """The directory to write model checkpoints and summaries. If None, a local temporary directory is created.""") tf.flags.DEFINE_string("checkpoint", None, """checkpoint to restore variables""") tf.flags.DEFINE_boolean("debug", False, """use tfdbg to debug""") # Model config tf.flags.DEFINE_integer("beam_width", 5, """beam width. 0 for close beam search.""") # Model hyper parameters tf.flags.DEFINE_string("optimizer", "Momentum", """the optimizer to use""") tf.flags.DEFINE_float("learning_rate", 0.01, """learning rate""") tf.flags.DEFINE_float("clip_gradients", 20.0, """number of clipped gradients""") tf.flags.DEFINE_float("momentum", 0.9, """momentum value for the momentum optimizer if used""") tf.flags.DEFINE_boolean("use_nesterov", True, """use nesterov""") # Dataset config tf.flags.DEFINE_string("dataset_name", "MJSynth", """Name of the dataset. Supported: fsns""") tf.flags.DEFINE_string("dataset_dir", None, """Dataset root folder.""") tf.flags.DEFINE_string("split_name", None, """Name of the dataset split.""") tf.flags.DEFINE_integer("batch_size", 128, """Batch size used for training and evaluation.""") # Training and evaluating parameters tf.flags.DEFINE_string("schedule", "train", """Estimator function to call, defaults to continuous_train_and_eval for local run""") tf.flags.DEFINE_integer("train_steps", 1000000, """Maximum number of training steps to run. If None, train forever.""") tf.flags.DEFINE_integer("eval_steps", 500, "Run N steps evaluation.") # RunConfig Flags tf.flags.DEFINE_integer("tf_random_seed", None, """Random seed for TensorFlow initializers. Setting this value allows consistency between reruns.""") tf.flags.DEFINE_integer("save_checkpoints_secs", 900, """Save checkpoints every this many seconds. Can not be specified with save_checkpoints_steps.""") tf.flags.DEFINE_integer("save_checkpoints_steps", None, """Save checkpoints every this many steps. Can not be specified with save_checkpoints_secs.""") tf.flags.DEFINE_integer("keep_checkpoint_max", 5, """Maximum number of recent checkpoint files to keep. As new files are created, older files are deleted. If None or 0, all checkpoint files are kept.""") tf.flags.DEFINE_integer("keep_checkpoint_every_n_hours", 4, """In addition to keeping the most recent checkpoint files, keep one checkpoint file for every N hours of training.""") tf.flags.DEFINE_float("gpu_memory_fraction", 1.0, """Fraction of GPU memory used by the process on each GPU uniformly on the same machine.""") tf.flags.DEFINE_boolean("gpu_allow_growth", False, """Allow GPU memory allocation to grow dynamically.""") tf.flags.DEFINE_integer("log_step", 100, """log_step_count_steps""") # Summary config tf.flags.DEFINE_boolean("summary", True, """log to summary""") tf.flags.DEFINE_integer("max_outputs", 4, """the max outputs number to summary images and text in a batch""") # yapf: enable
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,634
yongduek/conv-ensemble-str
refs/heads/master
/tools/make_tfrecord_datasets.py
#!/usr/bin/env python """ A tool to convert mjsynth datasets to tfrecords datasets. """ import os import tensorflow as tf import cv2 import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt SPLITS = ['train', 'test', 'val'] ORIGINAL_DIR = '/home/data/Dataset/mjsynth' OUTPUT_DIR = '/home/data/Dataset/tf-data/tf-mjsynth' CHARSET = 'data/charset_size=63.txt' MAX_WORD_LENGTH = 30 NULL_CODE = 0 NORM_SIZE = (100, 32) FILE_NUM_LIMIT = 3000 def _bytes_feature(value): return tf.train.Feature(bytes_list=tf.train.BytesList(value=value)) def _int64_feature(value): return tf.train.Feature(int64_list=tf.train.Int64List(value=value)) def _get_charset(): charset_path = os.path.join(ORIGINAL_DIR, CHARSET) assert tf.gfile.Exists(charset_path), charset_path charset = {} with open(charset_path) as file: for line in file: value, key = line.split() charset[key] = value return charset def _get_label(text, charset): unpadded_label = [] for c in text: label = int(charset[c]) unpadded_label.append(label) label = [unpadded_label[i] if i < len(unpadded_label) else NULL_CODE for i in range(MAX_WORD_LENGTH)] return label, unpadded_label def _get_text(path): return path.split('_')[1].strip() def run(split, charset): annotation = os.path.join(ORIGINAL_DIR, 'annotation_%s.txt'%(split)) assert tf.gfile.Exists(annotation), annotation split_dir = os.path.join(OUTPUT_DIR, split) tf.gfile.MkDir(split_dir) with tf.Graph().as_default(): with tf.Session('') as sess: image_placeholder = tf.placeholder(tf.uint8) encoded_image = tf.image.encode_png(image_placeholder) with open(annotation, 'r') as file: lines = file.readlines() with open('/tmp/fsc-error.log', 'a') as efile: fold_index = 0 for index, line in enumerate(lines): image_name, word_label = line.split() split_name = os.path.splitext(os.path.split(image_name)[1])[0] text = _get_text(image_name) text_length = len(text) label, unpadded_label = _get_label(text, charset) image_path = os.path.join(ORIGINAL_DIR, image_name) try: image = plt.imread(image_path) image = cv2.resize(image, NORM_SIZE) width, height = image.shape[0:2] jpg_image = sess.run(encoded_image, feed_dict={image_placeholder:image}) example = tf.train.Example(features=tf.train.Features(feature={ 'image/encoded': _bytes_feature([jpg_image]), 'image/format': _bytes_feature(["PNG"]), 'image/class': _int64_feature(label), 'image/unpadded_class': _int64_feature(unpadded_label), 'image/text': _bytes_feature([text]), 'image/text_length': _int64_feature([text_length]), 'image/height': _int64_feature([height]), 'image/width': _int64_feature([width]), 'image/word_class': _int64_feature([int(word_label)]), 'image/name':_bytes_feature([split_name])})) if index % FILE_NUM_LIMIT == 0: fold_name = '%s-%04d'%(split, fold_index) fold_dir = os.path.join(split_dir, fold_name) tf.gfile.MkDir(fold_dir) fold_index += 1 tfrecords_filename = '%s.tfrecord'%(os.path.splitext(os.path.basename(image_name))[0]) tfrecords_filename = os.path.join(fold_dir, tfrecords_filename) print '[%.2f%%] Writing %s'%(100.0*index/len(lines), tfrecords_filename) writer = tf.python_io.TFRecordWriter(tfrecords_filename) writer.write(example.SerializeToString()) except IOError: message = 'bad image: %s\n'%image_path efile.write(message) efile.flush() except Exception as e: efile.write('something error:%s\n'%(e.message)) efile.flush() def main(): assert tf.gfile.Exists(ORIGINAL_DIR) if tf.gfile.Exists(OUTPUT_DIR): tf.gfile.DeleteRecursively(OUTPUT_DIR) tf.gfile.MkDir(OUTPUT_DIR) tf.gfile.Copy(os.path.join(ORIGINAL_DIR, CHARSET), os.path.join(OUTPUT_DIR, CHARSET)) charset = _get_charset() for split in SPLITS: run(split, charset) if __name__ == '__main__': main()
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,635
yongduek/conv-ensemble-str
refs/heads/master
/model/encoder_resnet.py
"""Residual encoder. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import tensorflow as tf from tensorflow.contrib.learn import ModeKeys from tensorflow.contrib import slim from tensorflow.contrib.slim.nets import resnet_utils from tensorflow.contrib import layers as layers_lib from tensorflow.contrib.framework.python.ops import arg_scope from model import resnet_v2 ENCODER_DEFUALT_PARAM = { "block_name": ["block1", "block2", "block3", "block4"], "base_depth": [16, 32, 64, 128], "num_units" : [2, 2, 2, 6], "stride" : [2, 1, 1, 1] } class EncoderResnet(object): """ Residual encoder using off-the-shelf interface. """ def __init__(self, params, mode): self.params = params self.mode = mode self.encoder_params = ENCODER_DEFUALT_PARAM def __call__(self, features): """ Define tf graph. """ inputs = features['image'] with tf.variable_scope('encoder') as vsc: with slim.arg_scope(resnet_v2.resnet_arg_scope()): # conv1 with arg_scope( [layers_lib.conv2d], activation_fn=None, normalizer_fn=None): net = resnet_utils.conv2d_same(inputs, 16, 5, stride=2, scope='conv1') tf.add_to_collection(vsc.original_name_scope, net) # resnet blocks blocks = [] for i in range(len(self.encoder_params['block_name'])): block = resnet_v2.resnet_v2_block( scope=self.encoder_params['block_name'][i], base_depth=self.encoder_params['base_depth'][i], num_units=self.encoder_params['num_units'][i], stride=self.encoder_params['stride'][i]) blocks.append(block) net, _ = resnet_v2.resnet_v2( net, blocks, is_training=(self.mode == ModeKeys.TRAIN), global_pool=False, output_stride=2, include_root_block=False, scope='resnet') tf.add_to_collection(vsc.original_name_scope, net) return net
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,636
yongduek/conv-ensemble-str
refs/heads/master
/demo.py
#!/usr/bin/env python # Copyright 2017-2018 IIE, CAS. # Written by Shancheng Fang # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================= """ A quick demo to recognize text. """ from __future__ import print_function import os import argparse import numpy as np import tensorflow as tf from PIL import Image from tensorflow.contrib.learn import ModeKeys from model.model import Model def main(): parser = argparse.ArgumentParser() parser.add_argument('--path', type=str, required=True, help='path to image file.') parser.add_argument('--checkpoint', type=str, default='data/model.ckpt', help='path to image file.') args = parser.parse_args() params = { 'checkpoint': args.checkpoint, 'dataset':{ 'dataset_dir': 'data', 'charset_filename': 'charset_size=63.txt', 'max_sequence_length': 30, }, 'beam_width': 1, 'summary': False } model = Model(params, ModeKeys.INFER) image = tf.placeholder(tf.uint8, (1, 32, 100, 3), name='image') predictions, _, _ = model({'image': image}, None) assert os.path.exists(args.path), '%s does not exists!' % args.path raw_image = Image.open(args.path).convert('RGB') raw_image = raw_image.resize((100, 32), Image.BILINEAR) raw_image = np.array(raw_image)[None, :] with tf.Session() as sess: sess.run(tf.global_variables_initializer()) sess.run(tf.tables_initializer()) predictions = sess.run(predictions, feed_dict={image: raw_image}) text = predictions['predicted_text'][0] print('%s: %s' % (args.path, text)) if __name__ == '__main__': main()
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,637
yongduek/conv-ensemble-str
refs/heads/master
/datasets.py
# Copyright 2017 IIE, CAS. # Written by Shancheng Fang # ============================================================================== """Define base dataset. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os import abc import sys import copy import six import tensorflow as tf from tensorflow.contrib.slim.python.slim.data import tfexample_decoder def create_dataset(def_dict, mode, use_beam_search): """Creates an Dataset object from a dictionary definition. Args: def_dict: A dictionary defining the input pipeline. It must have "dataset_name", "split_name" and "dataset_dir" that correspond to the class name and constructor parameters of an InputPipeline, respectively. mode: A value in tf.contrib.learn.ModeKeys use_beam_search: Whether to use beam search Returns: A Dataset object. """ if not "dataset_name" in def_dict: raise ValueError("Dataset definition must have a dataset_name property.") class_ = def_dict["dataset_name"] if not hasattr(sys.modules[__name__], class_): raise ValueError("Invalid Dataset class: {}".format(class_)) # TODO(Shancheng): to support batch_size > 1, # remove use_beam_search argument if mode != tf.contrib.learn.ModeKeys.TRAIN and use_beam_search: def_dict['batch_size'] = 1 dataset_class = getattr(sys.modules[__name__], class_) return dataset_class(params=def_dict, mode=mode) @six.add_metaclass(abc.ABCMeta) class Dataset(): """An abstract Dataset class. All datasets must inherit from this. This class defines how data is read, parsed, and separated into features and labels. """ def __init__(self, params, mode): self.mode = mode default_params = self._dataset_params() self.params = self._parse_params(params, default_params) @property def _params_template(self): """Params placeholder. """ return { 'dataset_name': None, 'dataset_dir': None, 'batch_size': None, 'splits': None, 'charset_filename': None, 'image_shape': None, 'max_sequence_length': None, 'null_code': None, 'shuffle': None, 'smaller_final_batch': None, 'num_epochs': None, 'split_name': None } def _dataset_params(self): """A abstract function implemented by subclass. """ raise NotImplementedError("Not implemented.") def _parse_params(self, params, default_params): """Parses parameter values to the types defined by the default parameters. Default parameters are used for missing values. """ # Cast parameters to correct types if params is None: params = {} result = copy.deepcopy(default_params) for key, value in params.items(): # If param is unknown, drop it to stay compatible with past versions if key not in default_params: raise ValueError("%s is not a valid model parameter" % key) # Param is a dictionary if isinstance(value, dict): default_dict = default_params[key] if not isinstance(default_dict, dict): raise ValueError("%s should not be a dictionary", key) if default_dict: value = self._parse_params(value, default_dict) else: # If the default is an empty dict we do not typecheck it # and assume it's done downstream pass if value is None: continue if default_params[key] is None: result[key] = value else: result[key] = type(default_params[key])(value) return result def _read_from_data_provider(self, data_provider): """Utility function to read all available items from a DataProvider. """ list_items = set(data_provider.list_items()) assert self.items.issubset(list_items), \ "items are unavailable in data_provider!" item_values = data_provider.get(list(self.items)) items_dict = dict(zip(self.items, item_values)) return items_dict def _make_data_provider(self, **kwargs): """Create data provider """ split_name = self.params['split_name'] if split_name not in self.params['splits']: raise ValueError('split name %s was not recognized.' % split_name) decoder = tfexample_decoder.TFExampleDecoder(self.keys_to_features, self.items_to_handlers) file_pattern = os.path.join(self.params['dataset_dir'], self.params['splits'][split_name]) tf.logging.info("Create dataset.") dataset = tf.contrib.slim.dataset.Dataset( data_sources=file_pattern, reader=tf.TFRecordReader, decoder=decoder, num_samples=None, items_to_descriptions={}) return tf.contrib.slim.dataset_data_provider.DatasetDataProvider( dataset=dataset, shuffle=self.params["shuffle"], num_epochs=self.params["num_epochs"], **kwargs) def create_input_fn(self): """Creates an input function that can be used with tf.learn estimators. Note that you must pass "factory funcitons" for both the data provider and featurizer to ensure that everything will be created in the same graph. """ with tf.variable_scope("input_fn"): batch_size = self.params['batch_size'] data_provider = self._make_data_provider() features_and_labels = self._read_from_data_provider(data_provider) tf.logging.info("Start batch queue.") batch = tf.train.batch( tensors=features_and_labels, enqueue_many=False, batch_size=batch_size, dynamic_pad=True, capacity=3000 + 16 * batch_size, allow_smaller_final_batch=self.params['smaller_final_batch'], name="batch_queue", num_threads=int((batch_size+1)/2) ) # Separate features and labels features_batch = {k: batch[k] for k in self.feature_keys} if set(batch.keys()).intersection(self.label_keys): labels_batch = {k: batch[k] for k in self.label_keys} else: labels_batch = None return features_batch, labels_batch @property def keys_to_features(self): """Key to features """ default = { 'image/encoded': tf.FixedLenFeature((), tf.string, default_value=''), 'image/format': tf.FixedLenFeature((), tf.string, default_value='jpeg'), 'image/text_length': tf.FixedLenFeature([1], tf.int64, default_value=tf.zeros([1], dtype=tf.int64)), 'image/class': tf.FixedLenFeature([self.params['max_sequence_length']], tf.int64), 'image/text': tf.FixedLenFeature([1], tf.string, default_value=''), 'image/name': tf.FixedLenFeature((), tf.string, default_value='') } return default @property def items_to_handlers(self): """Items to handlers """ default = { 'image': tfexample_decoder.Image( shape=self.params['image_shape'], image_key='image/encoded', format_key='image/format'), 'label': tfexample_decoder.Tensor(tensor_key='image/class'), 'text': tfexample_decoder.Tensor(tensor_key='image/text'), 'length': tfexample_decoder.Tensor(tensor_key='image/text_length'), 'name': tfexample_decoder.Tensor(tensor_key='image/name') } return default @property def items(self): """items """ return self.feature_keys.union(self.label_keys) @property def feature_keys(self): """Only image and name supported. """ return set(["image", "name"]) @property def label_keys(self): """Only label and length supported. """ return set(["label", "length"]) class MJSynth(Dataset): """Training dataset. """ def _dataset_params(self): dataset_params = { 'dataset_name': 'MJSynth', 'dataset_dir': '/opt/fsc/tf-mjsynth', 'batch_size': 64, 'splits': { 'train': 'train/train-*/*.tfrecord', 'test': 'test/test-*/*.tfrecord', 'validation': 'val/val-*/*.tfrecord' }, 'charset_filename': 'charset_size=63.txt', 'image_shape': (32, 100, 3), 'max_sequence_length': 30, 'null_code': 0, } default_params = self._params_template default_params.update(dataset_params) return default_params
{"/model/model.py": ["/model/encoder_resnet.py", "/model/decoder_conv.py", "/utils/utils.py"], "/train_eval.py": ["/config.py", "/datasets.py", "/model/model.py", "/utils/hooks.py", "/utils/metrics.py"], "/demo.py": ["/model/model.py"]}
6,638
Tasha-Carty-220/asvs
refs/heads/master
/projects/views.py
from django.shortcuts import render, redirect from django.contrib.auth.decorators import login_required from django.http import HttpResponse from .models import Projects import json import hashlib from django.conf import settings from django.core.files import File import os def load_json_file(level): results = [] with open('common/asvs.json') as f: data = json.load(f) for r in data['requirements']: bob = 'L{0}'.format(level) if r.get(bob): results.append(r) return results def create_template(requirements, project): # delete all the levels out of the requirements as not needed in the template # for r in requirements: # del r['levels'] # r['enabled'] = 0 # build the template with project information and requirements data = {} data['project_owner'] = project['project_owner'] data['project_name'] = project['project_name'] data['project_id'] = project['id'] data['project_description'] = project['project_description'] data['project_created'] = project['project_created'].isoformat() data['project_level'] = project['project_level'] data['requirements'] = requirements phash = (hashlib.md5('{0}{1}'.format( project['project_owner'], project['id']).encode('utf-8')).hexdigest()) with open('storage/{0}.json'.format(phash), 'w') as output: project_file = File(output) json.dump(data, project_file, indent=2) project_file.close() return def load_template(phash): with open('storage/{0}.json'.format(phash), 'r') as template: data = json.load(template) template.close() return data def update_template(phash, data): with open('storage/{0}.json'.format(phash), 'w') as template: json.dump(data, template, indent=2) template.close() return def calculate_completion(requirements): total = len(requirements) enabled = 0 for r in requirements: if r.get('enabled') and r['enabled'] > 0: enabled += 1 else: pass percentage = enabled / total * 100 return {'total': total, 'enabled': enabled, 'percentage': '{0:.1f}'.format(percentage)} @login_required def project_all(request): projects = Projects.objects.filter( project_owner=request.user.username).values() return render(request, 'projects/manage.html', {'projects': projects}) @login_required def project_add(request): if request.method == 'POST': # Create the database record project_name = request.POST.get('project_name') project_owner = request.user.username project_description = request.POST.get('project_description') project_level = request.POST.get('project_level') p = Projects(project_name=project_name, project_owner=project_owner, project_description=project_description, project_level=project_level) p.save() # Build the template controls = load_json_file(project_level) project = Projects.objects.filter( project_owner=request.user.username, project_name=project_name).values()[0] create_template(controls, project) return redirect('projectsmanage') @login_required def project_delete(request, projectid): Projects.objects.filter( project_owner=request.user.username, pk=projectid).delete() phash = (hashlib.md5('{0}{1}'.format( request.user.username, projectid).encode('utf-8')).hexdigest()) os.remove('storage/{0}.json'.format(phash)) return redirect('projectsmanage') @login_required def project_view(request, projectid): phash = (hashlib.md5('{0}{1}'.format( request.user.username, projectid).encode('utf-8')).hexdigest()) project = load_template(phash) if project['project_owner'] == request.user.username: percentage = calculate_completion(project['requirements']) return render(request, "projects/view.html", {'data': project['requirements'], 'project': project, 'percentage': percentage}) @login_required def project_update(request): if request.method == 'POST': phash = (hashlib.md5('{0}{1}'.format(request.user.username, request.POST.get( 'projectid')).encode('utf-8')).hexdigest()) project = load_template(phash) for k, v in request.POST.items(): if 'csrfmiddlewaretoken' in k or 'projectid' in k: pass else: for r in project['requirements']: if r['Item'] in k: if int(v) == 0: r['enabled'] = 0 else: r['enabled'] = 1 update_template(phash, project) return redirect('projectsview', projectid=request.POST.get('projectid')) @login_required def project_download(request, projectid): phash = (hashlib.md5('{0}{1}'.format( request.user.username, projectid).encode('utf-8')).hexdigest()) filename = 'storage/{0}.json'.format(phash) with open(filename, 'rb') as fh: response = HttpResponse( fh.read(), content_type="application/json") response['Content-Disposition'] = 'inline; filename=' + \ os.path.basename(filename) return response
{"/projects/urls.py": ["/projects/views.py"]}
6,639
Tasha-Carty-220/asvs
refs/heads/master
/accountauth/urls.py
# Basic setup for allowing users to sign up using a username and a password from django.conf.urls import url from django.contrib.auth.views import LoginView, LogoutView from .views import signup urlpatterns = [ url(r'^signup/$', signup, name='signup'), url(r'login$', LoginView.as_view( template_name="auth/login.html"), name="login"), url(r'logout$', LogoutView.as_view(), name="logout"), ]
{"/projects/urls.py": ["/projects/views.py"]}
6,640
Tasha-Carty-220/asvs
refs/heads/master
/levels/urls.py
from django.conf.urls import url from .views import levels urlpatterns = [ url(r'(?P<level>\d+)', levels, name="level"), ]
{"/projects/urls.py": ["/projects/views.py"]}
6,641
Tasha-Carty-220/asvs
refs/heads/master
/projects/urls.py
from django.conf.urls import url from .views import project_all, project_add, project_delete, project_view, project_update, project_download urlpatterns = [ url(r'manage/', project_all, name='projectsmanage'), url(r'_add/', project_add, name='projectsadd'), url(r'_delete/(?P<projectid>\d+)', project_delete, name='projectsdelete'), url(r'view/(?P<projectid>\d+)', project_view, name='projectsview'), url(r'_update/', project_update, name='projectsupdate'), url(r'_download/(?P<projectid>\d+)', project_download, name='projectsdownload') ]
{"/projects/urls.py": ["/projects/views.py"]}