Skip to content

Commit 0aade41

Browse files
committed
minor fixes. WIP
1 parent f64ee49 commit 0aade41

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/pycamp_bot/commands/wizard.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def compute_wizards_slots(pycamp):
6363
(slot_start, slot_end)
6464
)
6565
current_period = slot_end
66-
print(len(slots), slots)
66+
6767
slots = clean_wizards_free_slots(pycamp, slots)
6868

6969
return slots
@@ -197,21 +197,21 @@ def persist_wizards_schedule_in_db(pycamp):
197197
async def schedule_wizards(update, context):
198198
_, pycamp = get_active_pycamp()
199199

200-
persist_wizards_schedule_in_db(pycamp)
200+
n = pycamp.clear_wizards_schedule()
201+
logger.info("Deleted wizards schedule ({} records)".format(n))
201202

202-
notify_schedule_to_wizards(update, context, pycamp)
203+
persist_wizards_schedule_in_db(pycamp)
203204

205+
await notify_schedule_to_wizards(update, context, pycamp)
204206

205-
async def show_wizards_schedule(update, context):
206-
_, pycamp = get_active_pycamp()
207207

208-
agenda = WizardAtPycamp.select().where(pycamp == pycamp).order_by(WizardAtPycamp.init)
208+
def format_wizards_schedule(agenda):
209209
per_day = defaultdict(list)
210210
for entry in agenda:
211211
k = entry.init.strftime("%a %d de %b")
212212
per_day[k].append(entry)
213213

214-
msg = "Esta es la agenda de magos para el PyCamp {}".format(pycamp.headquarters)
214+
msg = "Agenda de magos:"
215215
for day, items in per_day.items():
216216
msg += "\nEl día _{}_:\n".format(day)
217217
for i in items:
@@ -220,7 +220,13 @@ async def show_wizards_schedule(update, context):
220220
i.end.strftime("%H:%M"),
221221
"@" + i.wizard.username
222222
)
223-
223+
return msg
224+
225+
async def show_wizards_schedule(update, context):
226+
_, pycamp = get_active_pycamp()
227+
228+
agenda = WizardAtPycamp.select().where(pycamp == pycamp).order_by(WizardAtPycamp.init)
229+
msg = format_wizards_schedule(agenda)
224230
logger.debug(msg)
225231

226232
await context.bot.send_message(

src/pycamp_bot/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def get_current_wizard(self):
106106
return wizard
107107

108108

109+
def clear_wizards_schedule(self):
110+
return WizardAtPycamp.delete().where(WizardAtPycamp.pycamp == self).execute()
111+
109112
class PycampistaAtPycamp(BaseModel):
110113
'''
111114
Many to many relationship. Ona pycampista will attend many pycamps. A

0 commit comments

Comments
 (0)