X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/9616d8fcb2932b9556aea942fc19000111da2a13..3017d1ec2631585dff08ab4ae1aa0086995dfdcf:/edumed/utils.py diff --git a/edumed/utils.py b/edumed/utils.py index 756ffa3..0683476 100644 --- a/edumed/utils.py +++ b/edumed/utils.py @@ -1,9 +1,14 @@ # -*- coding: utf-8 -*- import codecs import csv - import cStringIO +import pytz +from django.conf import settings +from django.utils import timezone + +from settings.apps import INSTALLED_APPS + # source: https://docs.python.org/2/library/csv.html#examples class UnicodeCSVWriter(object): @@ -33,4 +38,18 @@ class UnicodeCSVWriter(object): def writerows(self, rows): for row in rows: - self.writerow(row) \ No newline at end of file + self.writerow(row) + + +def process_app_deps(list_with_deps): + return tuple( + (x[0] if type(x) == tuple else x) + for x in list_with_deps + if type(x) != tuple or x[1] in INSTALLED_APPS) + + +def localtime_to_utc(localtime): + tz = pytz.timezone(settings.TIME_ZONE) + return timezone.utc.normalize( + tz.localize(localtime) + )