from django.shortcuts import render

from . import contents


def getContentDic(obj):
    '''
    Return a dictionairy with the values from the content object
    obj = <contents.Class>
    '''
    dic = {
        'icon': obj.icon,
        'title': obj.title,
        'subtitle': obj.subtitle,
        'content': obj.content,
        'url': obj.url,
        'translateUrl': obj.translateUrl,
        'relDate': contents.Global().relDate,
        'urls': {
            'Erasand': contents.Global().getUrl('Erasand'),
            'Projects': contents.Global().getUrl('Projects'),
            'About': contents.Global().getUrl('About'),
            'Networks': contents.Global().getUrl('Networks'),
            'Privacy': contents.Global().getUrl('Privacy'),
            'Sitemap': contents.Global().getUrl('Sitemap')
        }
    }
    return(dic)


def erasand(request):
    ''' erasand site '''
    dic = {
        'icon': contents.Erasand().icon,
        'title': contents.Erasand().title,
        'subtitle': contents.Erasand().subtitle,
        'intro': contents.Erasand().intro,
        'content': contents.Erasand().content,
        'url': contents.Erasand().url,
        'relDate': contents.Global().relDate,
        'urls': {
            'Erasand': contents.Global().getUrl('Erasand'),
            'Projects': contents.Global().getUrl('Projects'),
            'About': contents.Global().getUrl('About'),
            'Networks': contents.Global().getUrl('Networks'),
            'Privacy': contents.Global().getUrl('Privacy'),
            'Sitemap': contents.Global().getUrl('Sitemap')
        }
    }
    return(render(
        request,
        'homepage/landing.html',
        dic
    ))


def linux(request):
    ''' Linux site '''
    contentObj = contents.Linux()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def eraspage(request):
    ''' eras:PAGE site '''
    contentObj = contents.ErasPage()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def homepage(request):
    ''' home:PAGE site '''
    contentObj = contents.HomePage()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def erastools(request):
    ''' eras:TOOLS site '''
    contentObj = contents.ErasTools()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def eraswebapp(request):
    ''' eras:WEBAPP site '''
    contentObj = contents.ErasWebApp()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def fdds(request):
    ''' FilesDateDirSort site '''
    contentObj = contents.Fdds()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def liinwand(request):
    ''' liin:WAND site '''
    contentObj = contents.LiinWand()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def nextsteb(request):
    ''' NextSteB site '''
    contentObj = contents.NextSteb()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def linuxpvr(request):
    ''' linux:PVR site '''
    contentObj = contents.LinuxPvr()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def tradecontrol(request):
    ''' TradeControl site '''
    contentObj = contents.TradeControl()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def reuss(request):
    ''' reuss site '''
    contentObj = contents.Reuss()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def dellingr(request):
    ''' Dellingr site '''
    contentObj = contents.Dellingr()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def smartskrzat(request):
    ''' smartSKRZAT site '''
    contentObj = contents.SmartSkrzat()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def mindfulclock(request):
    ''' MindfulClock site '''
    contentObj = contents.MindfulClock()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def lorze(request):
    ''' lorze site '''
    contentObj = contents.Lorze()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def ponton(request):
    ''' PONTON site '''
    contentObj = contents.Ponton()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def capspg(request):
    ''' CaspsPg site '''
    contentObj = contents.CaspsPg()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def osk(request):
    ''' OSK v1 und OskV2 site '''
    contentObj = contents.Osk()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def projects(request):
    ''' Projekte site '''
    contentObj = contents.Projects()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def about(request):
    ''' über:MICH site '''
    contentObj = contents.About()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def civi(request):
    ''' curiculum:VITAE site '''
    contentObj = contents.Civi()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def networks(request):
    ''' Netzwerke site '''
    contentObj = contents.Networks()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def privacy(request):
    ''' Datenschutz site '''
    contentObj = contents.Privacy()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))


def sitemap(request):
    ''' Sitemap site '''
    contentObj = contents.Sitemap()
    return(render(
        request,
        'homepage/content.html',
        getContentDic(contentObj)
    ))
