예제 #1
0
def generateCalendars(erpHWs, localtime, triggers, obsessions, places):

    cal = calendar.Calendar(6)
    year = localtime.year
    theDay = localtime.day
    monthNumber = localtime.month
    #list of all months in years
    allMonths = cal.yeardatescalendar(year, 1)
    previousYearMonths = cal.yeardatescalendar((year - 1), 1)
    nextYearMonths = cal.yeardatescalendar((year + 1), 1)

    #list of relevant months for calendar
    months = previousYearMonths[8:]
    months = months + allMonths[:8]
    #months=allMonths
    #months= months+ nextYearMonths
    mNumber = monthNumber
    #if monthNumber == 12 :
    #    mNumber=0
    #months+=allMonths[mNumber]
    finalYear = 0
    finalMonth = 8
    theMonths = []
    currMonth = 9
    currYear = -1
    isFirst = True

    for month in months:
        if currMonth == 13:
            currYear += 1
            currMonth = 1
        aMonth = '''
        <div '''
        if currMonth == monthNumber and currYear == 0:
            aMonth += '''class="row calendarRow'''
        else:
            aMonth += '''hidden class="row calendarRow'''
        aMonth += " monthCal" + str(currMonth) + str(currYear) + '''">
        <div class="row"> 
            <div class="col-xs-2">

            </div>
            <div class="col-xs-2" align="center">'''
        if not isFirst:
            aMonth += '''<a onclick="calNavLeft();" ><span class="glyphicon glyphicon-chevron-left chevy"></span> 
                </a>'''
        isFirst = False
        aMonth += '''</div>
            <div class="col-xs-4" align="center">'''
        aMonth += calendar.month_name[currMonth] + ' ' + str(year + currYear)
        aMonth += '''</div>
            <div class="col-xs-2" align="center">'''
        if currMonth == finalMonth and currYear == finalYear:
            pass
        else:
            aMonth += '''<a onclick="calNavRight();" ><span class="glyphicon glyphicon-chevron-right chevy"></span> 
                </a>'''
        aMonth += '''
            </div>

            <div class="col-xs-2">


            </div>

        </div>
        <div class="row"> 
            <div class="col-xs-12">
        
        <table class="table-bordered '''
        aMonth += " month" + str(currMonth)
        aMonth += '''">
        <thead>  <!--Header row for the Table-->
            <th class="dayHeader "> <center>Sunday    </center></th>
            <th class="dayHeader "> <center> Monday   </center></th>
            <th class="dayHeader "> <center> Tuesday  </center></th>
            <th class="dayHeader "> <center>Wednesday </center></th>
            <th class="dayHeader "> <center>Thursday  </center></th>
            <th class="dayHeader "> <center>Friday    </center></th>
            <th class="dayHeader "> <center>Saturday  </center></th>
        </thead>
        '''
        for week in month[0]:
            aMonth += '<tr>'
            for day in week:
                isCurr = False
                if day.month == currMonth:
                    isCurr = True
                    aMonth += '<td class="day currMonthDay">'
                else:
                    isCurr == False
                    aMonth += '<td class="day notCurrMonthDay">'
                aMonth += "<div class='container-fluid dayContainer' ><div class='row'><div class='col-xs-12 dayCol'>"
                if ((monthNumber - day.month) > 0
                        and not currYear == 1) or currYear == -1 or (
                            currYear == 0 and day.month == 12 and
                            (currMonth != monthNumber)):
                    pass
                elif (monthNumber - day.month) == 0:
                    if day.day >= theDay:
                        innerForm = erpForm(obsessions, places, triggers, day)
                        addForm = addERPHWForm()
                        aMonth += '<button class="addERPButton ' + str(
                            day.month
                        ) + ' ' + str(
                            currMonth
                        ) + ' pop" data-toggle="popovers" data-content=\'' + render_template(
                            'erpHWForm.html',
                            form=addForm,
                            innerForm=innerForm
                        ) + '\'> <span data-toggle="tooltip" title="Click to add HW" class="glyphicon glyphicon-plus glyph-blue"></span></button>'
                elif isNextMonth(day.month, currMonth) or (
                        day.month > monthNumber
                        and day.year >= year) or day.year >= year:
                    innerForm = erpForm(obsessions, places, triggers, day)
                    addForm = addERPHWForm()
                    aMonth += '<button class="addERPButton ' + str(
                        day.month
                    ) + ' ' + str(
                        currMonth
                    ) + '" data-toggle="popovers" data-content=\'' + render_template(
                        'erpHWForm.html', form=addForm, innerForm=innerForm
                    ) + '\'> <span data-toggle="tooltip" title="Click to add HW" class="glyphicon glyphicon-plus glyph-blue"></span></button>'
                aMonth += '<span class="dayDate">' + str(day.day) + '</span>'
                aMonth += '</div></div>'
                #Should be handling events right now placing random
                if erpHWs.get(day, False):
                    if len(erpHWs[day]) > 3:
                        aMonth += "<div class='row'><div class='col-xs-12'><center>"
                        aMonth += '<button type ="button" class="btn btn-default showHWButton" data-toggle="collapse" data-target="#HWs' + str(
                            day
                        ) + str(
                            isCurr
                        ) + '"><span data-toggle="tooltip" title="Click to Expand HW\'s">HWs</span></button>'
                        aMonth += "<div class='hwContainer collapse' id='HWs" + str(
                            day) + str(isCurr) + "'>"
                        for erpHW in erpHWs[day]:
                            #aMonth+='<li>'
                            #aMonth+=generateERPDisplay(erpHW, "ERPHWLi",   'data-trigger="hover;"')
                            #aMonth+='</li>'
                            #aMonth+='</ul></div>'
                            aMonth += generateERPDisplay(
                                erpHW,
                                "ERPHWSmall",
                            )
                        aMonth += "</div>"
                    else:
                        aMonth += "<div class='row hwRow'><div class='col-xs-12'><center>"
                        for erpHW in erpHWs[day]:
                            aMonth += generateERPDisplay(
                                erpHW,
                                "ERPHWButton",
                            )

                aMonth += '</center>'
                aMonth += '</div></div>'
                aMonth += "</div>"
                aMonth += '</td>'
            aMonth += '</tr>'
        aMonth += '</table> </div> </div> </div>'
        currMonth += 1
        theMonths.append(Markup(aMonth))
    return theMonths
def generateCalendars (erpHWs, localtime, triggers, obsessions, places) :

    cal   = calendar.Calendar(6)
    year  = localtime.year
    theDay=localtime.day
    monthNumber =localtime.month
    #list of all months in years
    allMonths  = cal.yeardatescalendar(year, 1)
    previousYearMonths=cal.yeardatescalendar((year-1), 1)
    nextYearMonths =cal.yeardatescalendar((year+1), 1)
    
    #list of relevant months for calendar
    months = previousYearMonths[8:]
    months= months+allMonths[:8]
    #months=allMonths
    #months= months+ nextYearMonths
    mNumber=monthNumber
    #if monthNumber == 12 :
    #    mNumber=0
    #months+=allMonths[mNumber]
    finalYear=0
    finalMonth=8
    theMonths=[]
    currMonth=9
    currYear=-1
    isFirst=True
    
    for month in months :
        if currMonth==13 :
            currYear+=1
            currMonth=1
        aMonth='''
        <div '''
        if currMonth==monthNumber and currYear==0 :
            aMonth+='''class="row calendarRow'''
        else :
            aMonth+='''hidden class="row calendarRow'''
        aMonth+=" monthCal"+str(currMonth)+str(currYear)+'''">
        <div class="row"> 
            <div class="col-xs-2">

            </div>
            <div class="col-xs-2" align="center">'''
        if not isFirst : 
            aMonth+='''<a onclick="calNavLeft();" ><span class="glyphicon glyphicon-chevron-left chevy"></span> 
                </a>'''
        isFirst=False
        aMonth+='''</div>
            <div class="col-xs-4" align="center">'''
        aMonth+=calendar.month_name[currMonth]+' '+str(year+currYear)
        aMonth+='''</div>
            <div class="col-xs-2" align="center">'''
        if currMonth==finalMonth and currYear==finalYear :
            pass
        else :
            aMonth+='''<a onclick="calNavRight();" ><span class="glyphicon glyphicon-chevron-right chevy"></span> 
                </a>'''
        aMonth+='''
            </div>

            <div class="col-xs-2">


            </div>

        </div>
        <div class="row"> 
            <div class="col-xs-12">
        
        <table class="table-bordered '''
        aMonth+=" month"+str(currMonth)
        aMonth+='''">
        <thead>  <!--Header row for the Table-->
            <th class="dayHeader "> <center>Sunday    </center></th>
            <th class="dayHeader "> <center> Monday   </center></th>
            <th class="dayHeader "> <center> Tuesday  </center></th>
            <th class="dayHeader "> <center>Wednesday </center></th>
            <th class="dayHeader "> <center>Thursday  </center></th>
            <th class="dayHeader "> <center>Friday    </center></th>
            <th class="dayHeader "> <center>Saturday  </center></th>
        </thead>
        '''
        for week in month[0] :
            aMonth+='<tr>'
            for day in week :
                isCurr=False
                if day.month==currMonth :
                    isCurr=True
                    aMonth+='<td class="day currMonthDay">'
                else :
                    isCurr==False
                    aMonth+='<td class="day notCurrMonthDay">'
                aMonth+="<div class='container-fluid dayContainer' ><div class='row'><div class='col-xs-12 dayCol'>"
                if ((monthNumber-day.month)>0 and not currYear==1) or currYear==-1 or (currYear==0 and day.month==12 and (currMonth!=monthNumber)) :
                    pass
                elif (monthNumber-day.month)==0 : 
                    if day.day>=theDay :
                        innerForm=erpForm(obsessions,places, triggers, day)
                        addForm=addERPHWForm()
                        aMonth+='<button class="addERPButton '+str(day.month)+' '+str(currMonth) +' pop" data-toggle="popovers" data-content=\''+render_template('erpHWForm.html', form=addForm, innerForm=innerForm)+'\'> <span data-toggle="tooltip" title="Click to add HW" class="glyphicon glyphicon-plus glyph-blue"></span></button>'
                elif isNextMonth(day.month, currMonth) or (day.month>monthNumber and day.year>=year) or day.year>=year : 
                    innerForm=erpForm(obsessions,places, triggers, day)
                    addForm=addERPHWForm()
                    aMonth+='<button class="addERPButton '+str(day.month)+' '+str(currMonth)+'" data-toggle="popovers" data-content=\''+render_template('erpHWForm.html', form=addForm, innerForm=innerForm)+'\'> <span data-toggle="tooltip" title="Click to add HW" class="glyphicon glyphicon-plus glyph-blue"></span></button>'
                aMonth+='<span class="dayDate">'+str(day.day)+'</span>'
                aMonth+='</div></div>'
                #Should be handling events right now placing random
                if erpHWs.get(day, False) :
                    if len(erpHWs[day]) >3 :
                        aMonth+="<div class='row'><div class='col-xs-12'><center>"
                        aMonth+='<button type ="button" class="btn btn-default showHWButton" data-toggle="collapse" data-target="#HWs'+str(day)+str(isCurr)+'"><span data-toggle="tooltip" title="Click to Expand HW\'s">HWs</span></button>'
                        aMonth+="<div class='hwContainer collapse' id='HWs"+str(day)+str(isCurr)+"'>"
                        for erpHW in erpHWs[day] :
                            #aMonth+='<li>'
                            #aMonth+=generateERPDisplay(erpHW, "ERPHWLi",   'data-trigger="hover;"')
                            #aMonth+='</li>'
                        #aMonth+='</ul></div>' 
                            aMonth+=generateERPDisplay(erpHW,"ERPHWSmall", )
                        aMonth+="</div>"
                    else :
                        aMonth+="<div class='row hwRow'><div class='col-xs-12'><center>"
                        for erpHW in erpHWs[day] :
                            aMonth+=generateERPDisplay(erpHW,"ERPHWButton",)

                aMonth+='</center>'
                aMonth+='</div></div>'
                aMonth+="</div>"
                aMonth+='</td>'
            aMonth+='</tr>'
        aMonth+='</table> </div> </div> </div>'
        currMonth+=1
        theMonths.append(Markup(aMonth))
    return theMonths
예제 #3
0
def generateCalendar(erpHWs, localtime, triggers, obsessions, places):

    cal = calendar.Calendar(6)
    year = localtime.year
    theDay = localtime.day
    monthNumber = localtime.month
    #list of all months in years
    allMonths = cal.yeardatescalendar(year, 1)
    previousYearMonths = cal.yeardatescalendar((year - 1), 1)
    nextYearMonths = cal.yeardatescalendar((year + 1), 1)

    #list of relevant months for calendar
    months = previousYearMonths
    months = months + allMonths
    months = months + nextYearMonths
    mNumber = monthNumber
    #if monthNumber == 12 :
    #    mNumber=0
    #months+=allMonths[mNumber]

    theMonths = []
    currMonth = 1
    currYear = -1
    isFirst = True

    for month in months:
        if currMonth == 13:
            currYear += 1
            currMonth = 1
        aMonth = '''
        <div '''
        if currMonth == monthNumber and currYear == 0:
            aMonth += '''class="row calendarRow'''
        else:
            aMonth += '''hidden class="row calendarRow'''
        aMonth += " monthCal" + str(currMonth) + str(currYear) + '''">
        <div class="row"> 
            <div class="col-xs-2">

            </div>
            <div class="col-xs-2" align="center">'''
        if not isFirst:
            aMonth += '''<a onclick="calNavLeft();" ><span class="glyphicon glyphicon-chevron-left chevy"></span> 
                </a>'''
        isFirst = False
        aMonth += '''</div>
            <div class="col-xs-4" align="center">'''
        aMonth += calendar.month_name[currMonth]
        aMonth += '''</div>
            <div class="col-xs-2" align="center">'''
        if currMonth == 12 and currYear == 2:
            pass
        else:
            aMonth += '''<a onclick="calNavRight();" ><span class="glyphicon glyphicon-chevron-right chevy"></span> 
                </a>'''
        aMonth += '''
            </div>

            <div class="col-xs-2">


            </div>

        </div>
        <div class="row"> 
            <div class="col-xs-12">
        
        <table class="table-bordered '''
        aMonth += " month" + str(currMonth)
        aMonth += '''">
        <thead>  <!--Header row for the Table-->
            <th class="dayHeader "> <center>Sunday    </center></th>
            <th class="dayHeader "> <center> Monday   </center></th>
            <th class="dayHeader "> <center> Tuesday  </center></th>
            <th class="dayHeader "> <center>Wednesday </center></th>
            <th class="dayHeader "> <center>Thursday  </center></th>
            <th class="dayHeader "> <center>Friday    </center></th>
            <th class="dayHeader "> <center>Saturday  </center></th>
        </thead>
        '''
        for week in month[0]:
            aMonth += '<tr>'
            for day in week:
                if day.month == currMonth:
                    aMonth += '<td class="day currMonthDay">'
                else:
                    aMonth += '<td class="day notCurrMonthDay">'

                if ((monthNumber - day.month) > 0
                        and not currYear == 1) or currYear == -1 or (
                            currYear == 0 and day.month == 12 and
                            (currMonth != monthNumber)):
                    pass
                elif (monthNumber - day.month) == 0:
                    if day.day >= theDay:
                        innerForm = erpForm(obsessions, places, triggers, day)
                        addForm = addERPHWForm()
                        aMonth += '<button class="addERPButton" data-toggle="popovers" data-content=\'' + render_template(
                            'erpHWForm.html',
                            form=addForm,
                            innerForm=innerForm
                        ) + '\'> <span class="glyphicon glyphicon-plus glyph-blue"></span></button>'
                else:
                    innerForm = erpForm(obsessions, places, triggers, day)
                    addForm = addERPHWForm()
                    aMonth += '<button class="addERPButton" data-toggle="popovers" data-content=\'' + render_template(
                        'erpHWForm.html', form=addForm, innerForm=innerForm
                    ) + '\'> <span class="glyphicon glyphicon-plus glyph-blue"></span></button>'
                aMonth += '<span class="dayDate">' + str(day.day) + '</span>'

                #Should be handling events right now placing random
                aMonth += '<div class="HWContainer"><center>'
                for erpHW in erpHWs:
                    if erpHW['dateTime'][:10].replace('/', '-') == str(day):
                        aMonth += generateERPDisplay(erpHW)
                aMonth += '</center></div>'
                aMonth += '</td>'
            aMonth += '</tr>'
        aMonth += '</table> </div> </div> </div>'
        currMonth += 1
        theMonths.append(Markup(aMonth))
    return theMonths
def generateCalendar (erpHWs, localtime, triggers, obsessions, places) :

    cal   = calendar.Calendar(6)
    year  = localtime.year
    theDay=localtime.day
    monthNumber =localtime.month
    #list of all months in years
    allMonths  = cal.yeardatescalendar(year, 1)
    previousYearMonths=cal.yeardatescalendar((year-1), 1)
    nextYearMonths =cal.yeardatescalendar((year+1), 1)
    
    #list of relevant months for calendar
    months = previousYearMonths
    months= months+allMonths
    months= months+ nextYearMonths
    mNumber=monthNumber
    #if monthNumber == 12 :
    #    mNumber=0
    #months+=allMonths[mNumber]

    theMonths=[]
    currMonth=1
    currYear=-1
    isFirst=True
    
    for month in months :
        if currMonth==13 :
            currYear+=1
            currMonth=1
        aMonth='''
        <div '''
        if currMonth==monthNumber and currYear==0 :
            aMonth+='''class="row calendarRow'''
        else :
            aMonth+='''hidden class="row calendarRow'''
        aMonth+=" monthCal"+str(currMonth)+str(currYear)+'''">
        <div class="row"> 
            <div class="col-xs-2">

            </div>
            <div class="col-xs-2" align="center">'''
        if not isFirst : 
            aMonth+='''<a onclick="calNavLeft();" ><span class="glyphicon glyphicon-chevron-left chevy"></span> 
                </a>'''
        isFirst=False
        aMonth+='''</div>
            <div class="col-xs-4" align="center">'''
        aMonth+=calendar.month_name[currMonth]
        aMonth+='''</div>
            <div class="col-xs-2" align="center">'''
        if currMonth==12 and currYear==2 :
            pass
        else :
            aMonth+='''<a onclick="calNavRight();" ><span class="glyphicon glyphicon-chevron-right chevy"></span> 
                </a>'''
        aMonth+='''
            </div>

            <div class="col-xs-2">


            </div>

        </div>
        <div class="row"> 
            <div class="col-xs-12">
        
        <table class="table-bordered '''
        aMonth+=" month"+str(currMonth)
        aMonth+='''">
        <thead>  <!--Header row for the Table-->
            <th class="dayHeader "> <center>Sunday    </center></th>
            <th class="dayHeader "> <center> Monday   </center></th>
            <th class="dayHeader "> <center> Tuesday  </center></th>
            <th class="dayHeader "> <center>Wednesday </center></th>
            <th class="dayHeader "> <center>Thursday  </center></th>
            <th class="dayHeader "> <center>Friday    </center></th>
            <th class="dayHeader "> <center>Saturday  </center></th>
        </thead>
        '''
        for week in month[0] :
            aMonth+='<tr>'
            for day in week :
                if day.month==currMonth :
                    aMonth+='<td class="day currMonthDay">'
                else :
                    aMonth+='<td class="day notCurrMonthDay">'
                
                if ((monthNumber-day.month)>0 and not currYear==1) or currYear==-1 or (currYear==0 and day.month==12 and (currMonth!=monthNumber)) :
                    pass
                elif (monthNumber-day.month)==0 : 
                    if day.day>=theDay :
                        innerForm=erpForm(obsessions,places, triggers, day)
                        addForm=addERPHWForm()
                        aMonth+='<button class="addERPButton" data-toggle="popovers" data-content=\''+render_template('erpHWForm.html', form=addForm, innerForm=innerForm)+'\'> <span class="glyphicon glyphicon-plus glyph-blue"></span></button>'
                else : 
                    innerForm=erpForm(obsessions,places, triggers, day)
                    addForm=addERPHWForm()
                    aMonth+='<button class="addERPButton" data-toggle="popovers" data-content=\''+render_template('erpHWForm.html', form=addForm, innerForm=innerForm)+'\'> <span class="glyphicon glyphicon-plus glyph-blue"></span></button>'
                aMonth+='<span class="dayDate">'+str(day.day)+'</span>'

                #Should be handling events right now placing random
                aMonth+='<div class="HWContainer"><center>'
                for erpHW in erpHWs :
                    if erpHW['dateTime'][:10].replace('/','-')==str(day) :
                        aMonth+=generateERPDisplay(erpHW)
                aMonth+='</center></div>'
                aMonth+='</td>'
            aMonth+='</tr>'
        aMonth+='</table> </div> </div> </div>'
        currMonth+=1
        theMonths.append(Markup(aMonth))
    return theMonths