| author | Shantanu <shantanu@fossee.in> |
| Wed, 20 Jan 2010 17:09:52 +0530 | |
| changeset 5 | a1fe7806d6a0 |
| parent 4 | 6a2fdf0b4f7e |
| child 12 | 10d86ada90c2 |
| permissions | -rw-r--r-- |
|
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 | 15 |
eventList = [] |
| 4 | 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() |
|
a370c5796d08
Initialized the registration application.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
21 |
if daysLeft.days > 3 and daysLeft.days < 31: |
|
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 |