Adicionar Tracks

parent 3edd735b
......@@ -2,5 +2,7 @@ from eventos.core.models.certified import Certified
from eventos.core.models.event import Event
from eventos.core.models.event_ref import EventRef
from eventos.core.models.submission import Submission
from eventos.core.models.track import Track
from eventos.core.models.track_ref import TrackRef
from eventos.core.models.user import User
from eventos.core.models.user_ref import UserRef
from mongoengine import Document, fields
from eventos.core.models import EventRef
class Track(Document):
starts_on = fields.DateTimeField()
ends_on = fields.DateTimeField()
ref_event = fields.EmbeddedDocumentField(EventRef)
from mongoengine import EmbeddedDocument, fields
from eventos.core.models import Track
class TrackRef(EmbeddedDocument):
id = fields.ReferenceField(Track, required=True)
starts_on = fields.DateTimeField()
ends_on = fields.DateTimeField()
from rest_framework_mongoengine import routers
from eventos.core.views import CertifiedViewSet, EventViewSet, SubmissionViewSet, UserViewSet
from eventos.core.views import CertifiedViewSet, EventViewSet, SubmissionViewSet, TrackViewSet, UserViewSet
router = routers.SimpleRouter()
router.register("user", UserViewSet)
router.register("event", EventViewSet)
router.register("submission", SubmissionViewSet)
router.register("certified", CertifiedViewSet)
router.register("track", TrackViewSet)
from eventos.core.serializers.certified import CertifiedSerializer
from eventos.core.serializers.embedded import EventRefSerializer, UserRefSerializer
from eventos.core.serializers.embedded import EventRefSerializer, TrackRefSerializer, UserRefSerializer
from eventos.core.serializers.event import EventSerializer
from eventos.core.serializers.submission import SubmissionSerializer
from eventos.core.serializers.track import TrackSerializer
from eventos.core.serializers.user import UserSerializer
from rest_framework_mongoengine import serializers
from eventos.core.models import EventRef, UserRef
from eventos.core.models import EventRef, TrackRef, UserRef
class UserRefSerializer(serializers.EmbeddedDocumentSerializer):
class Meta:
ref_name = "ref_user"
model = UserRef
class EventRefSerializer(serializers.EmbeddedDocumentSerializer):
class Meta:
ref_name = "ref_event"
model = EventRef
class TrackRefSerializer(serializers.EmbeddedDocumentSerializer):
class Meta:
ref_name = "ref_track"
model = TrackRef
from rest_framework_mongoengine import serializers
from eventos.core.models import Track
from eventos.core.serializers import EventRefSerializer
class TrackSerializer(serializers.DocumentSerializer):
ref_event = EventRefSerializer(many=False)
class Meta:
ref_name = "Track"
model = Track
from eventos.core.views.certified import CertifiedViewSet
from eventos.core.views.event import EventViewSet
from eventos.core.views.submission import SubmissionViewSet
from eventos.core.views.track import TrackViewSet
from eventos.core.views.user import UserViewSet
from rest_framework_mongoengine import viewsets
from eventos.core.models import Track
from eventos.core.serializers import TrackSerializer
class TrackViewSet(viewsets.ModelViewSet):
queryset = Track.objects.all()
serializer_class = TrackSerializer
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment