Small clean to urls

This commit is contained in:
jmsgrogan 2024-02-17 18:34:27 +00:00
parent ff7c31701e
commit f5a9029e82
3 changed files with 25 additions and 8 deletions

View file

@ -6,11 +6,10 @@ from . import views
urlpatterns = [
path("", views.index, name="index"),
path('login', views.login_view, name="login"),
path('schedule', views.schedule, name="schedule"),
path("landing", views.landing, name="landing"),
path("thingstodo", views.things_to_do, name="thingstodo"),
path("travel", views.travel, name="travel"),
path("accommodation", views.accommodation, name="accommodation"),
path("landing", views.landing, name="landing"),
path("faq", views.faq, name="faq"),
]

View file

@ -0,0 +1,15 @@
import argparse
def upload_images(path):
pass
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Django utils for wedding site.')
parser.add_argument('action', default = "upload_images",
help='Action to perform')
parser.add_argument('--source', help='Path to working items')
args = parser.parse_args()

View file

@ -73,7 +73,7 @@ def get_page_body(site: Site, page: Page):
def get_page(name:str):
site = Site.objects.get(pk=1)
page = Page.objects.get(name=name)
page = Page.objects.get(name__iexact=name)
template = Template(_TEMPLATE)
context = Context({"site": site,
@ -85,13 +85,16 @@ def get_page(name:str):
for img in soup.find_all('img'):
img_name = img["src"]
img["src"] = Image.objects.get(name=img_name).content.url
db_images = Image.objects.filter(name=img_name)
if db_images:
img["src"] = db_images[0].content.url
return HttpResponse(soup.prettify())
@login_required(login_url="/")
def schedule(request):
return get_page("Schedule")
def schedule(request, name):
return get_page(name)
@login_required(login_url="/")
def things_to_do(request):
@ -103,9 +106,9 @@ def travel(request):
@login_required(login_url="/")
def faq(request):
return get_page("Faq")
return get_page("FAQ")
@login_required(login_url="/")
def accommodation(request):
return get_page("Accomodation")
return get_page("Accommodation")