Skip to content

Commit 5e7dcd3

Browse files
committed
util functions to PyCamp model
1 parent c52f9a1 commit 5e7dcd3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/pycamp_bot/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Pycamp(BaseModel):
5757
vote_authorized = pw.BooleanField(default=False, null=True)
5858
project_load_authorized = pw.BooleanField(default=False, null=True)
5959
active = pw.BooleanField(default=False, null=True)
60+
wizard_slot_duration = pw.IntegerField(default=60, null=False) # In minutes
6061

6162
def __str__(self):
6263
rv_str = 'Pycamp:\n'
@@ -65,6 +66,17 @@ def __str__(self):
6566
rv_str += f'{attr}: {getattr(self, attr)}\n'
6667
return rv_str
6768

69+
def set_as_only_active(self):
70+
active = Pycamp.select().where(Pycamp.active)
71+
for p in active:
72+
p.active = False
73+
Pycamp.bulk_update(active, fields=[Pycamp.active])
74+
self.active = True
75+
self.save()
76+
77+
def get_wizards(self):
78+
return Pycampista.select().where(Pycampista.wizard == 1)
79+
6880

6981
class PycampistaAtPycamp(BaseModel):
7082
'''

0 commit comments

Comments
 (0)