upload/workshops.py
author Shantanu <shantanu@fossee.in>
Wed, 20 Jan 2010 14:19:50 +0530
changeset 1 a370c5796d08
child 3 ff06ee4aa9d9
permissions -rw-r--r--
Initialized the registration application.
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
    """
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    15
    eventList = []
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    16
    #disable this when we are deploying it!
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    17
    proxies = {'http': 'http://fossee:Python321@10.101.1.1:80'}
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    18
    eventPage = urllib.urlopen('http://fossee.in/event/ical', proxies=proxies).read()    
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    19
    parsedCal = vobject.readOne(eventPage)    
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    20
    for event in parsedCal.components():
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    21
        eventDate = event.dtstart.value.date()
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    22
	daysLeft = eventDate - date.today()
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    23
	if daysLeft.days > 3 and daysLeft.days < 31:
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    24
            eventList += (tuple((event.summary.value,event.summary.value)),)    
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    25
    return tuple(eventList)
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    26
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    27
if __name__ == '__main__':
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    28
    print workshop_name()                             
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    29
a370c5796d08 Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    30