blob: 9092a2d4f629c5b8a70114c00e313afa3b258880 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
from collections import defaultdict
import datetime
from raven import Client
client = None
def per_manager(timesheets):
per_manager = defaultdict(list)
# filter timesheets per manager
for timesheet in [t for t in timesheets if not t.is_done()]:
manager_id = timesheet.approver
per_manager[manager_id].append(timesheet)
return per_manager
def employees(timesheets):
return dict([(t.employee.id, t.employee) for t in timesheets])
def previous_monday(date=None):
today = date or datetime.date.today()
return today + datetime.timedelta(days=-today.weekday(), weeks=-1)
def is_present(what):
return what and what.strip()
def is_empty(what):
return not is_present(what)
def sentry_log(msg, extra={}):
if client:
try:
client.captureMessage(msg, extra=extra)
except:
client.captureException()
def sentry_exception():
if client:
client.captureException()
def sentry(config):
if config.has_option('sentry', 'dsn'):
try:
dsn = config.get('sentry', 'dsn')
global client
client = Client(dsn)
except Exception as e:
print(str(e))
|