# ======================================================================================================================
# Fakulta informacnich technologii VUT v Brne
# Bachelor thesis
# Author: Filip Bali (xbalif00)
# License: MIT
# ======================================================================================================================
from django import template
import datetime
import time

from portfolioApp.models import NotificationEvent

register = template.Library()

import pandas as pd

def print_timestamp(timestamp):
    return time.strftime('%Y-%m-%d'.format(timestamp%1000), time.gmtime(timestamp/1000.0))

def print_timestamp_analysis(timestamp):
    return str(timestamp.year) + '-' + str(timestamp.month) +'-' + str(timestamp.day)

def print_timestamp_notifications(timestamp):
    return str(timestamp.year) + '-' + str(timestamp.month) +'-' + str(timestamp.day)

def print_notification_text(type):
    if type == 1:
        return 'At a price change equal/above/below'
    elif type == 2:
        return 'Percentage increase current price'
    elif type == 3:
        return 'Percentage decrease current price'

def print_symbol_notifications(notification_id):
    object = NotificationEvent.objects.get(id=notification_id)
    symbol = str(object.company.symbol)
    return symbol

def print_type_notifications(notification_type):
    if notification_type == 1:
        return 'Interday'
    elif notification_type == 2:
        return 'Intraday'

register.filter(print_timestamp)
register.filter(print_timestamp_analysis)
register.filter(print_timestamp_notifications)
register.filter(print_notification_text)
register.filter(print_symbol_notifications)
register.filter(print_type_notifications)
[((472, 490), 'django.template.Library', 'template.Library', ([], {}), '()\n', (488, 490), False, 'from django import template\n'), ((1209, 1258), 'portfolioApp.models.NotificationEvent.objects.get', 'NotificationEvent.objects.get', ([], {'id': 'notification_id'}), '(id=notification_id)\n', (1238, 1258), False, 'from portfolioApp.models import NotificationEvent\n'), ((605, 636), 'time.gmtime', 'time.gmtime', (['(timestamp / 1000.0)'], {}), '(timestamp / 1000.0)\n', (616, 636), False, 'import time\n')]