Skip to content

Commit a3c89dd

Browse files
committed
Support editing event category in modals
1 parent 7fc06bd commit a3c89dd

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

goathacks/admin/events.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def update_create_event(id):
6767
datetime.time.fromisoformat(start_time))
6868
end = datetime.datetime.combine(datetime.date.fromisoformat(end_day),
6969
datetime.time.fromisoformat(end_time))
70+
category = request.form.get("category")
7071

7172
if id == 0:
7273
# new event
@@ -75,6 +76,7 @@ def update_create_event(id):
7576
description=description,
7677
location=location,
7778
start_time=start,
79+
category=category,
7880
end_time=end)
7981
db.session.add(e)
8082
db.session.commit()
@@ -88,6 +90,7 @@ def update_create_event(id):
8890
e.location = location
8991
e.start_time = start
9092
e.end_time = end
93+
e.category=category
9194
db.session.commit()
9295
current_app.logger.info(f"{current_user} is updating an existing event: {e.name}")
9396

goathacks/models.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class User(db.Model, UserMixin):
2121
phone = Column(String, nullable=True)
2222
gender = Column(String, nullable=True)
2323

24+
def __str__(self):
25+
return f"{self.first_name} {self.last_name} ({self.email})"
2426
def create_json_output(lis):
2527
hackers = []
2628

@@ -73,15 +75,7 @@ def create_json_output(lis):
7375
events = []
7476

7577
for e in lis:
76-
events.append({
77-
'id': e.id,
78-
'name': e.name,
79-
'description': e.description,
80-
'location': e.location,
81-
'start': e.start_time,
82-
'end': e.end_time,
83-
'category': e.category
84-
})
78+
events.append(e.create_json())
8579

8680
return events
8781

@@ -93,6 +87,7 @@ def create_json(self):
9387
"location": self.location,
9488
"start_time": self.start_time.isoformat(),
9589
"end_time": self.end_time.isoformat(),
90+
"category": self.category
9691
}
9792

9893
def get_checkins(self):

goathacks/templates/events/list.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ <h1 class="modal-title fs-5" id="editModalLabel">Event</h1>
6565
{{ form.location(class="form-control") }}
6666
{{ form.location.label() }}
6767
</div>
68+
<div class="form-floating mb-3">
69+
{{ form.category(class="form-control") }}
70+
{{ form.category.label() }}
71+
</div>
6872
<div class="row">
6973
<div class="col">
7074
<div class="form-floating mb-3 required">
@@ -155,7 +159,8 @@ <h1 class="modal-title fs-5" id="editModalLabel">Event</h1>
155159
} else {
156160
name = data.name,
157161
description = data.description,
158-
loc = data.location
162+
loc = data.location,
163+
category = data.category
159164

160165
start = new Date(data.start_time)
161166

@@ -180,6 +185,7 @@ <h1 class="modal-title fs-5" id="editModalLabel">Event</h1>
180185
modal.find('#start_time').val(start_time)
181186
modal.find('#end_day').val(end_day)
182187
modal.find('#end_time').val(end_time)
188+
modal.find('#category').val(category)
183189

184190

185191
});

0 commit comments

Comments
 (0)