Commit 22c7854f authored by berumuron's avatar berumuron
Browse files

add: #4 List events by project

parent 0e0f80fb
......@@ -99,6 +99,26 @@ class Event:
event = cursor.fetchone()
@classmethod
def items_by_project(cls, project_id):
database = db.get_db()
cursor = database.execute(
"SELECT * FROM events WHERE project_id = ?", (project_id,)
)
event = cursor.fetchone()
while event:
yield cls(
event["id"],
event["title"],
event["date"],
event["is_private"],
event["project_id"],
event["description"],
)
event = cursor.fetchone()
@classmethod
def find_by_id(cls, event_id):
database = db.get_db()
......@@ -150,6 +170,9 @@ class Project:
self.responsible = responsible
self.description = description
def events(self):
return Event.items_by_project(self.id)
@classmethod
def items(cls):
database = db.get_db()
......
......@@ -428,6 +428,11 @@ button.button-ghost {
margin-top: 1rem;
}
.project .events {
margin-top: 1rem;
margin-left: .5rem;
}
/* Folder system */
.folder.folder-folded .folder-container {
display: none;
......
......@@ -54,6 +54,41 @@
{% endif %}
</header>
{% endif %}
<ul class="events">
{% for event in project.events() if g.current_user or not event.is_private %}
<li class="event {{ 'event-private' if event.is_private }} {{ 'folder folder-folded' if event.description }}">
<span class="event-date">
{{ event.date.strftime('%d %b') }}
</span>
{% if event.description %}
<button class="folder-toggle">
{{ event.title }}
</button>
{% else %}
{{ event.title }}
{% endif %}
{% if g.current_user %}
<button
class="button-ghost event-delete"
data-confirm="Êtes-vous certain·e de vouloir supprimer cet évènement ?"
data-action="{{ url_for('events.delete', event_id=event.id ) }}"
data-method="delete"
>
Supprimer
</button>
{% endif %}
{% if event.description %}
<div class="event-description folder-container">
{{ event.description|markdown }}
</div>
{% endif %}
</li>
{% endfor %}
</ul>
</section>
{% endfor %}
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment