Adicionar Certificados

parent 747c880e
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 mongoengine import Document, fields
from eventos.core.models import EventRef, UserRef
class Certified(Document):
description = fields.StringField(max_length=255, required=True)
type = fields.StringField(max_length=255, required=True)
emission = fields.DateTimeField(required=True)
key = fields.StringField(max_length=255, required=True)
owner = fields.EmbeddedDocumentField(UserRef, required=True)
event_ref = fields.EmbeddedDocumentField(EventRef, required=True)
new_certified = fields.ReferenceField("self", required=False)
from rest_framework_mongoengine import routers
from eventos.core.views import EventViewSet, SubmissionViewSet, UserViewSet
from eventos.core.views import CertifiedViewSet, EventViewSet, SubmissionViewSet, UserViewSet
router = routers.SimpleRouter()
router.register("user", UserViewSet)
router.register("event", EventViewSet)
router.register("submission", SubmissionViewSet)
router.register("certified", CertifiedViewSet)
from eventos.core.serializers.certified import CertifiedSerializer
from eventos.core.serializers.embedded import EventRefSerializer, UserRefSerializer
from eventos.core.serializers.event import EventSerializer
from eventos.core.serializers.submission import SubmissionSerializer
......
from rest_framework_mongoengine import serializers
from eventos.core.models import Certified
from eventos.core.serializers import EventRefSerializer, UserRefSerializer
class CertifiedSerializer(serializers.DocumentSerializer):
event_ref = EventRefSerializer(many=False)
owner = UserRefSerializer(many=False)
class Meta:
ref_name = "Certified"
model = Certified
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.user import UserViewSet
from rest_framework_mongoengine import viewsets
from eventos.core.models import Certified
from eventos.core.serializers import CertifiedSerializer
class CertifiedViewSet(viewsets.ModelViewSet):
queryset = Certified.objects.all()
serializer_class = CertifiedSerializer
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