Browse Source

routes sorted

graphics
Cailean Finn 6 months ago
parent
commit
3a40026cf8
  1. 32
      app.py
  2. 1
      public/css/styles.css
  3. 19
      templates/article.html
  4. 2
      templates/list.html

32
app.py

@ -31,10 +31,41 @@ def exhibitions():
def conference(): def conference():
return render_template('list.html', title='Conferences') return render_template('list.html', title='Conferences')
@app.route('/<type>/<title>')
def event_article(type, title):
data = get_content_by_title(title, type)
print(data)
return render_template('article.html', title=title)
def get_all_content(type): def get_all_content(type):
content_list = [] content_list = []
entries = client.entries({'content_type': type}) entries = client.entries({'content_type': type})
for entry in entries: for entry in entries:
date_time_obj = getattr(entry, f'{type}_date_time')
date_str, time_str = format_datetime(date_time_obj)
end_time_str = getattr(entry, f'{type}_end_date_time')
end_time_str = end_time_str.strftime('%I%p').upper().lstrip('0')
content = {
'title': getattr(entry, f'title_of_{type}'),
'information': getattr(entry, f'{type}_information'),
'image': 'https:{0}'.format(getattr(entry, f'{type}_reference_image').url()),
'artists': getattr(entry, f'{type}_artists'),
'date': date_str,
'time': time_str,
'end_time': end_time_str,
'location': getattr(entry, f'{type}_location')
}
content_list.append(content)
return content_list
def get_content_by_title(title, pre_type):
content_list = []
type = pre_type[:-1]
entries = client.entries({'query': title, 'limit': 1})
for entry in entries:
date_time_obj = getattr(entry, f'{type}_date_time') date_time_obj = getattr(entry, f'{type}_date_time')
date_str, time_str = format_datetime(date_time_obj) date_str, time_str = format_datetime(date_time_obj)
end_time_str = getattr(entry, f'{type}_end_date_time') end_time_str = getattr(entry, f'{type}_end_date_time')
@ -50,7 +81,6 @@ def get_all_content(type):
'location': getattr(entry, f'{type}_location') 'location': getattr(entry, f'{type}_location')
} }
content_list.append(content) content_list.append(content)
print(content_list)
return content_list return content_list
def format_datetime(dt): def format_datetime(dt):

1
public/css/styles.css

@ -86,6 +86,7 @@ hr {
padding-right: 50px; padding-right: 50px;
overflow-y: scroll; overflow-y: scroll;
box-sizing: border-box; /* Include padding in the height calculation */ box-sizing: border-box; /* Include padding in the height calculation */
flex: 1;
} }
#main-text { #main-text {

19
templates/article.html

@ -0,0 +1,19 @@
{% extends "base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div id="main-wrapper">
{% include '_nav.html' %}
<div id="main-container">
<div id="article-container">
</div>
</div>
<hr>
<div id="page-header">
<div>/{{ title }}</div>
</div>
</div>
<div id="container"></div>
{% endblock content %}

2
templates/list.html

@ -12,7 +12,7 @@
<div id="main-container"> <div id="main-container">
<div id="list-container"> <div id="list-container">
{% for event in content %} {% for event in content %}
<a href='/'> <a href='/{{ title.lower() }}/{{ event.title }}'>
<div class="list"> <div class="list">
<div class="list-image"> <div class="list-image">
<img src="{{ event.image }}" alt="{{ event.title }}"> <img src="{{ event.image }}" alt="{{ event.title }}">

Loading…
Cancel
Save