Add image upload and fix css

This commit is contained in:
jmsgrogan 2024-02-18 09:57:34 +00:00
parent f5a9029e82
commit 6464703381
5 changed files with 57 additions and 37 deletions

View file

@ -31,6 +31,16 @@ body {
url('images/Background.png');
}
img {
margin:0 auto;
width: 100%;
display: flex;
justify-content: center;
max-height:300px;
border-radius: 8px;
box-shadow: 0 4px 8px 0;
}
.site-tagline{
text-align: center;
margin-top: 140px;
@ -53,14 +63,14 @@ body {
bottom: -30px;
}
ul {
.nav-ul {
list-style-type: none;
margin: 0 auto;
padding: 0;
overflow: hidden;
}
li {
.nav-li {
display: inline;
float: left;
}
@ -80,29 +90,21 @@ li {
text-decoration: none;
font-size: 24px;
font-family: GlacialIndifference;
font-style: normal;
}
.standard-a {
a {
color: black;
text-decoration: none;
font-style: italic;
}
.standard-a:hover {
a:hover {
text-decoration: underline;
}
.biglink-a {
color: black;
text-decoration: none;
}
.biglink-a:hover {
text-decoration: underline;
}
li a:hover {
text-decoration: underline;
ul {
list-style-position: inside;
}
.login-input{
@ -146,16 +148,6 @@ input[type=submit] {
font-family: GlacialIndifference;
}
.jumbo-image {
margin:0 auto;
width: 100%;
display: flex;
justify-content: center;
max-height:300px;
border-radius: 8px;
box-shadow: 0 4px 8px 0;
}
.signature{
font-family: Emitha-Script;
font-size: 50px;

View file

@ -1,8 +1,8 @@
<header>
<div class="main-nav">
<ul>
<ul class="nav-ul">
{% for page in pages %}
<li><a class="nav-button"
<li class="nav-li"><a class="nav-button"
href="/{{page.name | lower}}">{{page.pretty_name}}</a></li>
{% endfor %}
</ul>

View file

@ -6,7 +6,8 @@ from . import views
urlpatterns = [
path("", views.index, name="index"),
path('login', views.login_view, name="login"),
path("landing", views.landing, name="landing"),
path("home", views.home, name="home"),
path("schedule", views.schedule, name="schedule"),
path("thingstodo", views.things_to_do, name="thingstodo"),
path("travel", views.travel, name="travel"),
path("accommodation", views.accommodation, name="accommodation"),

View file

@ -1,10 +1,35 @@
import argparse
from pathlib import Path
import logging
def upload_images(path):
import django
from django.core.files import File
django.setup()
from primary.models import Image
def upload_image(path: Path):
logging.info(f"Uploading: {path}")
filename = path.stem
img = Image(name=filename, alt_text=filename)
with path.open(mode='rb') as f:
img.content = File(f, name=path.name)
img.save()
def upload_images(path: Path):
print("checking: " + str(path))
for dir_entry in path.iterdir():
print(dir_entry)
if dir_entry.is_file():
upload_image(dir_entry)
pass
if __name__ == "__main__":
print("entering")
parser = argparse.ArgumentParser(description='Django utils for wedding site.')
parser.add_argument('action', default = "upload_images",
@ -13,3 +38,6 @@ if __name__ == "__main__":
args = parser.parse_args()
if args.action == "upload_images":
upload_images(Path(args.source))

View file

@ -50,13 +50,13 @@ def login_view(request):
user = authenticate(request, username="guest", password=token)
if user is not None:
login(request, user)
return redirect("landing")
return redirect("home")
else:
return redirect("index")
@login_required(login_url="/")
def landing(request):
return get_page("Landing")
def home(request):
return get_page("Home")
def get_page_header(site: Site):
@ -68,7 +68,7 @@ def get_page_header(site: Site):
def get_page_body(site: Site, page: Page):
header = get_page_header(site)
body = markdown.markdown(page.content)
body = f"<div class=article-content>{markdown.markdown(page.content)}</div>"
return header + body
def get_page(name:str):
@ -85,7 +85,6 @@ def get_page(name:str):
for img in soup.find_all('img'):
img_name = img["src"]
db_images = Image.objects.filter(name=img_name)
if db_images:
img["src"] = db_images[0].content.url
@ -93,8 +92,8 @@ def get_page(name:str):
return HttpResponse(soup.prettify())
@login_required(login_url="/")
def schedule(request, name):
return get_page(name)
def schedule(request):
return get_page("Schedule")
@login_required(login_url="/")
def things_to_do(request):