gregplaysguitar / django-eventtools Goto Github PK
View Code? Open in Web Editor NEWA lightweight library designed to handle repeating and one-off event occurrences for display on a website.
License: Other
A lightweight library designed to handle repeating and one-off event occurrences for display on a website.
License: Other
I've got a base occurrence with the following
next --> datetime.datetime(2017, 12, 24, 16, 0, tzinfo=) or 2017-12-24 10:00:00-06 (SGT)
repeat --> u'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;INTERVAL=1'
calling next_occurrence(from_date=timezone.now()) whereby timezone.now() is datetime.datetime(2017, 12, 26, 15, 49, 58, 221887, tzinfo=) seems to be pulling dates from before the above see below which is calling for a date on the 25th instead of the 27th.
(datetime.datetime(2017, 12, 25, 0, 0, tzinfo=<DstTzInfo 'Asia/Singapore' SGT+8:00:00 STD>), datetime.datetime(2017, 12, 28, 1, 0, tzinfo=<DstTzInfo 'Asia/Singapore' SGT+8:00:00 STD>), <TaskRem: 2017-05-30 16:00:00+00:00>)
I have to do the following to get the next date:
nlist = self.all_occurrences(from_date=timezone.now())
next = None
for x in nlist:
if x[0] > timezone.now():
next = x[0]
break
Some clarifications on next_occurence would be good
Hello @gregplaysguitar ,
Thanks for eventtools.
I'm encountering a challenge and I'm not proficient enough to know if it's a bug.
My models looks like
class Programme(BaseEvent): title = models.CharField(max_length=255, blank=False)
while trying to loop over qs.station for qs = Programme.objects.select_related('station').filter(station__user=self.user)
, I run into an AttributeError 'EventQuerySet' object has no attribute 'station'
This would work if I was inhering from models.Model.
Look forward to your help.
I'm wondering if there is any reason why wheels (.whl
) are not being published in addition to the source distributions? One advantage to wheels from the python infrastructure standpoint is they install much faster as PyPI is able to pre-resolve the dependencies. And if your package is "pure" python (no C extensions) then building a wheel is very simple.
I am trying to optimize our dependency tree (coderedcms) and am therefore reaching out to any of our dependencies who do not yet publish in wheel format. Let me know if you are able to do this - I would be happy to help.
The command to build both source distribution and wheel is:
python setup.py sdist bdist_wheel
Then upload both as usual to PyPI.
I realize this may be outside the scope of this library, but I found myself in need of using a wider array of options from rrule, since I need to be able to integrate Google Calendar JSON output.
On the face of it, the easiest way out would be to use a string for BaseOccurrence.repeat, instead of an integer, and update the code to get the repeater accordingly. If I'm not mistaken, the change should have a relatively minor performance hit because it looks like the repeater and the generators do most of the work. This would also have the added benefit of allowing rrulesets without (I think) any other code changes.
Alternatively, to ensure backwards compatibility, a new BaseOccurrence.repeat_str field could be added, with checks to ensure only one of the rules is used and a conditional to decide which field should be used to create the repeater.
Given the scope of this, I'll wait for your feedback before proceeding.
I can't seem to register these like other models in django admin.
I had some problems when I set TZ_INFO=True in settings.py. In particular, I can't call next_occurrence_start = self.next_occurrence(from_date=now)[0]
Traceback (most recent call last):
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/wagtail/wagtailcore/views.py", line 25, in serve
return page.serve(request, *args, **kwargs)
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/wagtail/contrib/wagtailroutablepage/models.py", line 101, in serve
return view(request, *args, **kwargs)
File "/Users/Gross/Sites/Atelier/whitebox/page/models/events_page.py", line 90, in events_list_view
self.get_events_list()
File "/Users/Gross/Sites/Atelier/whitebox/page/models/events_page.py", line 83, in serialize_events_list
return events_model.preview_serializer(events, many=True).data
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/serializers.py", line 658, in data
ret = super(ListSerializer, self).data
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/serializers.py", line 223, in data
self._data = self.to_representation(self.instance)
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/serializers.py", line 598, in to_representation
self.child.to_representation(item) for item in iterable
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/serializers.py", line 447, in to_representation
attribute = field.get_attribute(instance)
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/fields.py", line 401, in get_attribute
return get_attribute(instance, self.source_attrs)
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/rest_framework/fields.py", line 76, in get_attribute
instance = getattr(instance, attr)
File "/Users/Gross/Sites/Atelier/whitebox/page/models/events_page.py", line 264, in next_event_occurrence
next_occurrence_start = self.next_occurrence(from_date=now)[0]
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/eventtools/models.py", line 139, in next_occurrence
self.all_occurrences(from_date=from_date, to_date=to_date))
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/eventtools/models.py", line 23, in first_item
return next(gen)
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/eventtools/models.py", line 54, in combine_occurrences
next_date = next(gen)
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/eventtools/models.py", line 331, in all_occurrences
inc=True
File "/Users/Gross/.virtualenvs/whitebox/lib/python2.7/site-packages/dateutil/rrule.py", line 225, in between
if i > before:
TypeError: can't compare offset-naive and offset-aware datetimes
At this point, i is datetime.datetime(2016, 2, 26, 10, 2, tzinfo=<UTC>)
, and before is datetime.datetime(2016, 3, 4, 23, 59, 59)
.
The problem seems to be that as_datetime strips off timezone information, but the timezone information is left on the dates used in the generator.
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.
add verbose_name to BaseOccurrence's model fields to help spread this library across non-english countries
start = models.DateTimeField(db_index=True [, verbose_name='start'])
end = models.DateTimeField(db_index=True, null=True, blank=True [, verbose_name='end'])
repeat = ChoiceTextField(choices=REPEAT_CHOICES, default='', blank=True [, verbose_name='repeat'])
repeat_until = models.DateField(null=True, blank=True [, verbose_name='repeat_until'])
Shouldn't all_occurrences method return all the occurrences between a start and end date?
Ex: If I set repeat with a rrulestr like "RRULE:FREQ=DAILY:BYDAY=FR,MO", shouldn't it return all Fridays and Mondays occurrences between the start and end dates?
The section regarding queryset filtering specifies:
Event and Occurrence querysets can be filtered, but due to uncertainty with repetitions, from_date filtering is only an approximation (whereas to_date filtering is accurate).
It would be nice to know what exactly this means. How is it an approximation or what results should we expect?
I'm currently afraid to use those functions, as I'm not sure how they will behave.
via tox
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.circleci/config.yml
circleci/python 3.8
circleci/python 3.7
circleci/python 3.6
circleci/python 3.5
circleci/python 2.7
circleci/python 3.7
setup.py
Django >=1.8
python-dateutil >=2.1
six >=1.14.0
Is it possible to export events in the iCalendar format?
For occurrences with no logical end, i.e. reminders, deliveries etc
tldr; should event.next_occurrence()
return None
rather than failing?
Maybe I'm not using django-eventtools properly, but the nice thing about next_occurrence() is I don't have to worry about any other occurrence in the event; however, if there are no future occurrences, then event.next_occurrence throws a TypeError
with 'NoneType' object is not iterable
.
Handling the TypeError
seems a bit too generic, so would a custom OccurrenceError
or simply returning None
be more useful here?
Cheers!
Since all_occurrences doesn't return a queryset but a generator object, how would you go about paginating all occurrences?
datetimefield is neccessary for occurrences that change in the middle of day. Is that possible?
Hello,
There are some issue when upgrading to Django 3.0.
The first item where it fails is python_2_unicode_compatible.
Is it possible to release a new version with support for Django 3.0?
This lib is used in CoderedCMS and we need this for the upgrade, see coderedcorp/coderedcms#290
Kind regards,
Jorne
How does one retrieve all occurences for a single day? I ve tried specifying from_date and to_date parameters but it returns zero occurrences.
Shouldn't just filter out events without being asked
Is there a tutorial example of how the library is used fully with a front end. Any resources will be appreciated.
Great tool. Enjoying it, but for our use, it's needs one more feature.
The ability to make an Occurrence entry that can either a) override an occurrence or b) remove an occurrence.
So, the weekly Tuesday, 2:00pm meeting is at 3:00pm this week and cancelled next week.
Currently only works if the class is called Occurrence; could mandate a related_name but that'll break backwards compatibility
If you create an event that starts during daylight or standard time that recurs, and as a result of that recurrence, crosses the boundary to the other time, the event times on the other side of the boundary will be skewed.
Example:
On an EST5EDT system, the offset from UTC is currently -0500hrs. If you create an event that first occurs on November 5 that starts at 10AM, and recurs once a week, it will show as starting at 9AM on the second occurrence.
I think the problem may be related to when the timezone conversion is applied; I think a naïve datetime has to be sent to the repeater then localized after iteration.
Hello,
I'm looking to see if there's a way to add a biweekly, that's once every 2 weeks.
I'm happy to update your code also but I would need some guidance.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.