Skip to content

Commit

Permalink
Merge pull request pycontw#1132 from pycontw/rm-schedule-model-and-views
Browse files Browse the repository at this point in the history
chore: remove deprecated schedule model, views, page, ...etc
  • Loading branch information
mattwang44 committed Apr 24, 2024
2 parents 0621af7 + 134b60e commit 6fb264f
Show file tree
Hide file tree
Showing 74 changed files with 641 additions and 5,836 deletions.
13 changes: 1 addition & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ psycopg2 = "2.9.9"
pytz = "2024.1"
requests = "2.31.0"
sorl-thumbnail = "12.10.0"
sortedcontainers = "2.4.0"
tabulate = "0.9.0"
uwsgi = "2.0.24"
Pillow = "10.3.0"
Expand Down
4 changes: 0 additions & 4 deletions src/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,5 @@ def sponsors(request):
}


def events(request):
return {'schedule_redirect_url': settings.SCHEDULE_REDIRECT_URL}


def frontend_host(request):
return {'FRONTEND_HOST': settings.FRONTEND_HOST}
22 changes: 2 additions & 20 deletions src/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
import os

import pytest
from django.conf import settings
from django.utils.translation import activate
from pytest_django.asserts import assertRedirects

from events.models import Schedule


@pytest.mark.django_db
Expand Down Expand Up @@ -97,14 +93,8 @@ def test_content_pages(client, parser, content_page_full_path):
assert response.status_code == 200, content_page_full_path


@pytest.fixture
def schedule(db):
"""Generate a schedule to prevent the schedule page from returning 404.
"""
return Schedule.objects.create(html='<div></div>')


def test_content_pages_links(client, parser, schedule, content_page_full_path):
@pytest.mark.django_db
def test_content_pages_links(client, parser, content_page_full_path):
"""Test to make sure all in-site links in a content page work.
"""
if '/surveys/conference/' in content_page_full_path:
Expand All @@ -116,14 +106,6 @@ def test_content_pages_links(client, parser, schedule, content_page_full_path):
link_status_codes = []
for tag in link_tags:
link = tag.get('href')
if "/events/schedule/" in link \
and settings.SCHEDULE_REDIRECT_URL:
assertRedirects(
client.get(link),
settings.SCHEDULE_REDIRECT_URL,
fetch_redirect_response=False
)
continue
try:
status = client.get(link, follow=True).status_code
except Exception: # Catch internal server error for better reporting.
Expand Down
8 changes: 0 additions & 8 deletions src/events/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
KeynoteEvent,
ProposedTalkEvent,
ProposedTutorialEvent,
Schedule,
SponsoredEvent,
Time,
)
Expand Down Expand Up @@ -208,10 +207,3 @@ class SponsoredEventAdmin(admin.ModelAdmin):
search_fields = ['title', 'abstract']
prepopulated_fields = {'slug': ['title']}
raw_id_fields = ['host']


@admin.register(Schedule)
class ScheduleAdmin(admin.ModelAdmin):
fields = ['html', 'created_at']
readonly_fields = ['created_at']
list_display = ['created_at']
8 changes: 1 addition & 7 deletions src/events/forms.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
from django import forms

from .models import CustomEvent, Schedule


class ScheduleCreationForm(forms.ModelForm):
class Meta:
model = Schedule
fields = ['html']
from .models import CustomEvent


class CustomEventForm(forms.ModelForm):
Expand Down
4 changes: 2 additions & 2 deletions src/events/management/commands/import_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from django.core.management.base import BaseCommand
from django.utils.dateparse import parse_time

from events.models import Location, Time
from events.renderers import EVENT_CLASSES
from events.models import CustomEvent, KeynoteEvent, Location, ProposedTalkEvent, SponsoredEvent, Time

cst = pytz.timezone('Asia/Taipei')

EVENT_CLASSES = (CustomEvent, KeynoteEvent, ProposedTalkEvent, SponsoredEvent)
DAYS = list(settings.EVENTS_DAY_NAMES.keys())


Expand Down
16 changes: 16 additions & 0 deletions src/events/migrations/0053_delete_schedule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.2.25 on 2024-04-15 09:07

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('events', '0052_remove_sponsoredevent_prefer_time'),
]

operations = [
migrations.DeleteModel(
name='Schedule',
),
]
36 changes: 0 additions & 36 deletions src/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,6 @@ class Location:
R4 = '7-r4'
OTHER = '8-oth'

@classmethod
def get_md_width(cls, value):
return {
'2-all': 4,
'3-r012': 3,
'4-r0': 1,
'5-r1': 1,
'6-r2': 1,
'1-r3': 1,
'7-r4': 1,
'8-oth': 1,
}[value]


EVENT_ROOMS = {Location.R0, Location.R1, Location.R2, Location.R3, Location.R4}


class BaseEvent(ConferenceRelated):
"""Base interface for all events in the schedule.
Expand Down Expand Up @@ -455,23 +439,3 @@ def get_absolute_url(self):
return reverse('events_tutorial_detail', kwargs={
'pk': self.proposal.pk,
})


class Schedule(ConferenceRelated):

html = models.TextField(
verbose_name=_('HTML'),
)
created_at = models.DateTimeField(
verbose_name=_('created at'),
auto_now_add=True,
)

class Meta:
verbose_name = _('Schedule')
verbose_name_plural = _('Schedules')
ordering = ['-created_at']
get_latest_by = 'created_at'

def __str__(self):
return gettext('Schedule created at {}').format(self.created_at)
Loading

0 comments on commit 6fb264f

Please sign in to comment.