Browse Source

ejabber processes

System Administrator 1 year ago
parent
commit
9e239829b6
7 changed files with 29 additions and 10 deletions
  1. 3 2
      admin/event.py
  2. 1 0
      handlers
  3. 5 1
      models/__init__.py
  4. 4 2
      models/event.py
  5. 9 0
      serializers/event.py
  6. 6 4
      urls.py
  7. 1 1
      views/__init__.py

+ 3 - 2
admin/event.py

@@ -30,7 +30,8 @@ class EventAdmin(admin.ModelAdmin):
         'min_participants',
         'max_age',
         'min_age',
-        'required_level',
+        'min_level',
+        'max_level',
         'is_public',
     )
     list_filter = (
@@ -41,4 +42,4 @@ class EventAdmin(admin.ModelAdmin):
         'time_updated',
         'time_close',
         'is_public',
-    )
+    )

+ 1 - 0
handlers

@@ -0,0 +1 @@
+Subproject commit 0973fb78ad5dfba831592f5dc31fc7b5b794adcd

+ 5 - 1
models/__init__.py

@@ -1,9 +1,13 @@
 
 MALE = 'M'
 FEMALE = 'F'
+UNDEFINED = 'U'
+BOTH = 'B'
 GENDERS = [
     (MALE, 'Мужчина'),
     (FEMALE, 'Женщина'),
+    (UNDEFINED, 'Неопределено'),
+    (BOTH, 'Мужчина и женщина'),
 ]
 
 from .sport import Sport
@@ -23,4 +27,4 @@ from .saved_sportsman import SavedSportsman
 from .blocked_sportsman import BlockedSportsman
 from .sport_preferrence import SportPreferrence
 
-# created events ищутся через event.host
+# created events ищутся через event.host

+ 4 - 2
models/event.py

@@ -38,10 +38,12 @@ class Event(models.Model):
     min_participants = models.IntegerField(help_text="минимальное количесво участников")
     max_age = models.IntegerField(help_text="максимальный возраст для участия")
     min_age = models.IntegerField(help_text="минимальный возраст для участия")
-    required_level = models.IntegerField(null=True, blank=True, help_text="необходимое минимальное значение в поле level у пользователя для участия")
+    min_level = models.IntegerField(null=True, blank=True, help_text="необходимое минимальное значение в поле level у пользователя для участия")
+    max_level = models.IntegerField(null=True, blank=True, help_text="необходимое минимальное значение в поле level у пользователя для участия")
+
     is_public = models.BooleanField(default=True)
 
     class Meta:
         db_table = "event"
         verbose_name = "мероприятие"
-        verbose_name_plural = "мероприятия"
+        verbose_name_plural = "мероприятия"

+ 9 - 0
serializers/event.py

@@ -71,3 +71,12 @@ class EventSerializer(serializers.ModelSerializer):
         ticket_instance.save()
         order_instance.save()
         return instance
+
+    def create(self, request, *args, **kwargs):
+        serializer = self.get_serializer(data=request.data)
+        serializer.is_valid(raise_exception=True)
+        self.perform_create(serializer)
+        headers = self.get_success_headers(serializer.data)
+        return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
+
+

+ 6 - 4
urls.py

@@ -3,7 +3,7 @@ from rest_framework import routers
 from django.urls import path, include, re_path
 from . import views
 
-app_name = 'webservice'
+app_name = 'webservice_running'
 
 router = routers.DefaultRouter()
 router.register(r'event', EventMVS)
@@ -22,6 +22,8 @@ router.register(r'sport', SportMVS)
 router.register(r'sportsman_gallery', SportsmanGalleryMVS)
 
 urlpatterns = [
-    # path("", views.order_reg, name="order_reg"),
-    re_path(r'^api/', include(router.urls), name="webservice_running_api"),
-]
+    path('order_reg/', views.order_reg, name="order_reg"),
+    path('', views.registration, name="registration"),
+    path('api/', include(router.urls), name="webservice_running_api"),
+]
+

+ 1 - 1
views/__init__.py

@@ -1 +1 @@
-from . import views
+from .views import *