Support editing event category in modals
This commit is contained in:
parent
7fc06bde11
commit
a3c89dd478
3 changed files with 14 additions and 10 deletions
|
@ -67,6 +67,7 @@ def update_create_event(id):
|
||||||
datetime.time.fromisoformat(start_time))
|
datetime.time.fromisoformat(start_time))
|
||||||
end = datetime.datetime.combine(datetime.date.fromisoformat(end_day),
|
end = datetime.datetime.combine(datetime.date.fromisoformat(end_day),
|
||||||
datetime.time.fromisoformat(end_time))
|
datetime.time.fromisoformat(end_time))
|
||||||
|
category = request.form.get("category")
|
||||||
|
|
||||||
if id == 0:
|
if id == 0:
|
||||||
# new event
|
# new event
|
||||||
|
@ -75,6 +76,7 @@ def update_create_event(id):
|
||||||
description=description,
|
description=description,
|
||||||
location=location,
|
location=location,
|
||||||
start_time=start,
|
start_time=start,
|
||||||
|
category=category,
|
||||||
end_time=end)
|
end_time=end)
|
||||||
db.session.add(e)
|
db.session.add(e)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -88,6 +90,7 @@ def update_create_event(id):
|
||||||
e.location = location
|
e.location = location
|
||||||
e.start_time = start
|
e.start_time = start
|
||||||
e.end_time = end
|
e.end_time = end
|
||||||
|
e.category=category
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
current_app.logger.info(f"{current_user} is updating an existing event: {e.name}")
|
current_app.logger.info(f"{current_user} is updating an existing event: {e.name}")
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ class User(db.Model, UserMixin):
|
||||||
phone = Column(String, nullable=True)
|
phone = Column(String, nullable=True)
|
||||||
gender = 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):
|
def create_json_output(lis):
|
||||||
hackers = []
|
hackers = []
|
||||||
|
|
||||||
|
@ -73,15 +75,7 @@ class Event(db.Model):
|
||||||
events = []
|
events = []
|
||||||
|
|
||||||
for e in lis:
|
for e in lis:
|
||||||
events.append({
|
events.append(e.create_json())
|
||||||
'id': e.id,
|
|
||||||
'name': e.name,
|
|
||||||
'description': e.description,
|
|
||||||
'location': e.location,
|
|
||||||
'start': e.start_time,
|
|
||||||
'end': e.end_time,
|
|
||||||
'category': e.category
|
|
||||||
})
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
|
|
||||||
|
@ -93,6 +87,7 @@ class Event(db.Model):
|
||||||
"location": self.location,
|
"location": self.location,
|
||||||
"start_time": self.start_time.isoformat(),
|
"start_time": self.start_time.isoformat(),
|
||||||
"end_time": self.end_time.isoformat(),
|
"end_time": self.end_time.isoformat(),
|
||||||
|
"category": self.category
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_checkins(self):
|
def get_checkins(self):
|
||||||
|
|
|
@ -65,6 +65,10 @@
|
||||||
{{ form.location(class="form-control") }}
|
{{ form.location(class="form-control") }}
|
||||||
{{ form.location.label() }}
|
{{ form.location.label() }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
{{ form.category(class="form-control") }}
|
||||||
|
{{ form.category.label() }}
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="form-floating mb-3 required">
|
<div class="form-floating mb-3 required">
|
||||||
|
@ -155,7 +159,8 @@
|
||||||
} else {
|
} else {
|
||||||
name = data.name,
|
name = data.name,
|
||||||
description = data.description,
|
description = data.description,
|
||||||
loc = data.location
|
loc = data.location,
|
||||||
|
category = data.category
|
||||||
|
|
||||||
start = new Date(data.start_time)
|
start = new Date(data.start_time)
|
||||||
|
|
||||||
|
@ -180,6 +185,7 @@
|
||||||
modal.find('#start_time').val(start_time)
|
modal.find('#start_time').val(start_time)
|
||||||
modal.find('#end_day').val(end_day)
|
modal.find('#end_day').val(end_day)
|
||||||
modal.find('#end_time').val(end_time)
|
modal.find('#end_time').val(end_time)
|
||||||
|
modal.find('#category').val(category)
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue