bartekgorny / django-schedule

NOT MAINTAINED - see other forks
http://wiki.github.com/bartekgorny/django-schedule
70 stars 31 forks source link

views.py, get_occurrence() returns 404 on unit=0 #11

Open mixmastamyk opened 13 years ago

mixmastamyk commented 13 years ago

I encountered this problem after an update. It looks like the code at:

https://github.com/bartekgorny/django-schedule/blob/master/schedule/views.py#L206

was changed from:

elif not [x for x in (year, month, day, hour, minute, second) if x is None]:

to:

elif(all((year, month, day, hour, minute, second))):

Though it looks nicer, it fails if any of the parameters are zero, such as minutes, and serves up a 404.

bartekgorny commented 13 years ago

On Thu, 16 Jun 2011 17:11:11 -0700 mixmastamyk reply@reply.github.com wrote:

I encountered this problem after an update. It looks like the code at:

https://github.com/bartekgorny/django-schedule/blob/master/schedule/views.py#L206

was changed from:

elif not [x for x in (year, month, day, hour, minute, second) if x is None]:

to:

elif(all((year, month, day, hour, minute, second))):

Hum, I'm not sure - this line has always been like that. It's been written by Tony way back in 2009, and has been working at least for most cases. Though, I must admit I don't quite get the logic of it - it is true that it should fail when minutes are zero; besides, I see no reason to enforce all the arguments (except year, perhaps) - in an extreme case there might be an annual event and someone might want an occurrence for a given year. So you might try two approaches: either change it to your version above, or set default values to zero and only check if the year is given. See if it works and send me a pull request.

Cheers Bartek

Though it looks nicer, it fails if any of the parameters are zero, such as minutes, and serves up a 404.

Co tu począć, co tu począć, trudna rada / Człowiek przestał się już dobrze zapowiadać / Ale z drugiej strony można cieszyć się / Że się również przestał zapowiadać źle... (Starsi Panowie)

mixmastamyk commented 13 years ago

I did switch back to the version above in my copy and it works again.

Sorry, I had the history mixed up. I was originally using the ajax branch until I discovered it didn't have the recent performance optimization updates. So I switched to master and thereafter my event pages starting at HH:00 began to return 404s.

I've tracked down the line in the ajax branch to views.py, line 211: https://github.com/bartekgorny/django-schedule/blob/9e7d528e2a7296aa2ccbaad597a99e0570757fe8/schedule/views.py#L211

Investigating further, I see what's happening. I have passed an int into the function, (minutes=0 keyword arg in my caller) and the master branch is anticipating strings. The doc string, however makes no statement or warning on the matter.

What do you recommend as the best source of action? I don't use git so won't be able to do branching myself, apologies.