upload/workshops.py
author Shantanu <shantanu@fossee.in>
Mon, 25 Jan 2010 01:20:43 +0530
changeset 12 10d86ada90c2
parent 4 6a2fdf0b4f7e
permissions -rw-r--r--
Added custom view for looking at registrants yAy.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     1
import vobject
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     2
import urllib
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     3
from datetime import date
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     4
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     5
def workshop_name():
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     6
    """
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     7
    Reading the ical from fossee.in
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     8
    and generating a option field for 
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     9
    selecting particular workshop.
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    10
    Disabling the registration when 
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    11
    number of days are less then 5 and
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    12
    enabling registration when workshop 
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    13
    is within 30 days.
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    14
    """
3
ff06ee4aa9d9 Corrected proxy.
Shantanu <shantanu@fossee.in>
parents: 1
diff changeset
    15
    eventList = []    
4
6a2fdf0b4f7e removed proxy.
Shantanu <shantanu@fossee.in>
parents: 3
diff changeset
    16
    eventPage = urllib.urlopen('http://fossee.in/event/ical').read()    
1
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    17
    parsedCal = vobject.readOne(eventPage)    
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    18
    for event in parsedCal.components():
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    19
        eventDate = event.dtstart.value.date()
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    20
	daysLeft = eventDate - date.today()
12
10d86ada90c2 Added custom view for looking at registrants yAy.
Shantanu <shantanu@fossee.in>
parents: 4
diff changeset
    21
	if daysLeft.days > -1 and daysLeft.days < 31:
1
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    22
            eventList += (tuple((event.summary.value,event.summary.value)),)    
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    23
    return tuple(eventList)
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    24
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    25
if __name__ == '__main__':
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    26
    print workshop_name()                             
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    27
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    28