Support editing event category in modals

This commit is contained in:
Cara Salter 2024-06-03 18:12:39 -04:00
parent b7ca654bf1
commit 0b3480dd52
3 changed files with 14 additions and 10 deletions

View file

@ -67,6 +67,7 @@ def update_create_event(id):
datetime.time.fromisoformat(start_time))
end = datetime.datetime.combine(datetime.date.fromisoformat(end_day),
datetime.time.fromisoformat(end_time))
category = request.form.get("category")
if id == 0:
# new event
@ -75,6 +76,7 @@ def update_create_event(id):
description=description,
location=location,
start_time=start,
category=category,
end_time=end)
db.session.add(e)
db.session.commit()
@ -88,6 +90,7 @@ def update_create_event(id):
e.location = location
e.start_time = start
e.end_time = end
e.category=category
db.session.commit()
current_app.logger.info(f"{current_user} is updating an existing event: {e.name}")

View file

@ -21,6 +21,8 @@ class User(db.Model, UserMixin):
phone = Column(String, nullable=True)
gender = Column(String, nullable=True)
def __str__(self):
return f"{self.first_name} {self.last_name} ({self.email})"
def create_json_output(lis):
hackers = []
@ -73,15 +75,7 @@ class Event(db.Model):
events = []
for e in lis:
events.append({
'id': e.id,
'name': e.name,
'description': e.description,
'location': e.location,
'start': e.start_time,
'end': e.end_time,
'category': e.category
})
events.append(e.create_json())
return events
@ -93,6 +87,7 @@ class Event(db.Model):
"location": self.location,
"start_time": self.start_time.isoformat(),
"end_time": self.end_time.isoformat(),
"category": self.category
}
def get_checkins(self):

View file

@ -65,6 +65,10 @@
{{ form.location(class="form-control") }}
{{ form.location.label() }}
</div>
<div class="form-floating mb-3">
{{ form.category(class="form-control") }}
{{ form.category.label() }}
</div>
<div class="row">
<div class="col">
<div class="form-floating mb-3 required">
@ -155,7 +159,8 @@
} else {
name = data.name,
description = data.description,
loc = data.location
loc = data.location,
category = data.category
start = new Date(data.start_time)
@ -180,6 +185,7 @@
modal.find('#start_time').val(start_time)
modal.find('#end_day').val(end_day)
modal.find('#end_time').val(end_time)
modal.find('#category').val(category)
});