yobafromstarvvars hai 1 ano
pai
achega
a3b96c970f
Modificáronse 70 ficheiros con 979 adicións e 91 borrados
  1. 0 5
      admin.py
  2. 16 0
      admin/__init__.py
  3. 7 0
      admin/achievement.py
  4. 14 0
      admin/achievements.py
  5. 7 0
      admin/blocked_sportsman.py
  6. 7 0
      admin/browse_event.py
  7. 7 0
      admin/browse_sportsman.py
  8. 44 0
      admin/event.py
  9. 7 0
      admin/event_gallery.py
  10. 7 0
      admin/participant.py
  11. 7 0
      admin/saved_event.py
  12. 7 0
      admin/saved_sportsman.py
  13. 6 0
      admin/sport.py
  14. 7 0
      admin/sport_preferrence.py
  15. 29 0
      admin/sportsman.py
  16. 7 0
      admin/sportsman_gallery.py
  17. 14 1
      apiviews/__init__.py
  18. 12 0
      apiviews/achievement.py
  19. 12 0
      apiviews/achievements.py
  20. 12 0
      apiviews/blocked_sportsman.py
  21. 12 0
      apiviews/browse_event.py
  22. 12 0
      apiviews/browse_sportsman.py
  23. 9 20
      apiviews/event.py
  24. 12 0
      apiviews/event_gallery.py
  25. 12 0
      apiviews/participant.py
  26. 12 0
      apiviews/saved_event.py
  27. 12 0
      apiviews/saved_sportsman.py
  28. 12 0
      apiviews/sport.py
  29. 12 0
      apiviews/sport_preferrence.py
  30. 66 0
      apiviews/sportsman.py
  31. 12 0
      apiviews/sportsman_gallery.py
  32. 1 5
      apps.py
  33. 2 0
      exceptions/__init__.py
  34. 7 0
      exceptions/client_not_defined.py
  35. 7 0
      exceptions/order_not_defined.py
  36. 26 1
      models/__init__.py
  37. 19 0
      models/achievement.py
  38. 17 0
      models/achievements.py
  39. 21 0
      models/blocked_sportsman.py
  40. 18 0
      models/browse_event.py
  41. 19 0
      models/browse_sportsman.py
  42. 47 0
      models/event.py
  43. 14 0
      models/event_gallery.py
  44. 18 0
      models/participant.py
  45. 17 0
      models/saved_event.py
  46. 17 0
      models/saved_sportsman.py
  47. 13 0
      models/sport.py
  48. 17 0
      models/sport_preferrence.py
  49. 53 0
      models/sportsman.py
  50. 14 0
      models/sportsman_gallery.py
  51. 0 30
      models/webservice_running.py
  52. 0 1
      serializer/__init__.py
  53. 14 0
      serializers/__init__.py
  54. 8 0
      serializers/achievement.py
  55. 8 0
      serializers/achievements.py
  56. 8 0
      serializers/blocked_sportsman.py
  57. 8 0
      serializers/browse_event.py
  58. 8 0
      serializers/browse_sportsman.py
  59. 5 22
      serializers/event.py
  60. 8 0
      serializers/event_gallery.py
  61. 8 0
      serializers/participant.py
  62. 8 0
      serializers/saved_event.py
  63. 8 0
      serializers/saved_sportsman.py
  64. 8 0
      serializers/sport.py
  65. 8 0
      serializers/sport_preferrence.py
  66. 86 0
      serializers/sportsman.py
  67. 8 0
      serializers/sportsman_gallery.py
  68. 18 6
      urls.py
  69. 1 0
      views/__init__.py
  70. 0 0
      views/views.py

+ 0 - 5
admin.py

@@ -1,5 +0,0 @@
-from django.contrib import admin
-from webservice_running.models import OrdersLocal
-
-
-admin.site.register(OrdersLocal)

+ 16 - 0
admin/__init__.py

@@ -0,0 +1,16 @@
+from .sport import SportAdmin
+from .achievements import AchievementsAdmin
+
+from .event import EventAdmin
+from .sportsman import SportsmanAdmin
+from .sportsman_gallery import SportsmanGalleryAdmin
+from .achievement import AchievementAdmin
+from .event_gallery import EventGalleryAdmin
+from .participant import ParticipantAdmin
+
+from .browse_event import BrowseEventAdmin
+from .browse_sportsman import BrowseSportsmanAdmin
+from .saved_event import SavedEventAdmin
+from .saved_sportsman import SavedSportsmanAdmin
+from .blocked_sportsman import BlockedSportsmanAdmin
+from .sport_preferrence import SportPreferrenceAdmin

+ 7 - 0
admin/achievement.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import Achievement
+
+@admin.register(Achievement)
+class AchievementAdmin(admin.ModelAdmin):
+    list_display = ('id', 'sportsman', 'achievement', 'time_received')
+    list_filter = ('sportsman', 'achievement', 'time_received')

+ 14 - 0
admin/achievements.py

@@ -0,0 +1,14 @@
+from django.contrib import admin
+from webservice_running.models import Achievements
+
+
+@admin.register(Achievements)
+class AchievementsAdmin(admin.ModelAdmin):
+    list_display = (
+        'id',
+        'title',
+        'description',
+        'image',
+        'image_animated',
+        'value',
+    )

+ 7 - 0
admin/blocked_sportsman.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import BlockedSportsman
+
+@admin.register(BlockedSportsman)
+class BlockedSportsmanAdmin(admin.ModelAdmin):
+    list_display = ('id', 'sportsman', 'sportsman_blocked')
+    list_filter = ('sportsman', 'sportsman_blocked')

+ 7 - 0
admin/browse_event.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import BrowseEvent
+
+@admin.register(BrowseEvent)
+class BrowseEventAdmin(admin.ModelAdmin):
+    list_display = ('id', 'sportsman', 'event_browseevent', 'time_browsed')
+    list_filter = ('sportsman', 'event_browseevent', 'time_browsed')

+ 7 - 0
admin/browse_sportsman.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import BrowseSportsman
+
+@admin.register(BrowseSportsman)
+class BrowseSportsmanAdmin(admin.ModelAdmin):
+    list_display = ('id', 'sportsman', 'sportsman_browsed', 'time_browsed')
+    list_filter = ('sportsman', 'sportsman_browsed', 'time_browsed')

+ 44 - 0
admin/event.py

@@ -0,0 +1,44 @@
+from django.contrib import admin
+from webservice_running.models import Event
+
+@admin.register(Event)
+class EventAdmin(admin.ModelAdmin):
+    list_display = (
+        'id',
+        'order_synced',
+        'resource_id',
+        'rating_id',
+        'attempts',
+        'order_place_type',
+        'order_place_start',
+        'order_place_start_gps',
+        'order_place_start_sector',
+        'order_place_start_real',
+        'order_place_start_real_gps',
+        'order_place_finish_predicted',
+        'order_place_finish_predicted_gps',
+        'order_place_finish_sector',
+        'order_place_finish_real',
+        'order_place_finish_real_gps',
+        'sport',
+        'host',
+        'required_gender',
+        'description',
+        'time_updated',
+        'time_close',
+        'max_participants',
+        'min_participants',
+        'max_age',
+        'min_age',
+        'required_level',
+        'is_public',
+    )
+    list_filter = (
+        'order_synced',
+        'resource_id',
+        'sport',
+        'host',
+        'time_updated',
+        'time_close',
+        'is_public',
+    )

+ 7 - 0
admin/event_gallery.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import EventGallery
+
+@admin.register(EventGallery)
+class EventGalleryAdmin(admin.ModelAdmin):
+    list_display = ('id', 'event', 'image')
+    list_filter = ('event',)

+ 7 - 0
admin/participant.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import Participant
+
+@admin.register(Participant)
+class ParticipantAdmin(admin.ModelAdmin):
+    list_display = ('id', 'sportsman', 'event_participant', 'is_finished')
+    list_filter = ('sportsman', 'event_participant', 'is_finished')

+ 7 - 0
admin/saved_event.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import SavedEvent
+
+@admin.register(SavedEvent)
+class SavedEventAdmin(admin.ModelAdmin):
+    list_display = ('id', 'sportsman', 'event_savedevent')
+    list_filter = ('sportsman', 'event_savedevent')

+ 7 - 0
admin/saved_sportsman.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import SavedSportsman
+
+@admin.register(SavedSportsman)
+class SavedSportsmanAdmin(admin.ModelAdmin):
+    list_display = ('id', 'sportsman', 'sportsman_saved')
+    list_filter = ('sportsman', 'sportsman_saved')

+ 6 - 0
admin/sport.py

@@ -0,0 +1,6 @@
+from django.contrib import admin
+from webservice_running.models import Sport
+
+@admin.register(Sport)
+class SportAdmin(admin.ModelAdmin):
+    list_display = ('id', 'title', 'image')

+ 7 - 0
admin/sport_preferrence.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import SportPreferrence
+
+@admin.register(SportPreferrence)
+class SportPreferrenceAdmin(admin.ModelAdmin):
+    list_display = ('id', 'sportsman', 'sport')
+    list_filter = ('sportsman', 'sport')

+ 29 - 0
admin/sportsman.py

@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from django.contrib import admin
+from webservice_running.models import Sportsman
+
+@admin.register(Sportsman)
+class SportsmanAdmin(admin.ModelAdmin):
+    list_display = (
+        'id',
+        'client',
+        'bio',
+        'level',
+        'birthdate',
+        'active_status',
+        'time_updated',
+        'preferred_time',
+        'reliance_rating',
+        'gender',
+    )
+    list_filter = ('client', 'birthdate', 'time_updated')
+    raw_id_fields = (
+        'blocked_sportsman',
+        'browse_sportsman',
+        'saved_sportsman',
+        'sport_preferrence',
+        'achievement',
+        'saved_event',
+        'participant',
+        'browse_event',
+    )

+ 7 - 0
admin/sportsman_gallery.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+from webservice_running.models import SportsmanGallery
+
+@admin.register(SportsmanGallery)
+class SportsmanGalleryAdmin(admin.ModelAdmin):
+    list_display = ('id', 'sportsman', 'image')
+    list_filter = ('sportsman',)

+ 14 - 1
apiviews/__init__.py

@@ -1 +1,14 @@
-from .orders_local import OrdersLocalMVS
+from .event import EventMVS
+from .achievement import AchievementMVS
+from .achievements import AchievementsMVS
+from .blocked_sportsman import BlockedSportsmanMVS
+from .browse_event import BrowseEventMVS
+from .browse_sportsman import BrowseSportsmanMVS
+from .event_gallery import EventGalleryMVS
+from .participant import ParticipantMVS
+from .saved_event import SavedEventMVS
+from .sport_preferrence import SportPreferrenceMVS
+from .saved_sportsman import SavedSportsmanMVS
+from .sport import SportMVS
+from .sportsman_gallery import SportsmanGalleryMVS
+from .sportsman import SportsmanMVS

+ 12 - 0
apiviews/achievement.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import Achievement
+from webservice_running.serializers import AchievementSerializer
+
+
+class AchievementMVS(viewsets.ModelViewSet):
+    queryset = Achievement.objects.all()
+    serializer_class = AchievementSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 12 - 0
apiviews/achievements.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import Achievements
+from webservice_running.serializers import AchievementsSerializer
+
+
+class AchievementsMVS(viewsets.ModelViewSet):
+    queryset = Achievements.objects.all()
+    serializer_class = AchievementsSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 12 - 0
apiviews/blocked_sportsman.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import BlockedSportsman
+from webservice_running.serializers import BlockedSportsmanSerializer
+
+
+class BlockedSportsmanMVS(viewsets.ModelViewSet):
+    queryset = BlockedSportsman.objects.all()
+    serializer_class = BlockedSportsmanSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 12 - 0
apiviews/browse_event.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import BrowseEvent
+from webservice_running.serializers import BrowseEventSerializer
+
+
+class BrowseEventMVS(viewsets.ModelViewSet):
+    queryset = BrowseEvent.objects.all()
+    serializer_class = BrowseEventSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 12 - 0
apiviews/browse_sportsman.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import BrowseSportsman
+from webservice_running.serializers import BrowseSportsmanSerializer
+
+
+class BrowseSportsmanMVS(viewsets.ModelViewSet):
+    queryset = BrowseSportsman.objects.all()
+    serializer_class = BrowseSportsmanSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 9 - 20
apiviews/orders_local.py → apiviews/event.py

@@ -1,18 +1,13 @@
-from django.http import Http404, HttpResponse
 from django.shortcuts import get_object_or_404
-from webservice_running.serializer import OrdersLocalSerializer
-from rest_framework import viewsets, permissions, status
+from rest_framework import viewsets, permissions
 from rest_framework.response import Response
-from rest_framework.exceptions import NotFound
-from webservice_running.models import OrdersLocal
-# from metaservicesynced.models import Orders, Service, ServiceType, Provider, Client
-# from SharixAdmin.models import SharixUser
-# from tickets.models import Task
-# from tickets.serializer import TaskSerializer
+from webservice_running.models import Event
+from webservice_running.serializers import EventSerializer
 
-class OrdersLocalMVS(viewsets.ModelViewSet):
-    queryset = OrdersLocal.objects.all()
-    serializer_class = OrdersLocalSerializer
+
+class EventMVS(viewsets.ModelViewSet):
+    queryset = Event.objects.all()
+    serializer_class = EventSerializer
     #permission_classes = [IsOwnerOrReadOnly]
     permission_classes = [permissions.IsAuthenticated]
     
@@ -26,7 +21,7 @@ class OrdersLocalMVS(viewsets.ModelViewSet):
         keyword arguments in the url conf.
         """
         # queryset = self.filter_queryset(self.get_queryset())
-        queryset = OrdersLocal.objects.select_related('order_synced__ticket')
+        queryset = Event.objects.select_related('order_synced__ticket')
 
         # Perform the lookup filtering.
         lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
@@ -49,7 +44,7 @@ class OrdersLocalMVS(viewsets.ModelViewSet):
 
     def update(self, request, *args, **kwargs):
         partial = kwargs.pop('partial', False)
-        instance = self.get_object()# OrdersLocal.objects.select_related('order_synced__ticket').get(id=1)
+        instance = self.get_object()# Event.objects.select_related('order_synced__ticket').get(id=1)
         serializer = self.get_serializer(instance, data=request.data, partial=partial)
         # for serializer in serializers:
         serializer.is_valid(raise_exception=True)
@@ -61,9 +56,3 @@ class OrdersLocalMVS(viewsets.ModelViewSet):
             instance._prefetched_objects_cache = {}
 
         return Response(serializer.data)
-
-    
-    
-    
-    
-    

+ 12 - 0
apiviews/event_gallery.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import EventGallery
+from webservice_running.serializers import EventGallerySerializer
+
+
+class EventGalleryMVS(viewsets.ModelViewSet):
+    queryset = EventGallery.objects.all()
+    serializer_class = EventGallerySerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 12 - 0
apiviews/participant.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import Participant
+from webservice_running.serializers import ParticipantSerializer
+
+
+class ParticipantMVS(viewsets.ModelViewSet):
+    queryset = Participant.objects.all()
+    serializer_class = ParticipantSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 12 - 0
apiviews/saved_event.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import SavedEvent
+from webservice_running.serializers import SavedEventSerializer
+
+
+class SavedEventMVS(viewsets.ModelViewSet):
+    queryset = SavedEvent.objects.all()
+    serializer_class = SavedEventSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 12 - 0
apiviews/saved_sportsman.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import SavedSportsman
+from webservice_running.serializers import SavedSportsmanSerializer
+
+
+class SavedSportsmanMVS(viewsets.ModelViewSet):
+    queryset = SavedSportsman.objects.all()
+    serializer_class = SavedSportsmanSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 12 - 0
apiviews/sport.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import Sport
+from webservice_running.serializers import SportSerializer
+
+
+class SportMVS(viewsets.ModelViewSet):
+    queryset = Sport.objects.all()
+    serializer_class = SportSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 12 - 0
apiviews/sport_preferrence.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import SportPreferrence
+from webservice_running.serializers import SportPreferrenceSerializer
+
+
+class SportPreferrenceMVS(viewsets.ModelViewSet):
+    queryset = SportPreferrence.objects.all()
+    serializer_class = SportPreferrenceSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 66 - 0
apiviews/sportsman.py

@@ -0,0 +1,66 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import Sportsman
+from webservice_running.serializers import SportsmanSerializer
+
+
+class SportsmanMVS(viewsets.ModelViewSet):
+    serializer_class = SportsmanSerializer
+    queryset = Sportsman.objects.all()
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]
+
+    def get_queryset(self):
+        """
+        Optionally restricts the returned sportsmen to a given phone number,
+        by filtering against a `phone_number` query parameter in the URL.
+        """
+        queryset = Sportsman.objects.select_related('client__user')
+        phone_number = self.request.query_params.get('phone_number', None)
+        if phone_number is not None:
+            queryset = queryset.filter(client__user__phone_number=phone_number)
+        return queryset
+
+    def get_object(self, queryset=None):
+        """
+        Returns the object the view is displaying.
+
+        You may want to override this if you need to provide non-standard
+        queryset lookups.  Eg if objects are referenced using multiple
+        keyword arguments in the url conf.
+        """
+        queryset = self.filter_queryset(self.get_queryset())
+        # Perform the lookup filtering.
+        lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
+
+        assert lookup_url_kwarg in self.kwargs, (
+            'Expected view %s to be called with a URL keyword argument '
+            'named "%s". Fix your URL conf, or set the `.lookup_field` '
+            'attribute on the view correctly.' %
+            (self.__class__.__name__, lookup_url_kwarg)
+        )
+
+        filter_kwargs = {self.lookup_field: self.kwargs[lookup_url_kwarg]}
+        obj = get_object_or_404(queryset, **filter_kwargs)
+
+        # May raise a permission denied
+        self.check_object_permissions(self.request, obj)
+
+        return obj
+
+
+    def update(self, request, *args, **kwargs):
+        partial = kwargs.pop('partial', False)
+        instance = self.get_object()# Event.objects.select_related('order_synced__ticket').get(id=1)
+        serializer = self.get_serializer(instance, data=request.data, partial=partial)
+        # for serializer in serializers:
+        serializer.is_valid(raise_exception=True)
+        self.perform_update(serializer)
+
+        if getattr(instance, '_prefetched_objects_cache', None):
+            # If 'prefetch_related' has been applied to a queryset, we need to
+            # forcibly invalidate the prefetch cache on the instance.
+            instance._prefetched_objects_cache = {}
+
+        return Response(serializer.data)

+ 12 - 0
apiviews/sportsman_gallery.py

@@ -0,0 +1,12 @@
+from django.shortcuts import get_object_or_404
+from rest_framework import viewsets, permissions
+from rest_framework.response import Response
+from webservice_running.models import SportsmanGallery
+from webservice_running.serializers import SportsmanGallerySerializer
+
+
+class SportsmanGalleryMVS(viewsets.ModelViewSet):
+    queryset = SportsmanGallery.objects.all()
+    serializer_class = SportsmanGallerySerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    #permission_classes = [permissions.IsAuthenticated]

+ 1 - 5
apps.py

@@ -5,8 +5,4 @@ api = AuthAPI("<module_login>", "<module_password>")
 
 class WebserviceRunningConfig(AppConfig):
     default_auto_field = 'django.db.models.BigAutoField'
-    name = 'webservice_running'
-
-# class OpenlocalConfig(AppConfig):
-#     default_auto_field = "django.db.models.BigAutoField"
-#     name = "openlocal"
+    name = 'webservice_running'

+ 2 - 0
exceptions/__init__.py

@@ -0,0 +1,2 @@
+from .order_not_defined import OrderNotDefined
+from .client_not_defined import ClientNotDefined

+ 7 - 0
exceptions/client_not_defined.py

@@ -0,0 +1,7 @@
+class ClientNotDefined(Exception):
+    """
+    If order_synced field is not defined throw exception
+    """
+    def __init__(self, message="client field is not defined"):
+        self.message = message
+        super().__init__(self.message)

+ 7 - 0
exceptions/order_not_defined.py

@@ -0,0 +1,7 @@
+class OrderNotDefined(Exception):
+    """
+    If order_synced field is not defined throw exception
+    """
+    def __init__(self, message="order_synced is not defined"):
+        self.message = message
+        super().__init__(self.message)

+ 26 - 1
models/__init__.py

@@ -1 +1,26 @@
-from .webservice_running import OrdersLocal
+
+MALE = 'M'
+FEMALE = 'F'
+GENDERS = [
+    (MALE, 'Мужчина'),
+    (FEMALE, 'Женщина'),
+]
+
+from .sport import Sport
+from .achievements import Achievements
+
+from .event import Event
+from .sportsman import Sportsman
+from .sportsman_gallery import SportsmanGallery
+from .achievement import Achievement
+from .event_gallery import EventGallery
+from .participant import Participant
+
+from .browse_event import BrowseEvent
+from .browse_sportsman import BrowseSportsman
+from .saved_event import SavedEvent
+from .saved_sportsman import SavedSportsman
+from .blocked_sportsman import BlockedSportsman
+from .sport_preferrence import SportPreferrence
+
+# created events ищутся через event.host

+ 19 - 0
models/achievement.py

@@ -0,0 +1,19 @@
+from django.db import models
+from webservice_running.models import Sportsman, Achievements
+
+class Achievement(models.Model):
+    """
+    Achievement (not to confuse with 'Achievements') stores information about achievement history of users.
+    Соединяющая таблица пользователя и достижения для истории полученных достижений у конкретного пользователя.
+    """
+    sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_achievement")
+    achievement = models.ForeignKey(Achievements, on_delete=models.DO_NOTHING, related_name="achievement")
+    time_received = models.DateTimeField(auto_now_add=True)
+
+    class Meta:
+        db_table = "achievement"
+        verbose_name = "достижение пользователя"
+        verbose_name_plural = "достижения пользователя"
+        constraints = [
+            models.UniqueConstraint(fields=['sportsman', 'achievement'], name='unique_achievement')
+        ]

+ 17 - 0
models/achievements.py

@@ -0,0 +1,17 @@
+from django.db import models
+
+class Achievements(models.Model):
+    """
+    Achievments (not to confuse with 'Achievement') table contains a list of achievements.
+    Таблицы со всеми достижениями в сервисе
+    """
+    title = models.CharField(max_length=128, help_text="Название достижения")
+    description = models.CharField(max_length=255, help_text="Описание достижения, за что получается")
+    image = models.ImageField(upload_to="sports/achievements/", help_text="статичная картинка достижения")
+    image_animated = models.ImageField(null=True, blank=True, upload_to="sports/achievements/", help_text="анимированная картинка достижения. Если отсутствует, то используется статичная картинка")
+    value = models.FloatField(default=0, help_text="Очки за выполение")
+
+    class Meta:
+        db_table = "achievements"
+        verbose_name = "достижения"
+        verbose_name_plural = "достижения"

+ 21 - 0
models/blocked_sportsman.py

@@ -0,0 +1,21 @@
+from django.db import models
+from webservice_running.models import Sportsman
+
+class BlockedSportsman(models.Model):
+    """
+    Соединяющая таблица двух пользователей для реализации функционала сохранения мероприятия в список заблокированных
+    """
+    sportsman = models.ForeignKey(Sportsman, 
+                                  on_delete=models.DO_NOTHING,
+                                  related_name="sportsman_blockedsportsman")
+    sportsman_blocked = models.ForeignKey(Sportsman, 
+                                          on_delete=models.DO_NOTHING, 
+                                          related_name="sportsman_blocked")
+
+    class Meta:
+        db_table = "blocked_sportsman"
+        verbose_name = "заблокированный ползователь"
+        verbose_name_plural = "заблокированные пользователи"
+        constraints = [
+            models.UniqueConstraint(fields=['sportsman', 'sportsman_blocked'], name='unique_blocked_sportsman')
+        ]   

+ 18 - 0
models/browse_event.py

@@ -0,0 +1,18 @@
+from django.db import models
+from webservice_running.models import Sportsman, Event
+
+class BrowseEvent(models.Model):
+    """
+    Соединяющая таблица пользователя и мероприятия для сохранения истории просмотра страниц мероприятий
+    """
+    sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_browseevent")
+    event_browseevent = models.ForeignKey(Event, on_delete=models.DO_NOTHING, related_name="event_browseevent")
+    time_browsed = models.DateTimeField(auto_now_add=True, help_text="Для сортировки объектов после соединения browseEvent и browseUser")
+
+    class Meta:
+        db_table = "browse_event"
+        verbose_name = "просмотренное мероприятие"
+        verbose_name_plural = "просмотренные мероприятия"
+        constraints = [
+            models.UniqueConstraint(fields=['sportsman', 'event_browseevent'], name='unique_browse_event')
+        ]

+ 19 - 0
models/browse_sportsman.py

@@ -0,0 +1,19 @@
+from django.db import models
+from webservice_running.models import Sportsman
+
+class BrowseSportsman(models.Model):
+    """
+    Соединяющая таблица двух пользователей для сохранения истории просмотра страниц спортсменов конкретным кользователем
+    """
+    sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_browsesportsman")
+    sportsman_browsed = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_browsed")
+    # Для сортировки объектов после соединения browseEvent и browseUser
+    time_browsed = models.DateTimeField(auto_now_add=True, help_text="Для сортировки объектов после соединения browseEvent и browseUser")
+
+    class Meta:
+        db_table = "browse_sportsman"
+        verbose_name = "просмотренный пользователь"
+        verbose_name_plural = "просмотренные пользователи"
+        constraints = [
+            models.UniqueConstraint(fields=['sportsman', 'sportsman_browsed'], name='unique_browse_sportsman')
+        ]

+ 47 - 0
models/event.py

@@ -0,0 +1,47 @@
+from django.db import models
+from webservice_running.models import GENDERS
+from metaservicesynced.models import Orders, Resource
+
+
+
+class Event(models.Model):
+    '''
+    Дополнительные данные для сервиса. 
+    '''
+    ### Standart fields
+    order_synced = models.ForeignKey(Orders, on_delete=models.DO_NOTHING)
+    resource_id = models.ForeignKey(Resource, null=True, on_delete=models.DO_NOTHING)
+    rating_id = models.IntegerField(null=True)#Need create table with rating
+    attempts = models.IntegerField(null=True, help_text="Попытки")
+    order_place_type = models.CharField(null=True, max_length=150)
+    order_place_start = models.CharField(null=True, max_length=150)
+    order_place_start_gps = models.CharField(null=True, max_length=150)
+    order_place_start_sector = models.IntegerField(null=True)
+    order_place_start_real = models.CharField(null=True, max_length=150)
+    order_place_start_real_gps = models.CharField(null=True, max_length=150)
+    order_place_finish_predicted = models.CharField(null=True, max_length=150)
+    order_place_finish_predicted_gps = models.CharField(null=True, max_length=150)
+    order_place_finish_sector = models.IntegerField(null=True)
+    order_place_finish_real = models.CharField(null=True, max_length=150)
+    order_place_finish_real_gps = models.CharField(null=True, max_length=150)
+
+    ### Application fields
+    sport = models.ForeignKey("Sport", on_delete=models.DO_NOTHING)
+    host = models.ForeignKey("Sportsman", on_delete=models.DO_NOTHING)
+    required_gender = models.CharField(max_length=1, choices=GENDERS, default=None, null=True, blank=True)
+    description = models.CharField(max_length=512, blank=True)
+    # Event updated time
+    time_updated = models.DateTimeField(auto_now=True, null=True, blank=True)
+    # Time until which signing up is available
+    time_close = models.DateTimeField(null=True, blank=True)
+    max_participants = models.IntegerField(help_text="максимальное количесво участников")
+    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 у пользователя для участия")
+    is_public = models.BooleanField(default=True)
+
+    class Meta:
+        db_table = "event"
+        verbose_name = "мероприятие"
+        verbose_name_plural = "мероприятия"

+ 14 - 0
models/event_gallery.py

@@ -0,0 +1,14 @@
+from django.db import models
+from webservice_running.models import Event
+
+class EventGallery(models.Model):
+    """
+    Соединяющая таблица между мероприятием и картинкой для хранения картинок для конкретного мероприятия
+    """
+    event = models.ForeignKey(Event, on_delete=models.DO_NOTHING)
+    image = models.ImageField(upload_to ='sports/event/')
+
+    class Meta:
+        db_table = "event_gallery"
+        verbose_name = "фото мероприятия"
+        verbose_name_plural = "фото мероприятия"

+ 18 - 0
models/participant.py

@@ -0,0 +1,18 @@
+from django.db import models
+from webservice_running.models import Sportsman, Event
+
+class Participant(models.Model):
+    """
+    Соединяющая таблица пользователя и мероприятия для регистрации участия
+    """
+    sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_participant")
+    event_participant = models.ForeignKey(Event, on_delete=models.DO_NOTHING, related_name="event_participant")
+    is_finished = models.BooleanField(default=False) # лучше такое поле или смотреть на дату окончания непосредственно в event?
+
+    class Meta:
+        db_table = "participant"
+        verbose_name = "участник"
+        verbose_name_plural = "участники"
+        constraints = [
+            models.UniqueConstraint(fields=['sportsman', 'event_participant'], name='unique_participant')
+        ]

+ 17 - 0
models/saved_event.py

@@ -0,0 +1,17 @@
+from django.db import models
+from webservice_running.models import Sportsman, Event
+
+class SavedEvent(models.Model):
+    """
+    Соединяющая таблица пользователя и мероприятия для реализации функционала сохранения мероприятия в список сохранённых у конкретного пользователя
+    """
+    sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_savedevent")
+    event_savedevent = models.ForeignKey(Event, on_delete=models.DO_NOTHING, related_name="event_savedevent")
+
+    class Meta:
+        db_table = "saved_event"
+        verbose_name = "сохранённое мероприятие"
+        verbose_name_plural = "сохранённые мероприятия"
+        constraints = [
+            models.UniqueConstraint(fields=['sportsman', 'event_savedevent'], name='unique_saved_event')
+        ]

+ 17 - 0
models/saved_sportsman.py

@@ -0,0 +1,17 @@
+from django.db import models
+from webservice_running.models import Sportsman
+
+class SavedSportsman(models.Model):
+    """
+    Соединяющая таблица двух пользователей для реализации функционала сохранения пользователя в список сохранённых
+    """
+    sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_savedsportsman")
+    sportsman_saved = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_saved")
+
+    class Meta:
+        db_table = "saved_sportsman"
+        verbose_name = "сохранённый ползователь"
+        verbose_name_plural = "сохранённые пользователи"
+        constraints = [
+            models.UniqueConstraint(fields=['sportsman', 'sportsman_saved'], name='unique_saved_sportsman')
+        ]

+ 13 - 0
models/sport.py

@@ -0,0 +1,13 @@
+from django.db import models
+
+class Sport(models.Model):
+    """
+    Таблица с видами спорта в сервисе
+    """
+    title = models.CharField(max_length=128)
+    image = models.ImageField(upload_to ='sports/sport/', help_text="иконка вида спорта")
+    
+    class Meta:
+        db_table = "sport"
+        verbose_name = "вид спорта"
+        verbose_name_plural = "виды спорта"

+ 17 - 0
models/sport_preferrence.py

@@ -0,0 +1,17 @@
+from django.db import models
+from webservice_running.models import Sportsman, Sport
+
+class SportPreferrence(models.Model):
+    """
+    Соединяющая таблица с пользователями и видами спорта, которые пользователь добавил как предпочитаемые
+    """
+    sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_sportpreferrence")
+    sport = models.ForeignKey(Sport, on_delete=models.DO_NOTHING, related_name="sport")
+
+    class Meta:
+        db_table = "sport_preferrence"
+        verbose_name = "предпочитаемый вид спорта"
+        verbose_name_plural = "предпочитаемые виды спорта"
+        constraints = [
+            models.UniqueConstraint(fields=['sportsman', 'sport'], name='unique_sportpreferrence')
+        ]

+ 53 - 0
models/sportsman.py

@@ -0,0 +1,53 @@
+from django.db import models
+from webservice_running.models import Sport, Event, Achievements, GENDERS
+from metaservicesynced.models import Client
+
+
+class Sportsman(models.Model):
+    """
+    Определяет дополнительные поля для сервиса "Друг-спортсмен".
+    Дополнительные данные, связанные с функционалом пользователя.
+    """
+    client = models.ForeignKey(Client, on_delete=models.DO_NOTHING, help_text="клиент, которому соответствует роль спортсмена")
+    bio = models.CharField(blank=True, max_length=512, help_text="")
+    level = models.FloatField(default=0, help_text="")
+    birthdate = models.DateField(null=True, blank=True, help_text="")
+    active_status = models.CharField(max_length=64, default="Active", help_text="")
+    time_updated = models.DateTimeField(blank=True, null=True, help_text="")
+    preferred_time = models.CharField(max_length=128, blank=True, help_text="список дней и времени")
+    reliance_rating = models.FloatField(default=0)
+    # blocked_sportsman = models.ManyToManyField("self", db_table="sportsman_blocked")
+    blocked_sportsman = models.ManyToManyField("self", 
+                                               through="BlockedSportsman",
+                                               through_fields=("sportsman", "sportsman_blocked"))
+    browse_sportsman = models.ManyToManyField("self", 
+                                               through="BrowseSportsman",
+                                               through_fields=("sportsman", "sportsman_browsed"))
+    saved_sportsman = models.ManyToManyField("self", 
+                                               through="SavedSportsman",
+                                               through_fields=("sportsman", "sportsman_saved"))
+    sport_preferrence = models.ManyToManyField(Sport, 
+                                               through="SportPreferrence",
+                                               through_fields=("sportsman", "sport"))
+    achievement = models.ManyToManyField(Achievements, 
+                                               through="Achievement",
+                                               through_fields=("sportsman", "achievement"))
+    saved_event = models.ManyToManyField(Event, 
+                                               through="SavedEvent",
+                                               through_fields=("sportsman", "event_savedevent"))
+    participant = models.ManyToManyField(Event, 
+                                               through="Participant",
+                                               through_fields=("sportsman", "event_participant"),
+                                               related_name="sportsman_participant")
+    browse_event = models.ManyToManyField(Event, 
+                                               through="BrowseEvent",
+                                               through_fields=("sportsman", "event_browseevent"),
+                                               related_name="sportsman_browseevent")
+    gender = models.CharField(max_length=1, choices=GENDERS, default=None, null=True, blank=True)
+
+
+
+    class Meta:
+        db_table = "sportsman"
+        verbose_name = "Спортсмена"
+        verbose_name_plural = "Спортсмены"

+ 14 - 0
models/sportsman_gallery.py

@@ -0,0 +1,14 @@
+from django.db import models
+from webservice_running.models import Sportsman
+
+class SportsmanGallery(models.Model):
+    """
+    Соединяющая таблица между пользователем и картинкой для хранения картинок для конкретного пользователя
+    """
+    sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING)
+    image = models.ImageField(upload_to ='sports/sportsman/%Y/%m/%d/')
+
+    class Meta:
+        db_table = "sportsman_gallery"
+        verbose_name = "фото пользователя"
+        verbose_name_plural = "фото пользователя"

+ 0 - 30
models/webservice_running.py

@@ -1,30 +0,0 @@
-from django.db import models
-from metaservicesynced.models import Orders, Resource
-
-class OrdersLocal(models.Model):
-    """
-    OrdersLocal - таблица с заказами
-    """
-    order_synced = models.ForeignKey(Orders, on_delete=models.DO_NOTHING)
-    resource_id = models.ForeignKey(Resource, null=True, on_delete=models.DO_NOTHING)
-    rating_id = models.IntegerField(null=True)#Need create table with rating
-    payment_transaction_id = models.IntegerField(null=True)#Need create table with payment_transaction or it get from platform (i dont know)
-    attempts = models.IntegerField(null=True, help_text="Попытки")
-
-    order_place_type = models.CharField(null=True, max_length=150)
-    order_place_start = models.CharField(null=True, max_length=150)
-    order_place_start_gps = models.CharField(null=True, max_length=150)
-    order_place_start_sector = models.IntegerField(null=True)
-    order_place_start_real = models.CharField(null=True, max_length=150)
-    order_place_start_real_gps = models.CharField(null=True, max_length=150)
-    order_place_finish_predicted = models.CharField(null=True, max_length=150)
-    order_place_finish_predicted_gps = models.CharField(null=True, max_length=150)
-    order_place_finish_sector = models.IntegerField(null=True)
-    order_place_finish_real = models.CharField(null=True, max_length=150)
-    order_place_finish_real_gps = models.CharField(null=True, max_length=150)
-
-
-    class Meta:
-        db_table = "orders_local"
-        verbose_name = "Заказ (local)"
-        verbose_name_plural = "Заказы (local)"

+ 0 - 1
serializer/__init__.py

@@ -1 +0,0 @@
-from .orders_local import OrdersLocalSerializer

+ 14 - 0
serializers/__init__.py

@@ -0,0 +1,14 @@
+from .achievement import AchievementSerializer
+from .achievements import AchievementsSerializer
+from .blocked_sportsman import BlockedSportsmanSerializer
+from .browse_event import BrowseEventSerializer
+from .browse_sportsman import BrowseSportsmanSerializer
+from .event_gallery import EventGallerySerializer
+from .event import EventSerializer
+from .participant import ParticipantSerializer
+from .saved_event import SavedEventSerializer
+from .saved_sportsman import SavedSportsmanSerializer
+from .sport_preferrence import SportPreferrenceSerializer
+from .sport import SportSerializer
+from .sportsman_gallery import SportsmanGallerySerializer
+from .sportsman import SportsmanSerializer

+ 8 - 0
serializers/achievement.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import Achievement
+
+
+class AchievementSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Achievement
+        exclude = ["id"]

+ 8 - 0
serializers/achievements.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import Achievements
+
+
+class AchievementsSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Achievements
+        exclude = ["id"]

+ 8 - 0
serializers/blocked_sportsman.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import BlockedSportsman
+
+
+class BlockedSportsmanSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = BlockedSportsman
+        exclude = ["id"]

+ 8 - 0
serializers/browse_event.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import BrowseEvent
+
+
+class BrowseEventSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = BrowseEvent
+        exclude = ["id"]

+ 8 - 0
serializers/browse_sportsman.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import BrowseSportsman
+
+
+class BrowseSportsmanSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = BrowseSportsman
+        exclude = ["id"]

+ 5 - 22
serializer/orders_local.py → serializers/event.py

@@ -1,25 +1,9 @@
 from rest_framework import serializers
-from webservice_running.models import OrdersLocal
-from tickets.models import *
-from metaservicesynced.models import Orders
-from SharixAdmin.models import SharixUser
-from tickets.serializer import TaskSerializer
-# from metaservicesynced.serializer import OrdersSerializer
-from rest_framework.utils import model_meta
-import pprint
-from django.db import connection
+from webservice_running.models import Event
+from webservice_running.exceptions import OrderNotDefined
 
 
-class OrderNotDefined(Exception):
-    """
-    If order_synced field is not defined throw exception
-    """
-    def __init__(self, message="order_synced is not defined"):
-        self.message = message
-        super().__init__(self.message)
-
-
-class OrdersLocalSerializer(serializers.ModelSerializer):
+class EventSerializer(serializers.ModelSerializer):
     service = serializers.IntegerField(source="order_synced.service.pk", allow_null=True)    
     service_type = serializers.IntegerField(source="order_synced.service_type.pk", allow_null=True) 
     state = serializers.CharField(source="order_synced.state", allow_null=True) 
@@ -56,12 +40,11 @@ class OrdersLocalSerializer(serializers.ModelSerializer):
     # order_synced = OrdersSerializer(read_only=True)
     
     class Meta:
-        model = OrdersLocal
+        model = Event
         fields = "__all__"
         # fields = ["order", "order_synced"]
         # depth = 2
 
-
     def update(self, instance, validated_data):
         """
         Normally order_synced is not null, but in testing it is null=True, so it can produce exceptions
@@ -87,4 +70,4 @@ class OrdersLocalSerializer(serializers.ModelSerializer):
         instance.save()
         ticket_instance.save()
         order_instance.save()
-        return instance
+        return instance

+ 8 - 0
serializers/event_gallery.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import EventGallery
+
+
+class EventGallerySerializer(serializers.ModelSerializer):
+    class Meta:
+        model = EventGallery
+        exclude = ["id"]

+ 8 - 0
serializers/participant.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import Participant
+
+
+class ParticipantSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Participant
+        exclude = ["id"]

+ 8 - 0
serializers/saved_event.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import SavedEvent
+
+
+class SavedEventSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = SavedEvent
+        exclude = ["id"]

+ 8 - 0
serializers/saved_sportsman.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import SavedSportsman
+
+
+class SavedSportsmanSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = SavedSportsman
+        exclude = ["id"]

+ 8 - 0
serializers/sport.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import Sport
+
+
+class SportSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Sport
+        exclude = ["id"]

+ 8 - 0
serializers/sport_preferrence.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import SportPreferrence
+
+
+class SportPreferrenceSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = SportPreferrence
+        exclude = ["id"]

+ 86 - 0
serializers/sportsman.py

@@ -0,0 +1,86 @@
+from rest_framework import serializers
+from webservice_running.models import Sportsman
+from metaservicesynced.models import Client
+from SharixAdmin.models import SharixUser
+from webservice_running.exceptions import ClientNotDefined
+from rest_framework.response import Response
+
+
+class SportsmanSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Sportsman
+        exclude = ["blocked_sportsman", 
+                   "browse_sportsman",
+                    "saved_sportsman",
+                    "sport_preferrence",
+                    "achievement",
+                    "saved_event",
+                    "participant",
+                    "browse_event",]
+
+    # User data
+    phone_number = serializers.CharField(source="client.user.phone_number")
+    first_name = serializers.CharField(source="client.user.first_name")
+    last_name = serializers.CharField(source="client.user.last_name")
+    email = serializers.CharField(source="client.user.email")
+    # Client data
+    requirements = serializers.CharField(source="client.requirements")
+    status = serializers.CharField(source="client.status")
+    ticket_status = serializers.IntegerField(source="client.ticket_status.pk")
+    id_metaservice = serializers.IntegerField(source="client.id_metaservice")
+    is_global = serializers.BooleanField(source="client.is_global")
+    is_visible = serializers.BooleanField(source="client.is_visible")
+
+
+    # def create(self, validated_data):
+    #     print("="*30)
+    #     print(validated_data['client'].status)
+    #     # # Temporary solution
+    #     # client_fields = ("requirements", "status", "ticket_status", "id_metaservice", "is_global", "is_visible")
+    #     # for attr, value in validated_data.items():
+    #     #     # If "client" in req, then User model is accessed
+    #     #     if attr == "client":
+    #     #         for u_attr, u_value in value.get('user').items():
+    #     #             setattr(user_instance, u_attr, u_value)
+    #     #     else:
+    #     #         setattr(instance, attr, value)
+
+    #     # for i in validated_data.items():
+    #     #     pass
+    #     # user_instance = SharixUser._default_manager.create(**validated_data)
+    #     # client_instance = Client._default_manager.create(**validated_data)
+    #     # instance = Sportsman._default_manager.create(**validated_data)
+    #     # return instance
+        
+
+    def update(self, instance, validated_data):
+        client_instance = instance.client
+        if not client_instance:
+            raise ClientNotDefined()
+        user_instance = instance.client.user
+
+        for attr, value in validated_data.items():
+            # If "client" in req, then User model is accessed
+            if attr == "client":
+                for u_attr, u_value in value.get('user').items():
+                    setattr(user_instance, u_attr, u_value)
+            else:
+                setattr(instance, attr, value)
+
+        instance.save()
+        user_instance.save()
+        
+        return instance
+
+'''
+
+{
+    'client': {
+        'user': {
+            'phone_number': '99999999999', 
+            'email': 'email'
+        }
+    },
+    'bio': 'bio test'}
+
+'''

+ 8 - 0
serializers/sportsman_gallery.py

@@ -0,0 +1,8 @@
+from rest_framework import serializers
+from webservice_running.models import SportsmanGallery
+
+
+class SportsmanGallerySerializer(serializers.ModelSerializer):
+    class Meta:
+        model = SportsmanGallery
+        exclude = ["id"]

+ 18 - 6
urls.py

@@ -1,15 +1,27 @@
 from webservice_running.apiviews import *
 from rest_framework import routers
 from django.urls import path, include, re_path
-from webservice_running import views
+from . import views
 
-app_name = 'webservice_running'
+app_name = 'webservice'
 
 router = routers.DefaultRouter()
-router.register(r'webservice', OrdersLocalMVS)
+router.register(r'event', EventMVS)
+router.register(r'sportsman', SportsmanMVS)
+router.register(r'achievement', AchievementMVS)
+router.register(r'achievements', AchievementsMVS)
+router.register(r'blocked_sportsman', BlockedSportsmanMVS)
+router.register(r'browse_event', BrowseEventMVS)
+router.register(r'browse_sportsman', BrowseSportsmanMVS)
+router.register(r'event_gallery', EventGalleryMVS)
+router.register(r'participant', ParticipantMVS)
+router.register(r'saved_event', SavedEventMVS)
+router.register(r'saved_sportsman', SavedSportsmanMVS)
+router.register(r'sport_preferrence', SportPreferrenceMVS)
+router.register(r'sport', SportMVS)
+router.register(r'sportsman_gallery', SportsmanGalleryMVS)
 
 urlpatterns = [
-    path('order_reg/', views.order_reg, name="order_reg"),
-    path('', views.registration, name="registration"),
-    path('api/', include(router.urls), name="webservice_running_api"),
+    # path("", views.order_reg, name="order_reg"),
+    re_path(r'^api/', include(router.urls), name="webservice_running_api"),
 ]

+ 1 - 0
views/__init__.py

@@ -0,0 +1 @@
+from . import views

+ 0 - 0
views.py → views/views.py