Source

LifeLeft / lifeleft / app / views.py

Full commit
#-*- coding: utf-8 -*-
from datetime import date
from django.shortcuts import render_to_response

def _get_date(year, month, day):
    return date(year, month, day)

def _get_table(x=30, y=30):
    html = '<table>'
    current = 0
    current_month = 350
    for i in range(1, x+1):
        html += "<tr>"
        for j in range(1, y+1):
            current = current + 1
            if current == current_month:
                html += '<td style="border:solid 1px #ccc;background-color:green;">%s</td>' % current
            elif current < current_month:
                html += '<td style="border:solid 1px #ccc;background-color:red;">%s</td>' % current
            else:
                html += '<td style="border:solid 1px #ccc">%s</td>' % current
        html += "</tr>"
    html += "</table>"
    return html

def setting(request, **kwargs):
    tpl_name = kwargs.pop('template_name', 'setting.html')

    context = {}
    context['years'] = range(1900, 2012)
    context['months'] = range(1, 12)
    context['days'] = range(1, 31)
    
    return render_to_response(tpl_name, context)

def display(request, **kwargs):
    tpl_name = kwargs.pop('template_name', 'display.html')
    
    context = {}
    context['table'] = _get_table()
    
    return render_to_response(tpl_name, context)