Small clean to urls
This commit is contained in:
parent
ff7c31701e
commit
f5a9029e82
3 changed files with 25 additions and 8 deletions
|
@ -6,11 +6,10 @@ from . import views
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.index, name="index"),
|
path("", views.index, name="index"),
|
||||||
path('login', views.login_view, name="login"),
|
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("thingstodo", views.things_to_do, name="thingstodo"),
|
||||||
path("travel", views.travel, name="travel"),
|
path("travel", views.travel, name="travel"),
|
||||||
path("accommodation", views.accommodation, name="accommodation"),
|
path("accommodation", views.accommodation, name="accommodation"),
|
||||||
path("landing", views.landing, name="landing"),
|
|
||||||
path("faq", views.faq, name="faq"),
|
path("faq", views.faq, name="faq"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
15
wedding_site/primary/utils.py
Normal file
15
wedding_site/primary/utils.py
Normal 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()
|
||||||
|
|
|
@ -73,7 +73,7 @@ def get_page_body(site: Site, page: Page):
|
||||||
|
|
||||||
def get_page(name:str):
|
def get_page(name:str):
|
||||||
site = Site.objects.get(pk=1)
|
site = Site.objects.get(pk=1)
|
||||||
page = Page.objects.get(name=name)
|
page = Page.objects.get(name__iexact=name)
|
||||||
|
|
||||||
template = Template(_TEMPLATE)
|
template = Template(_TEMPLATE)
|
||||||
context = Context({"site": site,
|
context = Context({"site": site,
|
||||||
|
@ -85,13 +85,16 @@ def get_page(name:str):
|
||||||
|
|
||||||
for img in soup.find_all('img'):
|
for img in soup.find_all('img'):
|
||||||
img_name = img["src"]
|
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())
|
return HttpResponse(soup.prettify())
|
||||||
|
|
||||||
@login_required(login_url="/")
|
@login_required(login_url="/")
|
||||||
def schedule(request):
|
def schedule(request, name):
|
||||||
return get_page("Schedule")
|
return get_page(name)
|
||||||
|
|
||||||
@login_required(login_url="/")
|
@login_required(login_url="/")
|
||||||
def things_to_do(request):
|
def things_to_do(request):
|
||||||
|
@ -103,9 +106,9 @@ def travel(request):
|
||||||
|
|
||||||
@login_required(login_url="/")
|
@login_required(login_url="/")
|
||||||
def faq(request):
|
def faq(request):
|
||||||
return get_page("Faq")
|
return get_page("FAQ")
|
||||||
|
|
||||||
@login_required(login_url="/")
|
@login_required(login_url="/")
|
||||||
def accommodation(request):
|
def accommodation(request):
|
||||||
return get_page("Accomodation")
|
return get_page("Accommodation")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue