Add image upload and fix css
This commit is contained in:
parent
f5a9029e82
commit
6464703381
5 changed files with 57 additions and 37 deletions
|
@ -31,6 +31,16 @@ body {
|
||||||
url('images/Background.png');
|
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{
|
.site-tagline{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 140px;
|
margin-top: 140px;
|
||||||
|
@ -53,14 +63,14 @@ body {
|
||||||
bottom: -30px;
|
bottom: -30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
.nav-ul {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
.nav-li {
|
||||||
display: inline;
|
display: inline;
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
@ -80,29 +90,21 @@ li {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-family: GlacialIndifference;
|
font-family: GlacialIndifference;
|
||||||
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.standard-a {
|
a {
|
||||||
color: black;
|
color: black;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
.standard-a:hover {
|
a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.biglink-a {
|
ul {
|
||||||
color: black;
|
list-style-position: inside;
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.biglink-a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
li a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-input{
|
.login-input{
|
||||||
|
@ -146,16 +148,6 @@ input[type=submit] {
|
||||||
font-family: GlacialIndifference;
|
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{
|
.signature{
|
||||||
font-family: Emitha-Script;
|
font-family: Emitha-Script;
|
||||||
font-size: 50px;
|
font-size: 50px;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<header>
|
<header>
|
||||||
<div class="main-nav">
|
<div class="main-nav">
|
||||||
<ul>
|
<ul class="nav-ul">
|
||||||
{% for page in pages %}
|
{% 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>
|
href="/{{page.name | lower}}">{{page.pretty_name}}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -6,7 +6,8 @@ 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("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("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"),
|
||||||
|
|
|
@ -1,10 +1,35 @@
|
||||||
import argparse
|
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__":
|
if __name__ == "__main__":
|
||||||
|
print("entering")
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Django utils for wedding site.')
|
parser = argparse.ArgumentParser(description='Django utils for wedding site.')
|
||||||
parser.add_argument('action', default = "upload_images",
|
parser.add_argument('action', default = "upload_images",
|
||||||
|
@ -13,3 +38,6 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.action == "upload_images":
|
||||||
|
upload_images(Path(args.source))
|
||||||
|
|
||||||
|
|
|
@ -50,13 +50,13 @@ def login_view(request):
|
||||||
user = authenticate(request, username="guest", password=token)
|
user = authenticate(request, username="guest", password=token)
|
||||||
if user is not None:
|
if user is not None:
|
||||||
login(request, user)
|
login(request, user)
|
||||||
return redirect("landing")
|
return redirect("home")
|
||||||
else:
|
else:
|
||||||
return redirect("index")
|
return redirect("index")
|
||||||
|
|
||||||
@login_required(login_url="/")
|
@login_required(login_url="/")
|
||||||
def landing(request):
|
def home(request):
|
||||||
return get_page("Landing")
|
return get_page("Home")
|
||||||
|
|
||||||
def get_page_header(site: Site):
|
def get_page_header(site: Site):
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ def get_page_header(site: Site):
|
||||||
def get_page_body(site: Site, page: Page):
|
def get_page_body(site: Site, page: Page):
|
||||||
|
|
||||||
header = get_page_header(site)
|
header = get_page_header(site)
|
||||||
body = markdown.markdown(page.content)
|
body = f"<div class=article-content>{markdown.markdown(page.content)}</div>"
|
||||||
return header + body
|
return header + body
|
||||||
|
|
||||||
def get_page(name:str):
|
def get_page(name:str):
|
||||||
|
@ -85,7 +85,6 @@ 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"]
|
||||||
|
|
||||||
db_images = Image.objects.filter(name=img_name)
|
db_images = Image.objects.filter(name=img_name)
|
||||||
if db_images:
|
if db_images:
|
||||||
img["src"] = db_images[0].content.url
|
img["src"] = db_images[0].content.url
|
||||||
|
@ -93,8 +92,8 @@ def get_page(name:str):
|
||||||
return HttpResponse(soup.prettify())
|
return HttpResponse(soup.prettify())
|
||||||
|
|
||||||
@login_required(login_url="/")
|
@login_required(login_url="/")
|
||||||
def schedule(request, name):
|
def schedule(request):
|
||||||
return get_page(name)
|
return get_page("Schedule")
|
||||||
|
|
||||||
@login_required(login_url="/")
|
@login_required(login_url="/")
|
||||||
def things_to_do(request):
|
def things_to_do(request):
|
||||||
|
|
Loading…
Reference in a new issue