upload/workshops.py
changeset 1 a370c5796d08
child 3 ff06ee4aa9d9
equal deleted inserted replaced
0:621d1b4200d2 1:a370c5796d08
       
     1 import vobject
       
     2 import urllib
       
     3 from datetime import date
       
     4 
       
     5 def workshop_name():
       
     6     """
       
     7     Reading the ical from fossee.in
       
     8     and generating a option field for 
       
     9     selecting particular workshop.
       
    10     Disabling the registration when 
       
    11     number of days are less then 5 and
       
    12     enabling registration when workshop 
       
    13     is within 30 days.
       
    14     """
       
    15     eventList = []
       
    16     #disable this when we are deploying it!
       
    17     proxies = {'http': 'http://fossee:Python321@10.101.1.1:80'}
       
    18     eventPage = urllib.urlopen('http://fossee.in/event/ical', proxies=proxies).read()    
       
    19     parsedCal = vobject.readOne(eventPage)    
       
    20     for event in parsedCal.components():
       
    21         eventDate = event.dtstart.value.date()
       
    22 	daysLeft = eventDate - date.today()
       
    23 	if daysLeft.days > 3 and daysLeft.days < 31:
       
    24             eventList += (tuple((event.summary.value,event.summary.value)),)    
       
    25     return tuple(eventList)
       
    26 
       
    27 if __name__ == '__main__':
       
    28     print workshop_name()                             
       
    29 
       
    30