finished ##187
This commit is contained in:
parent
12ca655d02
commit
61b9f7001a
|
@ -17,12 +17,20 @@ class UserController(metaclass=Singleton):
|
|||
def __init__(self):
|
||||
pass
|
||||
|
||||
def setLockedDay(self, date, locked,hard=False):
|
||||
return db.setLockedDay(date.date(), locked, hard)
|
||||
|
||||
def getLockedDay(self, date):
|
||||
now = datetime.now()
|
||||
daysInMonth = calendar.monthrange(date.year, date.month)[1]
|
||||
if date.year <= now.year and date.month <= now.month:
|
||||
for i in range(1, daysInMonth + 1):
|
||||
db.setLockedDay(datetime(date.year, date.month, i).date(), True)
|
||||
self.setLockedDay(datetime(date.year, date.month, i), True)
|
||||
for i in range(1, 8):
|
||||
nextMonth = datetime(date.year, date.month + 1, i)
|
||||
if nextMonth.weekday() == 2:
|
||||
break
|
||||
self.setLockedDay(nextMonth, True)
|
||||
return db.getLockedDay(date.date())
|
||||
|
||||
def getWorker(self, date, username=None):
|
||||
|
|
|
@ -71,3 +71,37 @@ def _deletUser(**kwargs):
|
|||
date = datetime(year, month, day, 12)
|
||||
userController.deleteWorker(user['username'], date)
|
||||
return jsonify({"ok": "ok"})
|
||||
|
||||
@vorstand.route("/sm/lockDay", methods=['POST'])
|
||||
@login_required(groups=[MONEY, GASTRO])
|
||||
def _lockDay(**kwargs):
|
||||
try:
|
||||
data = request.get_json()
|
||||
year = data['year']
|
||||
month = data['month']
|
||||
day = data['day']
|
||||
locked = data['locked']
|
||||
date = datetime(year, month, day, 12)
|
||||
lockedDay = userController.setLockedDay(date, locked, True)
|
||||
if not lockedDay:
|
||||
retVal = {
|
||||
'date': {
|
||||
'year': year,
|
||||
'month': month,
|
||||
'day': day
|
||||
},
|
||||
'locked': False
|
||||
}
|
||||
else:
|
||||
retVal = {
|
||||
'date': {
|
||||
'year': year,
|
||||
'month': month,
|
||||
'day': day
|
||||
},
|
||||
'locked': lockedDay['locked']
|
||||
}
|
||||
print(retVal)
|
||||
return jsonify(retVal)
|
||||
except Exception as err:
|
||||
return jsonify({'error': err}), 409
|
Loading…
Reference in New Issue