Comments (3)
Is there a way to handle this with current code? I am having the same situation.
Thanks!!!
from django-swingtime.
Here's what I am doing... I cloned the repo and modified the source directly to add a method to the OccurrenceManager class, but you could just write a function that takes two occurrences, or subclass occurrence.
def occurrence_at_time_exists(self, start, end, occurrence_set=None):
if not occurrence_set:
occurrence_set = Occurrence.objects.all()
occurrence_set.filter(start_time__lte=start, end_time__gte=start)
overlaps = occurrence_set.filter(
models.Q(start_time__lte=start, end_time__gt=start) |
models.Q(start_time__gte=start, start_time__lt=end) |
models.Q(start_time=start, end_time=end)
).exists()
return overlaps
Note that this implementation returns False if one occurrence begins at the same time that the other ends. For example, if I have an occurrence from 9:00-10:00 and another from 10:00-11:00 this would not interpret them as overlapping.
from django-swingtime.
Thanks. I am working more modifications on swingtime code, this really helps. Thanks again!!!
from django-swingtime.
Related Issues (20)
- Add a setup.py file HOT 2
- Freeze when count = 0 is passed HOT 1
- Add all day events
- Documentation on correlating a swingtime model with my own models. HOT 1
- Recent documents HOT 1
- Swingtime migrations HOT 4
- Suggestion: allow programmatically generated occurences HOT 3
- Support for multiple timezones
- Event title error when containing special characters like "é" : 'ascii' codec can't encode character u'\xe9' in position 1: ordinal not in range(128) HOT 1
- Dict or List format of daily events for more sophisticated monthly calendar layouts HOT 1
- Plans for merging abstract models branch HOT 2
- How do you install the demo? HOT 3
- Web user interface for add/remove/change of "Event type"?
- Release 1.1.0 HOT 1
- TypeError - can't compare offset-naive and offset-aware datetimes HOT 1
- Demo does not work HOT 1
- Reverse for 'swingtime-occurrence' .... HOT 3
- Ability to delete outside of the admin
- Are the docs online? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-swingtime.