# Path: sendinel/settings.py
# DEBUG = True        #for scheduling set to false
# TEMPLATE_DEBUG = DEBUG
# PROJECT_PATH = dirname(abspath(__file__))
# LOGGING_LEVEL = logging.INFO
# LOGGING_LEVEL_TEST = logging.CRITICAL
# ADMINS = (
# )
# MANAGERS = ADMINS
# DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
# DATABASE_NAME = PROJECT_PATH + '/sendinel.db'             # Or path to database file if using sqlite3.
# DATABASE_USER = ''             # Not used with sqlite3.
# DATABASE_PASSWORD = ''         # Not used with sqlite3.
# DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
# DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
# TIME_ZONE = 'Europe/Berlin'
# LANGUAGE_CODE = 'en-us'
# SITE_ID = 1
# USE_I18N = True
# MEDIA_ROOT = PROJECT_PATH + '/media'
# MEDIA_URL = '/mediaweb/'
# ADMIN_MEDIA_PREFIX = '/admin_media/'
# SECRET_KEY = '4ztf1p=e9d*ns^d*f@bs3mu#37p)$jp(%lzo2a+-%j8^=eq852'
# TEMPLATE_LOADERS = (
#     'django.template.loaders.filesystem.load_template_source',
#     'django.template.loaders.app_directories.load_template_source',
# #     'django.template.loaders.eggs.load_template_source',
# )
# TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.auth",
#     "django.core.context_processors.debug",
#     "django.core.context_processors.i18n",
#     "django.core.context_processors.media",
#     "django.contrib.messages.context_processors.messages")
# MIDDLEWARE_CLASSES = (
#     'django.middleware.common.CommonMiddleware',
#     'django.contrib.sessions.middleware.SessionMiddleware',
#     'django.middleware.locale.LocaleMiddleware',
#     'django.contrib.auth.middleware.AuthenticationMiddleware',
#     'django.contrib.csrf.middleware.CsrfMiddleware'
# )
# ROOT_URLCONF = 'sendinel.urls'
# TEMPLATE_DIRS = (
#     PROJECT_PATH + "/templates",
#     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
#     # Always use forward slashes, even on Windows.
#     # Don't forget to use absolute paths, not relative paths.
# )
# INSTALLED_APPS = (
#     'django.contrib.admin',
#     'django.contrib.auth',
#     'django.contrib.contenttypes',
#     'django.contrib.sessions',
#     'django.contrib.sites',
#     'sendinel',
#     'sendinel.web',
#     'sendinel.backend',
#     'sendinel.groups',
#     'sendinel.infoservices',
#     'sendinel.notifications',
#     'sendinel.medicines'
# )
# REMINDER_TIME_BEFORE_APPOINTMENT = timedelta(days = 1)
# DEFAULT_APPOINTMENT_DURATION = timedelta(minutes = 60)
# DEFAULT_HOSPITAL_NAME = 'your hospital'
# DEFAULT_SEND_TIME = '12:00' #hh:mm in 24-hours format
# COUNTRY_CODE_PHONE = "0049" #"0027" for South Africa
# START_MOBILE_PHONE = "0" # "0" for South Africa (07/08..), "01" for Germany
# ASTERISK_USER = "sendinel"
# ASTERISK_GROUP = "sendinel"
# ASTERISK_SPOOL_DIR = "/var/spool/asterisk/outgoing/"
# ASTERISK_DONE_SPOOL_DIR = "/var/spool/asterisk/outgoing_done/"
# ASTERISK_RETRY = 5
# ASTERISK_RETRY_TIME = 5
# ASTERISK_DATACARD = True 
# ASTERISK_EXTENSION = "s"
# ASTERISK_SIP_ACCOUNT = "datacard0"
# SERIALPORTSMS = '/dev/rfcomm0'
# FESTIVAL_CACHE = "/tmp"
# AUTH_NUMBER = "CHANGE ME"
# AUTHENTICATION_CALL_TIMEOUT = timedelta(minutes = 3)
# AUTHENTICATION_ENABLED = False
# BLUETOOTH_ENABLED = True
# SMS_SALUTATION = ''
# CALL_SALUTATION = "This is an automated call from your clinic"
# MEDICINE_MESSAGE_TEMPLATE = "Your medicine is now available " + \
#                             "at the $hospital. Please come and pick it up."
# VCAL_UID_SLUG = 'sendinel.org'


﻿from datetime import datetime
from sendinel import settings
"""BEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
UID:%(uid)s
DTSTART:%(start)s
DTEND:%(end)s
DESCRIPTION:%(content)s
SUMMARY:%(content)s
DTSTAMP:%(stamp)s
LOCATION:%(location)s
DALARM:%(alarm)s
AALARM:%(alarm)s
END:VEVENT
END:VCALENDAR""" % {\
    'uid': uid,
    'content': content,
    'location': location,
    'start': start_date.strftime("%Y%m%dT%H%M%S"),
    'end': end_date.strftime("%Y%m%dT%H%M%S"),
    'stamp': datetime.now().strftime("%Y%m%dT%H%M%S"),    
    'alarm': alarm_time.strftime("%Y%m%dT%H%M%S")}
    
    return vcal_data
    
def get_uid():
    """
        Calculate a unique UID for a vcal by using notification id and a time.
    """
    
    date_time = datetime.now().strftime("%Y%m%dT%H%M%S")

# Path: sendinel/settings.py
# DEBUG = True        #for scheduling set to false
# TEMPLATE_DEBUG = DEBUG
# PROJECT_PATH = dirname(abspath(__file__))
# LOGGING_LEVEL = logging.INFO
# LOGGING_LEVEL_TEST = logging.CRITICAL
# ADMINS = (
# )
# MANAGERS = ADMINS
# DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
# DATABASE_NAME = PROJECT_PATH + '/sendinel.db'             # Or path to database file if using sqlite3.
# DATABASE_USER = ''             # Not used with sqlite3.
# DATABASE_PASSWORD = ''         # Not used with sqlite3.
# DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
# DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
# TIME_ZONE = 'Europe/Berlin'
# LANGUAGE_CODE = 'en-us'
# SITE_ID = 1
# USE_I18N = True
# MEDIA_ROOT = PROJECT_PATH + '/media'
# MEDIA_URL = '/mediaweb/'
# ADMIN_MEDIA_PREFIX = '/admin_media/'
# SECRET_KEY = '4ztf1p=e9d*ns^d*f@bs3mu#37p)$jp(%lzo2a+-%j8^=eq852'
# TEMPLATE_LOADERS = (
#     'django.template.loaders.filesystem.load_template_source',
#     'django.template.loaders.app_directories.load_template_source',
# #     'django.template.loaders.eggs.load_template_source',
# )
# TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.auth",
#     "django.core.context_processors.debug",
#     "django.core.context_processors.i18n",
#     "django.core.context_processors.media",
#     "django.contrib.messages.context_processors.messages")
# MIDDLEWARE_CLASSES = (
#     'django.middleware.common.CommonMiddleware',
#     'django.contrib.sessions.middleware.SessionMiddleware',
#     'django.middleware.locale.LocaleMiddleware',
#     'django.contrib.auth.middleware.AuthenticationMiddleware',
#     'django.contrib.csrf.middleware.CsrfMiddleware'
# )
# ROOT_URLCONF = 'sendinel.urls'
# TEMPLATE_DIRS = (
#     PROJECT_PATH + "/templates",
#     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
#     # Always use forward slashes, even on Windows.
#     # Don't forget to use absolute paths, not relative paths.
# )
# INSTALLED_APPS = (
#     'django.contrib.admin',
#     'django.contrib.auth',
#     'django.contrib.contenttypes',
#     'django.contrib.sessions',
#     'django.contrib.sites',
#     'sendinel',
#     'sendinel.web',
#     'sendinel.backend',
#     'sendinel.groups',
#     'sendinel.infoservices',
#     'sendinel.notifications',
#     'sendinel.medicines'
# )
# REMINDER_TIME_BEFORE_APPOINTMENT = timedelta(days = 1)
# DEFAULT_APPOINTMENT_DURATION = timedelta(minutes = 60)
# DEFAULT_HOSPITAL_NAME = 'your hospital'
# DEFAULT_SEND_TIME = '12:00' #hh:mm in 24-hours format
# COUNTRY_CODE_PHONE = "0049" #"0027" for South Africa
# START_MOBILE_PHONE = "0" # "0" for South Africa (07/08..), "01" for Germany
# ASTERISK_USER = "sendinel"
# ASTERISK_GROUP = "sendinel"
# ASTERISK_SPOOL_DIR = "/var/spool/asterisk/outgoing/"
# ASTERISK_DONE_SPOOL_DIR = "/var/spool/asterisk/outgoing_done/"
# ASTERISK_RETRY = 5
# ASTERISK_RETRY_TIME = 5
# ASTERISK_DATACARD = True 
# ASTERISK_EXTENSION = "s"
# ASTERISK_SIP_ACCOUNT = "datacard0"
# SERIALPORTSMS = '/dev/rfcomm0'
# FESTIVAL_CACHE = "/tmp"
# AUTH_NUMBER = "CHANGE ME"
# AUTHENTICATION_CALL_TIMEOUT = timedelta(minutes = 3)
# AUTHENTICATION_ENABLED = False
# BLUETOOTH_ENABLED = True
# SMS_SALUTATION = ''
# CALL_SALUTATION = "This is an automated call from your clinic"
# MEDICINE_MESSAGE_TEMPLATE = "Your medicine is now available " + \
#                             "at the $hospital. Please come and pick it up."
# VCAL_UID_SLUG = 'sendinel.org'


# Path: sendinel/backend/vcal.py
﻿from datetime import datetime
from sendinel import settings

"""BEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
UID:%(uid)s
DTSTART:%(start)s
DTEND:%(end)s
DESCRIPTION:%(content)s
SUMMARY:%(content)s
DTSTAMP:%(stamp)s
LOCATION:%(location)s
DALARM:%(alarm)s
AALARM:%(alarm)s
END:VEVENT
END:VCALENDAR""" % {\
    'uid': uid,
    'content': content,
    'location': location,
    'start': start_date.strftime("%Y%m%dT%H%M%S"),
    'end': end_date.strftime("%Y%m%dT%H%M%S"),
    'stamp': datetime.now().strftime("%Y%m%dT%H%M%S"),    
    'alarm': alarm_time.strftime("%Y%m%dT%H%M%S")}
    
    return vcal_data
    
def get_uid():
    """
        Calculate a unique UID for a vcal by using notification id and a time.
    """
    
    date_time = datetime.now().strftime("%Y%m%dT%H%M%S")

    return "%s@%s" % (date_time, settings.VCAL_UID_SLUG)