Enzo Yair

Merge branch 'feature/endpoint_evento' into 'develop'

Feature/endpoint evento

Feature:
-Se crea endpoint de evento

Test resultado:
======================================================================================================== 3 passed in 2.28s ========================================================================================================

See merge request !3
from rest_framework import viewsets
from rest_framework.permissions import IsAuthenticated
from .models import Evento
from .serializers import EventoSerializer
class EventoViewSets(viewsets.ReadOnlyModelViewSet):
queryset = Evento.objects.all().order_by('id')
serializer_class = EventoSerializer
permission_classes = [IsAuthenticated,]
lookup_field = 'id'
... ...
from rest_framework_json_api import serializers
from .models import Evento
class EventoSerializer(serializers.ModelSerializer):
class Meta:
model = Evento
fields = (
'titulo',
'categoria',
'fecha_inicio',
'hora_inicio',
'fecha_final',
'hora_fin',
'fechas',
'descripcion',
'direccion',
'url',
'organismo',
'dependencia',
'imagen',
)
\ No newline at end of file
... ...
from factory import faker, django
from datetime import date
from evento.models import Evento
class EventoFactory(django.DjangoModelFactory):
class Meta:
model = Evento
titulo = faker.Faker(provider='sentence', nb_words=50)
categoria = faker.Faker(provider='sentence', nb_words=30)
direccion = 'https://maps.app.goo.gl/CNwbHBx5zq1VDje57'
descripcion = faker.Faker(provider='sentence', nb_words=30)
fecha_inicio = date(2024, 1, 1)
hora_inicio = '10:00:00'
fecha_final = date(2024, 1, 2)
hora_fin = '11:20:47'
\ No newline at end of file
... ...
import pytest
from rest_framework import status
from django.contrib.auth.models import User
from django.urls import reverse
from rest_framework.test import APIClient
from evento.tests.factories import EventoFactory
@pytest.mark.django_db
def test_evento_list():
cliente = APIClient()
user = User.objects.create_user(username='admin', email='admin@example.com', password='password123')
cliente.force_authenticate(user=user)
EventoFactory.create_batch(size=4)
endpoint = reverse('evento-list')
response = cliente.get(path=endpoint)
assert response.status_code == status.HTTP_200_OK
... ...
import factory
from factory import SubFactory, faker, django
from organismo.models import Organismo, Dependencia
... ...
from rest_framework import routers
from organismo import api as organismo_api
from evento import api as evento_api
# Define routes
router = routers.DefaultRouter()
router.register(prefix='organismo', viewset=organismo_api.OrganismoViewSets)
router.register(prefix='dependencia', viewset=organismo_api.DependenciaViewSets)
\ No newline at end of file
router.register(prefix='dependencia', viewset=organismo_api.DependenciaViewSets)
router.register(prefix='evento', viewset=evento_api.EventoViewSets)
... ...
... ... @@ -85,10 +85,9 @@ ROOT_URLCONF = 'project.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'project.wsgi.application'
LANGUAGE_CODE = 'es-ar'
LANGUAGE_CODE = 'es-AR'
TIME_ZONE = 'America/Argentina/Catamarca'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LANGUAGES = [
... ...