Skip to content

Commit

Permalink
Merge branch 'main' into merge-upstream-with-issue-206-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
AzaniaBG authored Nov 1, 2023
2 parents 88efd5e + 3613f0d commit 2aa990e
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 31 deletions.
6 changes: 3 additions & 3 deletions app/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from django.contrib.auth.forms import UsernameField
from django.utils.translation import gettext_lazy as _

from .models import Event
from .models import Faq
from .models import FaqViewed
from .models import Location
from .models import PermissionType
from .models import PracticeArea
from .models import ProgramArea
from .models import Project
from .models import RecurringEvent
from .models import Skill
from .models import SponsorPartner
from .models import StackElementType
Expand Down Expand Up @@ -120,8 +120,8 @@ class ProjectAdmin(admin.ModelAdmin):
)


@admin.register(RecurringEvent)
class RecurringEventAdmin(admin.ModelAdmin):
@admin.register(Event)
class EventAdmin(admin.ModelAdmin):
list_display = (
"name",
"start_time",
Expand Down
8 changes: 4 additions & 4 deletions app/core/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from rest_framework import serializers
from timezone_field.rest_framework import TimeZoneSerializerField

from core.models import Event
from core.models import Faq
from core.models import FaqViewed
from core.models import Location
from core.models import PermissionType
from core.models import PracticeArea
from core.models import ProgramArea
from core.models import Project
from core.models import RecurringEvent
from core.models import Skill
from core.models import SponsorPartner
from core.models import StackElementType
Expand Down Expand Up @@ -100,11 +100,11 @@ class Meta:
)


class RecurringEventSerializer(serializers.ModelSerializer):
"""Used to retrieve recurring_event info"""
class EventSerializer(serializers.ModelSerializer):
"""Used to retrieve event info"""

class Meta:
model = RecurringEvent
model = Event
fields = (
"uuid",
"name",
Expand Down
4 changes: 2 additions & 2 deletions app/core/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from django.urls import path
from rest_framework import routers

from .views import EventViewSet
from .views import FaqViewedViewSet
from .views import FaqViewSet
from .views import LocationViewSet
from .views import PermissionTypeViewSet
from .views import PracticeAreaViewSet
from .views import ProgramAreaViewSet
from .views import ProjectViewSet
from .views import RecurringEventViewSet
from .views import SkillViewSet
from .views import SponsorPartnerViewSet
from .views import StackElementTypeViewSet
Expand All @@ -19,7 +19,7 @@
router = routers.SimpleRouter()
router.register(r"users", UserViewSet, basename="user")
router.register(r"projects", ProjectViewSet, basename="project")
router.register(r"recurring-events", RecurringEventViewSet, basename="recurring-event")
router.register(r"events", EventViewSet, basename="event")
router.register(r"practice-areas", PracticeAreaViewSet, basename="practice-area")
router.register(r"sponsor-partners", SponsorPartnerViewSet, basename="sponsor-partner")
router.register(r"faqs", FaqViewSet, basename="faq")
Expand Down
22 changes: 11 additions & 11 deletions app/core/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
from rest_framework.permissions import IsAuthenticated
from rest_framework.permissions import IsAuthenticatedOrReadOnly

from ..models import Event
from ..models import Faq
from ..models import FaqViewed
from ..models import Location
from ..models import PermissionType
from ..models import PracticeArea
from ..models import ProgramArea
from ..models import Project
from ..models import RecurringEvent
from ..models import Skill
from ..models import SponsorPartner
from ..models import StackElementType
from ..models import Technology
from .serializers import EventSerializer
from .serializers import FaqSerializer
from .serializers import FaqViewedSerializer
from .serializers import LocationSerializer
from .serializers import PermissionTypeSerializer
from .serializers import PracticeAreaSerializer
from .serializers import ProgramAreaSerializer
from .serializers import ProjectSerializer
from .serializers import RecurringEventSerializer
from .serializers import SkillSerializer
from .serializers import SponsorPartnerSerializer
from .serializers import StackElementTypeSerializer
Expand Down Expand Up @@ -128,17 +128,17 @@ class ProjectViewSet(viewsets.ModelViewSet):


@extend_schema_view(
list=extend_schema(description="Return a list of all the recurring events"),
create=extend_schema(description="Create a new recurring event"),
retrieve=extend_schema(description="Return the details of a recurring event"),
destroy=extend_schema(description="Delete a recurring event"),
update=extend_schema(description="Update a recurring event"),
partial_update=extend_schema(description="Patch a recurring event"),
list=extend_schema(description="Return a list of all the events"),
create=extend_schema(description="Create a new event"),
retrieve=extend_schema(description="Return the details of an event"),
destroy=extend_schema(description="Delete an event"),
update=extend_schema(description="Update an event"),
partial_update=extend_schema(description="Patch an event"),
)
class RecurringEventViewSet(viewsets.ModelViewSet):
class EventViewSet(viewsets.ModelViewSet):
permission_classes = [IsAuthenticated]
queryset = RecurringEvent.objects.all()
serializer_class = RecurringEventSerializer
queryset = Event.objects.all()
serializer_class = EventSerializer


@extend_schema_view(
Expand Down
17 changes: 17 additions & 0 deletions app/core/migrations/0018_rename_recurringevent_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.0.10 on 2023-10-25 04:56

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0017_delete_language'),
]

operations = [
migrations.RenameModel(
old_name='RecurringEvent',
new_name='Event',
),
]
1 change: 1 addition & 0 deletions app/core/migrations/max_migration.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0018_rename_recurringevent_event
4 changes: 2 additions & 2 deletions app/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def __str__(self):
return f"{self.name}"


class RecurringEvent(AbstractBaseModel):
class Event(AbstractBaseModel):
"""
Recurring Events
Events
"""

name = models.CharField(max_length=255)
Expand Down
6 changes: 3 additions & 3 deletions app/core/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import pytest
from rest_framework.test import APIClient

from ..models import Event
from ..models import Faq
from ..models import FaqViewed
from ..models import Location
from ..models import PermissionType
from ..models import PracticeArea
from ..models import ProgramArea
from ..models import Project
from ..models import RecurringEvent
from ..models import Skill
from ..models import SponsorPartner
from ..models import StackElementType
Expand Down Expand Up @@ -49,8 +49,8 @@ def project():


@pytest.fixture
def recurring_event(project):
return RecurringEvent.objects.create(name="Test Recurring Event", project=project)
def event(project):
return Event.objects.create(name="Test Event", project=project)


@pytest.fixture
Expand Down
8 changes: 4 additions & 4 deletions app/core/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ME_URL = reverse("my_profile")
USERS_URL = reverse("user-list")
RECURRING_EVENTS_URL = reverse("recurring-event-list")
EVENTS_URL = reverse("event-list")
PRACTICE_AREA_URL = reverse("practice-area-list")
FAQS_URL = reverse("faq-list")
FAQS_VIEWED_URL = reverse("faq-viewed-list")
Expand Down Expand Up @@ -154,8 +154,8 @@ def test_user_actions(client_name, action, endpoint, payload, expected_status, r
assert res.status_code == expected_status


def test_create_recurring_event(auth_client, project):
"""Test that we can create a recurring event"""
def test_create_event(auth_client, project):
"""Test that we can create an event"""

payload = {
"name": "Test Weekly team meeting",
Expand All @@ -165,7 +165,7 @@ def test_create_recurring_event(auth_client, project):
"additional_info": "Test description",
"project": project.uuid,
}
res = auth_client.post(RECURRING_EVENTS_URL, payload)
res = auth_client.post(EVENTS_URL, payload)
assert res.status_code == status.HTTP_201_CREATED
assert res.data["name"] == payload["name"]

Expand Down
4 changes: 2 additions & 2 deletions app/core/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def test_project(project):
assert str(project) == "Test Project"


def test_recurring_event(recurring_event):
assert str(recurring_event) == "Test Recurring Event"
def test_event(event):
assert str(event) == "Test Event"


def test_practice_area(practice_area):
Expand Down
1 change: 1 addition & 0 deletions app/peopledepot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"drf_spectacular",
"phonenumber_field",
"timezone_field",
"django_linear_migrations",
# Local
"core",
]
Expand Down
1 change: 1 addition & 0 deletions app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ black~=22.3.0
cryptography~=37.0.2
Django~=4.0.1
django-extensions~=3.1.5
django-linear-migrations~=2.12.0
django-phonenumber-field[phonenumbers]~=6.3.0
django-timezone-field==5.0
djangorestframework~=3.13.1
Expand Down

0 comments on commit 2aa990e

Please sign in to comment.