On 3/8/07, Gary Doades <[EMAIL PROTECTED]> wrote:
>
> >
> > So in your Event model (or whatever you're calling it), you're
> > essentially storing the keyword arguments to an rrule, depending on
> > what's necessary for a particular event?
> >
> > Then whenever you need to render a calendar, you pull in all the
> > Events from the db, create rrules for each using the stored
> > parameters, and just work with the dateutil library to do the rest?
> >
> > Jay P.
>
> More or less, yes.
>
> I have a Django model (from my original test code):
>
> class ResourceSchedule(models.Model):
>     description = models.CharField(maxlength=64)
>     daymap = models.IntegerField()
>     monthmap = models.SmallIntegerField(default=4095)
>     period =
> models.SmallIntegerField(default=0,choices=RESOURCE_SCHEDULE_PERIODS,validator_list=[validators.NumberIsInRange(0,6)])
>     frequency = models.SmallIntegerField(default=1)
>     time_from = models.TimeField(default='09:00:00')
>     duration = models.TimeField(default='00:30:00')
>     date_from = models.DateField()
>     date_to = models.DateField(null=True)
>
>
> Which covers all the rule bits I will need.
>
> The daymap and monthmap are used depending on what the period is (Weekly,
> Monthly etc.) to store exactly wich days & months the event should repeat
> in. I store these as a bitmap for minimizing data storage, but it is
> easily searchable with SQL and the bitmaps can be simply expanded to lists
> for display in forms (as Checkbox Lists for example). You could of course
> store the days/months more explicitly in your table.
>
> frequency is the interval part of the rule giving you every 'n' weeks for
> example.
>
> Its pretty easy to then find the ResourceSchedules that might be
> candidates for having events in your datefrom/dateto period and shoving
> them into and rrule/rruleset.
>
> It might be overkill for some simple tasks but I need the flexibility.
> This way I can store/generate just about any repeating pattern I care to
> think of.

Mostly I'm cool with that, but one thing just isn't clicking yet: Your
date_from and date_to fields, I'm guessing these represent the from/to
dates of the *original* event, and aren't affected by repetitions? So
if that's the case, how do you initially pull your ResourceSchedules
out of the database? It looks to me like you'd have to pull them all
out (ie. ResourceSchedule.objects.all()), generate rrules for all of
them, and see which of the rrules fit into a desired timespan. Is that
right?

By the way, it warms my heart to see you storing bitfields. My area is
embedded devices, not web stuff, so I often spend my days working with
bitfields and masks and such. Good to see that tradition carried into
some Django :)

Jay P.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to