first commit

This commit is contained in:
2025-10-11 03:50:49 -05:00
parent fcdef3ffe1
commit 9e9668172c
353 changed files with 47535 additions and 0 deletions

0
leg_info/__init__.py Normal file
View File

14
leg_info/admin.py Normal file
View File

@@ -0,0 +1,14 @@
from django.contrib import admin
from .models import *
# class EventAdmin(admin.ModelAdmin):
# # prepopulated_fields = {"slug": ("shortname",)}
# list_display = ( "show_title", "event_type", "show_date",)
# list_filter = ("venue", "event_type")
# Register your models here.
admin.site.register(Organization)
admin.site.register(Snacker)
admin.site.register(Bill)

6
leg_info/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class LegInfoConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'leg_info'

View File

@@ -0,0 +1,55 @@
# Generated by Django 4.1.7 on 2023-03-12 21:57
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Organization',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64)),
('phone_number', models.CharField(blank=True, max_length=200, null=True)),
('email_address', models.CharField(blank=True, max_length=64, null=True)),
],
options={
'verbose_name_plural': 'Organizations',
'ordering': ['name'],
},
),
migrations.CreateModel(
name='Snacker',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64)),
('phone_number', models.CharField(blank=True, max_length=200, null=True)),
('email_address', models.CharField(blank=True, max_length=64, null=True)),
],
options={
'verbose_name_plural': 'Snackers',
'ordering': ['name'],
},
),
migrations.CreateModel(
name='Bill',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(blank=True, max_length=64, null=True)),
('bill_num', models.CharField(max_length=16)),
('description', models.CharField(blank=True, max_length=32, null=True)),
('org_tag', models.ManyToManyField(blank=True, to='leg_info.organization')),
('snax_tag', models.ManyToManyField(blank=True, to='leg_info.snacker')),
],
options={
'verbose_name_plural': 'Bills',
'ordering': ['bill_num'],
},
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 4.1.7 on 2023-03-12 22:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('events', '0004_alter_event_options_event_show_day_and_more'),
('leg_info', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='bill',
name='event_tag',
field=models.ManyToManyField(blank=True, to='events.event'),
),
]

View File

54
leg_info/models.py Normal file
View File

@@ -0,0 +1,54 @@
from django.db import models
from events.models import Event
# Create your models here.
class Organization(models.Model):
name = models.CharField(max_length=64)
phone_number = models.CharField(max_length=200, blank=True, null=True)
email_address = models.CharField(max_length=64, blank=True, null=True)
class Meta:
verbose_name_plural = "Organizations"
ordering = ['name']
def __unicode__(self):
return "%s" % self.name
def __str__(self):
return u'%s' % self.name
class Snacker(models.Model):
name = models.CharField(max_length=64)
phone_number = models.CharField(max_length=200, blank=True, null=True)
email_address = models.CharField(max_length=64, blank=True, null=True)
class Meta:
verbose_name_plural = "Snackers"
ordering = ['name']
def __unicode__(self):
return "%s" % self.name
def __str__(self):
return u'%s' % self.name
class Bill(models.Model):
name = models.CharField(max_length=64, blank=True, null=True)
bill_num = models.CharField(max_length=16)
description = models.CharField(max_length=32, blank=True, null=True)
org_tag = models.ManyToManyField(Organization, blank=True)
snax_tag = models.ManyToManyField(Snacker, blank=True)
event_tag = models.ManyToManyField(Event, blank=True)
class Meta:
verbose_name_plural = "Bills"
ordering = ['bill_num']
def __unicode__(self):
return "%s" % self.bill_num
def __str__(self):
return u'%s' % self.bill_num

24
leg_info/serializers.py Normal file
View File

@@ -0,0 +1,24 @@
from rest_framework import serializers
from django.contrib.auth.models import User
from .models import Event, Venue
############
## Events ##
############
class VenueSerializer(serializers.ModelSerializer):
class Meta:
model = Venue
fields = ('id', 'name', 'city')
# fields = '__all__'
class EventSerializer(serializers.ModelSerializer):
venue = VenueSerializer(many=False)
event_type = serializers.CharField(source='get_event_type_display')
# target_language = serializers.SerializerMethodField()
class Meta:
model = Event
fields = '__all__'
depth = 2
# fields = ('id', 'name',)

3
leg_info/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

22
leg_info/urls.py Normal file
View File

@@ -0,0 +1,22 @@
"""ds_events URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include, re_path
from .views import *
urlpatterns = [
re_path(r'^events/', EventsAPIView.as_view(), name="get-events"),
]

29
leg_info/views.py Normal file
View File

@@ -0,0 +1,29 @@
from django.shortcuts import render
from datetime import datetime, timedelta
import pytz
from .models import *
from .serializers import *
from django.db.models import Q
from rest_framework import generics
from rest_framework.decorators import authentication_classes, permission_classes
from rest_framework.authentication import SessionAuthentication, BasicAuthentication
from rest_framework.permissions import IsAuthenticated
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters
td = timedelta(hours=8)
odt = datetime.now() - td
# Create your views here.
@permission_classes([])
@authentication_classes([])
class EventsAPIView(generics.ListAPIView):
serializer_class = EventSerializer
queryset = Event.objects.filter(show_date__gte=odt).order_by('show_date')
filter_backends = [DjangoFilterBackend, filters.SearchFilter]
filterset_fields = ['show_title', 'event_type', 'show_date', 'show_day']
search_fields = ['show_title', 'event_type']