fix some issues with dynamic initial values confusing inline formsets (for inline formsets not bound to a urlfeed).
authorTero Marttila <terom@fixme.fi>
Sat, 31 Aug 2013 21:36:49 +0300
changeset 65 b6ce70e51bce
parent 64 b968f33d780c
child 66 8ca335eab457
fix some issues with dynamic initial values confusing inline formsets (for inline formsets not bound to a urlfeed).
qrurls/admin.py
--- a/qrurls/admin.py	Sat Aug 31 19:21:41 2013 +0300
+++ b/qrurls/admin.py	Sat Aug 31 21:36:49 2013 +0300
@@ -29,6 +29,7 @@
         if not isinstance(urlfeed, URL) :
             urlfeed = None
         
+        # XXX: initial values must be stable across form GET/POST, or django will be confused and think the form has been filled out
         kwargs.update(initial=[
             # Either generic from today, or based on the actual urlfeed
             dict(published=publish) for publish in URLAdmin.publishing_schedule(urlfeed, count=extra)
@@ -49,15 +50,11 @@
         """Yield URLItem.published values for feed, or defaults."""
         if urlfeed :
             date, time, offset = urlfeed.publishing_schedule()
+
+            return URL.apply_publishing_schedule(date, time, offset, count)
         else:
-            # no data... use defaults
-            tznow = timezone.now() # with tzinfo
-            
-            date = tznow.date()
-            time = tznow.timetz()
-            offset = datetime.timedelta(days=1)
-        
-        return URL.apply_publishing_schedule(date, time, offset, count)
+            # no data... no defaults
+            return []
 
     def timezone (self, obj) :
         now = timezone.localtime(obj.now())