Compare commits

...

5 Commits

Author SHA1 Message Date
bfc2950a1d postgres 2025-04-06 15:28:56 -04:00
8c9bc213b0 merge 2025-04-06 13:47:21 -04:00
e288cd3f31 image update 2025-04-06 13:39:48 -04:00
10db56805f Merge pull request 'db-update' (#1) from add-mad-to-db into api-first
Reviewed-on: #1
Reviewed-by: dominic <me@domdit.com>
2025-04-03 20:00:12 -04:00
794bf82a1c db-update 2025-04-03 20:01:19 -04:00
40 changed files with 72 additions and 24 deletions

6
.gitignore vendored
View File

@ -1,6 +1,7 @@
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
*.pyc
# C extensions # C extensions
*.so *.so
@ -51,3 +52,8 @@ docs/_build/
*__pycache__/* *__pycache__/*
*.pyc *.pyc
run.sh
venv/
*.bak
scratch*

Binary file not shown.

Binary file not shown.

View File

@ -82,8 +82,12 @@ WSGI_APPLICATION = 'korabo.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.postgresql',
'NAME': BASE_DIR / 'db.sqlite3', 'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('DB_USER'),
'PASSWORD': os.getenv('DB_PASS'),
'HOST': os.getenv('DB_HOST'),
'PORT': os.getenv('DB_PORT'),
} }
} }
@ -131,3 +135,6 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
LOGIN_REDIRECT_URL = '/' LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/' LOGOUT_REDIRECT_URL = '/'
MEDIA_URL = "/media/"
MEDIA_ROOT = BASE_DIR / "media"

View File

@ -1,6 +1,7 @@
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from api.views.event import EventView from api.views.event import EventView
from api.views.event_division import EventDivisionView from api.views.event_division import EventDivisionView
from api.views.event_comment import EventCommentView from api.views.event_comment import EventCommentView
@ -20,3 +21,6 @@ urlpatterns = [
path('change_password/', views.change_password, name='change_password'), path('change_password/', views.change_password, name='change_password'),
path('password_change_done/', views.password_change_done, name='password_change_done') path('password_change_done/', views.password_change_done, name='password_change_done')
] ]
if settings.DEBUG: # new
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -12,3 +12,4 @@ requests==2.32.3
soupsieve==2.6 soupsieve==2.6
sqlparse==0.5.1 sqlparse==0.5.1
urllib3==2.3.0 urllib3==2.3.0
pillow==11.1.0

Binary file not shown.

View File

@ -0,0 +1,18 @@
# Generated by Django 4.2.16 on 2025-04-06 01:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('web', '0004_remove_event_participants_alter_eventcomment_event_and_more'),
]
operations = [
migrations.AddField(
model_name='event',
name='cover_image',
field=models.ImageField(blank=True, default=None, null=True, upload_to='event_cover_images/'),
),
]

View File

@ -10,6 +10,7 @@ class Event(BaseModel):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
name = models.TextField(blank=False, null=False) name = models.TextField(blank=False, null=False)
description = models.TextField(blank=False, null=False) description = models.TextField(blank=False, null=False)
cover_image = models.ImageField(blank=True, null=True, default=None, upload_to='event_cover_images/')
division = models.ForeignKey(EventDivision, on_delete=models.CASCADE) division = models.ForeignKey(EventDivision, on_delete=models.CASCADE)
start_date = models.DateTimeField(blank=False, null=False) start_date = models.DateTimeField(blank=False, null=False)
end_date = models.DateTimeField(blank=False, null=False) end_date = models.DateTimeField(blank=False, null=False)

View File

@ -1,26 +1,36 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block content %} {% block content %}
<table class="table">
<table class="table"> <thead>
<thead>
<tr>
<td>Event Name</td>
<td>Already Responded</td>
<td>Start Date</td>
<td>End Date</td>
</tr>
</thead>
<tbody>
{% for event in events %}
<tr> <tr>
<td><a href="{% url 'event' event.id %}">{{event.name}}</a></td> <td>Event Name</td>
<td>{{event.responses}}</td> <td>Already Responded</td>
<td>{{event.start_date|date:"m/d/Y"}}</td> <td>Start Date</td>
<td>{{event.end_date|date:"m/d/Y"}}</td> <td>End Date</td>
<td>img</td>
</tr> </tr>
{% endfor %} </thead>
</tbody> <tbody>
</table> {% for event in events %}
<div class="accordion-item">
<div class="accordion-item">
<h2 class="accordion-header" id="event-{{ event.id }}">
<button class="accordion-button collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#event-collapse-{{ event.id }}"
aria-expanded="true"
aria-controls="event-collapse-{{ event.id }}">{{ event.name }}</button>
</h2>
<div id="event-collapse-{{ event.id }}"
class="accordion-collapse collapse"
aria-labelledby="event-{{ event.id }}"
data-bs-parent="#accordionExample">
<div class="accordion-body">{{ event.description }}</div>
</div>
</div>
</div>
{% endfor %}
</tbody>
</table>
{% endblock %} {% endblock %}

View File

@ -18,6 +18,7 @@ def index(request):
'name': active_event.name, 'name': active_event.name,
'start_date': active_event.start_date.date(), 'start_date': active_event.start_date.date(),
'end_date': active_event.end_date.date(), 'end_date': active_event.end_date.date(),
'cover_image': active_event.cover_image,
'responses': ', '.join([x.user.username for x in active_event.availability_set.all()]) 'responses': ', '.join([x.user.username for x in active_event.availability_set.all()])
} }