From 369adbc4bae2ab31af0037c37f751a05d131c1ae Mon Sep 17 00:00:00 2001 From: Raskatov Andrey Date: Wed, 6 Mar 2024 13:17:26 +1000 Subject: [PATCH] =?UTF-8?q?feature:=20=D0=A0=D0=B0=D1=81=D1=88=D0=B8=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE=D0=BD?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D1=8B=20=D1=81=20=D0=B7=D0=BE=D0=BD=D0=BE=D0=B9=20=D0=B0?= =?UTF-8?q?=D0=B4=D0=BC=D0=B8=D0=BD=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crm_yandex/ambassadors/admin.py | 64 +++++++++++++++++++++++----- crm_yandex/ambassadors/constants.py | 1 - crm_yandex/ambassadors/models.py | 51 ++-------------------- crm_yandex/ambassadors/tests.py | 20 +-------- crm_yandex/db.sqlite3 | Bin 262144 -> 262144 bytes 5 files changed, 59 insertions(+), 77 deletions(-) diff --git a/crm_yandex/ambassadors/admin.py b/crm_yandex/ambassadors/admin.py index 3fd2c40..0e4bf28 100644 --- a/crm_yandex/ambassadors/admin.py +++ b/crm_yandex/ambassadors/admin.py @@ -1,15 +1,59 @@ from django.contrib import admin -from .models import (Activity, Ambassador, AmbassadorActivity, - AmbassadorPreference, Content, MerchOnShipping, - MerchShipment, Preference, Venue) +from .models import (Activity, Ambassador, AmbassadorActivity, Content, Merch, + MerchOnShipping, MerchShipment, Venue) -admin.site.register(Activity) -admin.site.register(Ambassador) + +class AmbassadorActivityInline(admin.TabularInline): + model = AmbassadorActivity + extra = 1 + + +class MerchOnShippingInline(admin.TabularInline): + model = MerchOnShipping + extra = 1 + + +class ActivityAdmin(admin.ModelAdmin): + list_display = ("name",) + empty_value_display = "-пусто" + + +class MerchAdmin(admin.ModelAdmin): + list_display = ("merch_type", "cost") + empty_value_display = "-пусто" + + +class VenueAdmin(admin.ModelAdmin): + list_display = ("name",) + empty_value_display = "-пусто" + + +class MerchShipmentAdmin(admin.ModelAdmin): + list_display = ("curator", "ambassador", "status", "date") + list_filter = ("status", "ambassador", "curator") + inlines = (MerchOnShippingInline,) + empty_value_display = "-пусто" + + +class ContentAdmin(admin.ModelAdmin): + list_display = ("ambassador", "link", "date", "guide_followed") + list_filter = ("ambassador", "venue", "guide_followed") + empty_value_display = "-пусто" + + +class AmbassadorAdmin(admin.ModelAdmin): + list_display = ("fio", "telegram", "promocode", "status") + list_filter = ("fio", "status") + inlines = (AmbassadorActivityInline,) + empty_value_display = "-пусто" + + +admin.site.register(Activity, ActivityAdmin) +admin.site.register(Ambassador, AmbassadorAdmin) admin.site.register(AmbassadorActivity) -admin.site.register(AmbassadorPreference) -admin.site.register(Content) +admin.site.register(Content, ContentAdmin) admin.site.register(MerchOnShipping) -admin.site.register(MerchShipment) -admin.site.register(Preference) -admin.site.register(Venue) +admin.site.register(MerchShipment, MerchShipmentAdmin) +admin.site.register(Merch, MerchAdmin) +admin.site.register(Venue, VenueAdmin) diff --git a/crm_yandex/ambassadors/constants.py b/crm_yandex/ambassadors/constants.py index 03051ab..67d2218 100644 --- a/crm_yandex/ambassadors/constants.py +++ b/crm_yandex/ambassadors/constants.py @@ -61,7 +61,6 @@ ] CLOTHING_SIZE_MAX_LEN: int = 2 PROMOCODE_MAX_LEN: int = 20 -PREFERENCE_MAX_LEN: int = 255 TELEGRAM_MAX_LEN: int = 32 SHIPMENT_STATUS_CHOICES = [ ("unprocessed", "Необработанные"), diff --git a/crm_yandex/ambassadors/models.py b/crm_yandex/ambassadors/models.py index aa5e100..3e8d9ca 100644 --- a/crm_yandex/ambassadors/models.py +++ b/crm_yandex/ambassadors/models.py @@ -4,10 +4,9 @@ from .constants import (AMBASSADOR_STATUS_CHOICES, CLOTHING_SIZE_CHOICES, CLOTHING_SIZE_MAX_LEN, COURSE_CHOICES, DECIMAL_MAX_DIGITS, DECIMAL_PLACES, GOAL_MAX_LEN, - NAME_MAX_LEN, PHONE_NUM_MAX_LEN, PREFERENCE_MAX_LEN, - PROMOCODE_MAX_LEN, SEX_CHOICES, SEX_MAX_LEN, - SHIPMENT_STATUS_CHOICES, STATUS_MAX_LEN, - TELEGRAM_MAX_LEN) + NAME_MAX_LEN, PHONE_NUM_MAX_LEN, PROMOCODE_MAX_LEN, + SEX_CHOICES, SEX_MAX_LEN, SHIPMENT_STATUS_CHOICES, + STATUS_MAX_LEN, TELEGRAM_MAX_LEN) from .validators import POSTAL_CODE_VALIDATOR, TELEGRAM_USERNAME_VALIDATOR @@ -26,21 +25,6 @@ def __str__(self): return self.name -class Preference(models.Model): - name = models.CharField( - max_length=PREFERENCE_MAX_LEN, - verbose_name="Предпочтение" - ) - - class Meta: - verbose_name = "Предпочтение в рамкха амбассадорства" - verbose_name_plural = "Предпочтения в рамкха амбассадорства" - ordering = ["name"] - - def __str__(self): - return self.name - - class Ambassador(models.Model): fio = models.CharField( max_length=NAME_MAX_LEN, @@ -135,13 +119,6 @@ class Ambassador(models.Model): default="active", verbose_name="Статус амбассадора" ) - preferences = models.ManyToManyField( - Preference, - through="AmbassadorPreference", - verbose_name="Предпочтения амбассадора", - related_name="ambassadors", - through_fields=("ambassador", "preference") - ) guide_one = models.BooleanField( default=False, verbose_name="Гайд 1" @@ -164,28 +141,6 @@ def __str__(self): return self.fio -class AmbassadorPreference(models.Model): - ambassador = models.ForeignKey( - Ambassador, - on_delete=models.CASCADE, - related_name="ambassador_preferences", - verbose_name="ID амбассадора" - ) - preference = models.ForeignKey( - Preference, - on_delete=models.CASCADE, - related_name="ambassador_preferences", - verbose_name="ID предпочтения" - ) - - class Meta: - verbose_name = "Амбассадор-Предпочтение" - verbose_name_plural = "Амбассадор-Предпочтения" - - def __str__(self): - return f"{self.ambassador} - {self.preference}" - - class AmbassadorActivity(models.Model): ambassador = models.ForeignKey( Ambassador, diff --git a/crm_yandex/ambassadors/tests.py b/crm_yandex/ambassadors/tests.py index c5562f9..00f6a77 100644 --- a/crm_yandex/ambassadors/tests.py +++ b/crm_yandex/ambassadors/tests.py @@ -2,9 +2,8 @@ from django.test import TestCase from django.utils import timezone -from .models import (Activity, Ambassador, AmbassadorActivity, - AmbassadorPreference, Content, Merch, MerchOnShipping, - MerchShipment, Preference, Venue) +from .models import (Activity, Ambassador, AmbassadorActivity, Content, Merch, + MerchOnShipping, MerchShipment, Venue) from .validators import POSTAL_CODE_VALIDATOR, TELEGRAM_USERNAME_VALIDATOR @@ -12,7 +11,6 @@ class AmbassadorTests(TestCase): def setUp(self): self.activity = Activity.objects.create(name="Test_activity") - self.preference = Preference.objects.create(name="Test_preference") self.ambassador = Ambassador.objects.create( fio="Тест Тестов Тестович", sex="М", @@ -64,10 +62,6 @@ def setUp(self): ambassador=self.ambassador, activity=self.activity ) - self.ambassador_preference = AmbassadorPreference.objects.create( - ambassador=self.ambassador, - preference=self.preference - ) self.merch_on_shipping = MerchOnShipping.objects.create( shipping=self.merch_shipment, merch=self.merch, @@ -78,9 +72,6 @@ def setUp(self): def test_activity_listing(self): self.assertEqual(self.activity.name, "Test_activity") - def test_preference_listing(self): - self.assertEqual(self.preference.name, "Test_preference") - def test_ambassador_listing(self): self.assertEqual(self.ambassador.fio, "Тест Тестов Тестович") self.assertEqual(self.ambassador.sex, "М") @@ -130,7 +121,6 @@ def test_merch_shipment_listing(self): def test_models_have_correct_object_names(self): model_str = { self.activity: self.activity.name, - self.preference: self.preference.name, self.ambassador: self.ambassador.fio, self.merch: f"{self.merch.merch_type} - {self.merch.cost}", self.merch_shipment: ( @@ -150,12 +140,6 @@ def test_models_have_correct_object_names(self): def test_relationships(self): self.assertEqual(self.ambassador_activity.ambassador, self.ambassador) self.assertEqual(self.ambassador_activity.activity, self.activity) - self.assertEqual( - self.ambassador_preference.ambassador, self.ambassador - ) - self.assertEqual( - self.ambassador_preference.preference, self.preference - ) self.assertEqual(self.merch_on_shipping.shipping, self.merch_shipment) self.assertEqual(self.merch_on_shipping.merch, self.merch) self.assertEqual(self.merch_shipment.ambassador, self.ambassador) diff --git a/crm_yandex/db.sqlite3 b/crm_yandex/db.sqlite3 index 0d4a9c34628e405fa0b2e8479536d6e924f093a6..f774d1e4c9234677631512f240accdb40d66c3de 100644 GIT binary patch delta 1093 zcmah{Z)h839KL%mS<^pvZ|dflty?2orEE>|<}Q~e(P=MB(Mq2N#u#mW3IHs(G|hTkTBnO}r?3`J1H56{Do zhxg(4dwIysaji?gui8BMU@sMRZM5FJFmAWgfxfk1#}I!9l6a%iBJ+QZ;Y_%qyr*P#w&>Mmu# zQECrTofD29DSWd1yDM&mcd%ibF5U)?w(Ncpx3qWMDSV)F$4#R?3%QFyp8A49AF)YLQ z*jC4*{DAja;5`if2A{xt@NuVq56^*l+<0dWzf$P~ztos=cP(D#?FTQ=hC^e^ET5R=l^m008|w?s@M0?HQI|^Pd{E5K zuGUr+o-eJ>hw9-#eVq|1aypWhJsB3We6p_IHZ*f3>@C!a-8gF6n5xiv@4LEdy;PC(M1&l|}@S*WR zGo>CdN_6i~uaV8Z8`htCtyWKu0G@(TVd5>qkxCkGA0e*d`uid9v7Wd=oHi~TCw9RlTN)U)H1W)h eL*2Gboav{{-XkVnHSvmxH_f>}hgU8WD}Ml8sXg%k delta 605 zcmY+CUr3Wt7{*1DIsmnY=Mv=pD_v9#`30%E}Aol z@@6*Z?MiR@1EGa{7hlm$bWzYn4hf90ZiLaD=~XwuI`b~hd0t+A7l-G0IQhIQpLZ2~ z?tVf@RO-A`6CuFYdLt5sv+vE4FmWU&8Q9J}7S3V0c~3g!Y_qqNtgeXOAFSH+mbL>+ zyMu2K@j?6&1+ghmq{U^v#|_cTH}sC+PY%1Kzu_z9?j9Dmp|(SVrF362uu`Ef0d4wj z-+-zxt`c#Tf8wfq_7vCE>~~O@s1fl;9Eh6k&hH7mcE7XCILx4R3IYn9Ag@ercxGQO zjk+SJO+nC>(lYbfO3yHAUe>{u!z1|C!zOTii!Gq0!l6lqYR339T);<@^aQ@~vK$s; zG=T3u(+sLHdeeMX_K-oRhxt)Y!WLXahlh>f`X-w-=B~qwMF;Q-k=HM~@agW{S8i0k z!8x}DM3soD^tvms`Wr$L>=Uss!4F~V*P%1&GY=6Ps}R#FtMGfyr;hEWA!W{9XdJ^I zr7nuOF>1lXS=x$&V{`+LNK}@^ZqLN!mEu@xG*;}d75$(eAD0N^U q2@2l12B#m^6V#|Dm`#0BG+|Sog`C~8fW{9xBh@8~_$Xc$S?(Vx=Bs!B