예제 #1
0
def day_mobile(request):
    """Similar to 'day' func.
    Should be use for mobile sites.
    Returns only the first feast found, except if the feast is a feria."""
    sentvalue = RechercheSimple(request.GET or None)
    if sentvalue.is_valid():
        day = sentvalue.cleaned_data['date_seule']
        proper = sentvalue.cleaned_data['proper']
    else:
        day = datetime.date.today()
        proper = 'roman'
    pal = False
    lyear = annus.LiturgicalCalendar(proper=proper)
    lyear(day.year)
    data = lyear[day]
    feast = data[0]
    if len(data) > 1 and type(
            data[0]).__name__ == 'FeteFerie' and data[1].pal is False:
        feast = data[1]

    hashtag = "resultup"
    link_to_day = officia.datetime_to_link(day,
                                           host,
                                           hashtag=hashtag,
                                           proper=proper)
    return render(request, 'spill/day_mobile.html', locals())
예제 #2
0
def day(request):
    """Returns value for one date"""
    sentvalue = RechercheSimple(request.GET or None)
    if sentvalue.is_valid():
        day = sentvalue.cleaned_data['date_seule']
        pal = sentvalue.cleaned_data['pal']
        proper = sentvalue.cleaned_data['proper']
    else:
        day = datetime.date.today()
        pal = False
        proper = 'roman'
    lang = get_language_from_request(request)
    lyear = annus.LiturgicalCalendar(proper=proper)
    lyear(day.year)
    data = lyear[day]  # data of requested day
    hashtag = "resultup"
    link_to_day = officia.datetime_to_link(day,
                                           host,
                                           hashtag=hashtag,
                                           proper=proper,
                                           pal=pal)
    link_to_tomorrow = datetime_to_param(day + datetime.timedelta(1),
                                         pal=pal,
                                         proper=proper)
    link_to_yesterday = datetime_to_param(day - datetime.timedelta(1),
                                          pal=pal,
                                          proper=proper)
    return render(request, 'spill/day.html', locals())
예제 #3
0
def martyrology_date(request,date=None,recherche_simple=None):
    """Return martyrology for a date"""
    if not date:
        return home(request)
    result = (martyrology_instance.daytext(date,'fr'),) # a tuple in order to iterate in template
    martyrology = True
    recherche_mot_clef=RechercheMotClef(None)
    mois_entier=MoisEntier(None)
    hashtag = 'resultup'
    next_item = officia.datetime_to_link(date + datetime.timedelta(1),host,'on',hashtag,s)
    previous_item = officia.datetime_to_link(date - datetime.timedelta(1),host,'on',hashtag,s)
    main_title = martyrology_instance.name['fr']
    credits = martyrology_instance.credits('fr')
    titre = "Martyrologe romain : {}".format(result[0].title)
    result_len = len(result)
    shared_research = _setSharedResearch(martyrology=True)
    return render(request,'kalendarium/accueil.html',locals())
예제 #4
0
 def pseudo_day(request, data, day, mobile):
     """Imitates day behaviour in a static context"""
     hashtag = "resultup"
     link_to_day = officia.datetime_to_link(day, host, hashtag=hashtag)
     if not mobile:
         link_to_tomorrow = datetime_to_shtml(day + datetime.timedelta(1))
         link_to_yesterday = datetime_to_shtml(day - datetime.timedelta(1))
     months = ('', 'janvier', 'février', 'mars', 'avril', 'mai', 'juin',
               'juillet', 'août', 'septembre', 'octobre', 'novembre',
               'décembre')
     day = "{} {} {}".format(day.day, months[day.month], day.year)
     # add special classes for static files
     static_file = True
     pal = True
     # for mobile version
     if mobile:
         index = len(data) > 1 and type(data[0]).__name__ == 'FeteFerie'
         feast = data[index]
     # return
     return render(request,
                   ('spill/day.html', 'spill/day_mobile.html')[mobile],
                   locals())
예제 #5
0
def home(request,
         recherche_mot_clef=RechercheMotClef(None),recherche_simple=RechercheSimple(None),mois_entier=MoisEntier(None),mois_seul=False,
         debut=None,fin=None,pal=False,
         proper='roman',
         mots_clefs='',plus=False,annee=None):
    """A function which defines homepage. It is also used
    by other pages to print common code.
    It takes many arguments :
    - a request sent by client ;
    - three GET forms whith None as default value  : recherche_mot_clef, recherche_simple, mois_entier ;
    - mois_seul : a bool to define whether a complete month will be returned or not ;
    - debut : a datetime.date for the older date ;
    - fin : a datetime.date for the latest date ;
    - mots_clefs : a string used for research ;
    - plus : a bool used to know whether the research must be large, or not ;
    - annee : the year ;
    """
    if proper not in propers:
        proper = 'roman'
    liturgycal = annus.LiturgicalCalendar(proper=proper)
    retour = ''
    deroule = {}
    if debut == None:
        debut = datetime.date.today()
    if fin == None:
        fin = datetime.date.today()
    if mots_clefs == '':
        hashtag = 'resultup'
        if debut == fin: #à mettre dans le template
            next_item = officia.datetime_to_link(fin + datetime.timedelta(1),host,hashtag=hashtag,s=s,proper=proper,pal=pal)
            previous_item = officia.datetime_to_link(debut - datetime.timedelta(1),host,hashtag=hashtag,s=s,proper=proper,pal=pal)
        else:
            next_item = officia.month_to_link(fin,host,1,hashtag,s,proper)
            previous_item = officia.month_to_link(debut,host,-1,hashtag,s,proper)
        date = debut
        liturgycal(date.year)
        while date <= fin:
            deroule[date] = liturgycal[date]
            date = date + datetime.timedelta(1)
        inversion=False
        if mois_seul:
            titre = officia.mois[debut.month - 1]
        else:
            titre = debut
    else:
        if annee is None:
            annee = datetime.date.today().year
        titre = mots_clefs
        liturgycal(annee)
        try:
            deroule[titre] = officia.inversons(mots_clefs,liturgycal,datetime.date(annee,1,1),datetime.date(annee,12,31),langue='fr',exit=True,plus=plus)
        except SystemExit:
            deroule[titre] = []
        inversion=True

    #values for templates
    for value in deroule.values():
        for elt in value:
            liturgical_time = officia.affiche_temps_liturgique(elt,lang='fr')
            elt.temps_liturgique_ = liturgical_time[0].upper() + liturgical_time[1:]
            elt.proper_ = propers[elt.propre]
    shared_research = _setSharedResearch(pal=pal,martyrology=False,proper=proper)
    deroule = sorted(deroule.items())

    return render(request,'kalendarium/accueil.html',locals())