pax_global_header00006660000000000000000000000064144416335320014517gustar00rootroot0000000000000052 comment=4ac3f97651a864d83238da01d3fa656c90aa0369 django-ical-1.9.2/000077500000000000000000000000001444163353200137005ustar00rootroot00000000000000django-ical-1.9.2/.coveragerc000066400000000000000000000000511444163353200160150ustar00rootroot00000000000000[run] branch = True source = django_ical django-ical-1.9.2/.github/000077500000000000000000000000001444163353200152405ustar00rootroot00000000000000django-ical-1.9.2/.github/workflows/000077500000000000000000000000001444163353200172755ustar00rootroot00000000000000django-ical-1.9.2/.github/workflows/release.yml000066400000000000000000000017421444163353200214440ustar00rootroot00000000000000name: Release on: push: tags: - '*' jobs: build: if: github.repository == 'jazzband/django-ical' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v2 with: python-version: 3.8 - name: Install dependencies run: | python -m pip install -U pip python -m pip install -U setuptools twine wheel - name: Build package run: | python setup.py --version python setup.py sdist --format=gztar bdist_wheel twine check dist/* - name: Upload packages to Jazzband if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master with: user: jazzband password: ${{ secrets.JAZZBAND_RELEASE_KEY }} repository_url: https://jazzband.co/projects/django-ical/upload django-ical-1.9.2/.github/workflows/test.yml000066400000000000000000000041451444163353200210030ustar00rootroot00000000000000name: Test on: [push, pull_request] jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false max-parallel: 5 matrix: python-version: ['3.8', '3.9', '3.10', '3.11', 'pypy-3.8'] django-version: ['3.2', '4.0', '4.1'] include: # Tox configuration for QA environment - python-version: '3.10' django-version: 'qa' # Django main - python-version: '3.8' django-version: 'main' experimental: true - python-version: '3.9' django-version: 'main' experimental: true - python-version: '3.10' django-version: 'main' experimental: true - python-version: '3.11' django-version: 'main' experimental: true - python-version: 'pypy-3.8' django-version: 'main' experimental: true exclude: # Exclude Django 4.0 for Python 3.11 - python-version: '3.11' django-version: '4.0' # Exclude Django 3.2 for Python 3.11 - python-version: '3.11' django-version: '3.2' steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Get pip cache dir id: pip-cache run: | echo "::set-output name=dir::$(pip cache dir)" - name: Cache uses: actions/cache@v2 with: path: ${{ steps.pip-cache.outputs.dir }} key: ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }} restore-keys: | ${{ matrix.python-version }}-v1- - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install --upgrade tox tox-gh-actions - name: Tox tests run: | tox -v env: DJANGO: ${{ matrix.django-version }} - name: Upload coverage uses: codecov/codecov-action@v1 with: name: Python ${{ matrix.python-version }} django-ical-1.9.2/.gitignore000066400000000000000000000002221444163353200156640ustar00rootroot00000000000000syntax: glob .idea *.orig *.rej *~ *.bak *.marks *.o *.pyc *.swp *.egg-info .eggs .tox build temp dist .coverage syntax: regexp .*\#.*\#$ .venv/ django-ical-1.9.2/.pre-commit-config.yaml000066400000000000000000000000121444163353200201520ustar00rootroot00000000000000repos: [] django-ical-1.9.2/.prospector.yaml000066400000000000000000000001501444163353200170360ustar00rootroot00000000000000ignore-paths: - docs pep8: options: max-line-length: 88 pylint: disable: - import-error django-ical-1.9.2/CHANGES.rst000066400000000000000000000064101444163353200155030ustar00rootroot00000000000000 Changes ======= 1.9.2 (2023-06-12) ------------------ - Support all properties specified in RFC 5545 [magicbrothers] 1.9.1 (2023-05-01) ------------------ - Fix multiple CATEGORIES and add tests [mjfinney] 1.9.0 (2023-04-04) ------------------ - Support for iCalendar VTODO elements [wetneb] 1.8.4 (2023-04-02) ------------------ - Fix content-type charset declarations. [lchanouha] - Update test matrix. Add Python 3.11 and Django 4.1 support. Deprecate Python 3.7 support. [aleksihakli] 1.8.3 (2022-01-25) ------------------ - Enable Python 3.10 and Django 4.0 support. [aleksihakli] 1.8.2 (2022-01-13) ------------------ - Deprecate universal Python 2 wheels. [aleksihakli] 1.8.1 (2022-01-08) ------------------ - Drop Python 3.6 support and add Python 3.10 support. [aleksihakli] 1.8.0 (2021-05-21) ------------------ - Add ``VALARM`` support and documentation. [malteger] 1.7.3 (2021-05-03) ------------------ - Fix calendar ``Content-Type`` headers. Previous configuration included multiple comma separated values in the header, which is incompatible with the HTTP header specification. [aleksihakli] 1.7.2 (2020-12-16) ------------------ - Add support for Python 3.9. [aleksihakli] - Add support for Django 3.1. [aleksihakli] - Add tox QA with black and prospector. [aleksihakli] - Migrate from Travis to GitHub Actions. [aleksihakli] 1.7.1 (2020-05-09) ------------------ - Drop support for Django 1.11 LTS. [aleksihakli] - Fix string comparison in tests. [aleksihakli] 1.7.0 (2019-10-09) ------------------ - Add calendar MIME types for feeds. [xkill] - Add attendees for calendar events. [webaholik] 1.6.2 (2019-08-30) ------------------ - Language and documentation improvements. 1.6.1 (2019-08-30) ------------------ - Python 3.8 and PyPy support. 1.6 (2019-08-27) ---------------- - Drop support for old Python and Django versions. This enables support for new Django versions which do not have Python 2 compatibility shims. - Add continuous delivery via Jazzband. - Add SCM versioning via setuptools_scm. 1.5 (2018-10-10) ---------------- - Add support for Django 1.11. *Thanks, Martin Bächtold* - Drop support for Python 2.6. *Thanks, Martin Bächtold* - Add support for categories, rrule, exrule, rrdate, exdate. *Thanks, Armin Leuprecht* - Fix a documentation typo. *Thanks, Giorgos Logiotatidis* - Add documentation and testing around recurring events. *Thanks, Christian Ledermann* - Remove tests for Django versions < 1.8 *Thanks, Christian Ledermann* 1.4 (2016-05-08) ---------------- - Django up to 1.9 is supported. - Added new `ttl` parameter. *Thanks, Diaz-Gutierrez* - Added support for Python 3. *Thanks, Ben Lopatin* - Fixed LAST-MODIFIED support. *Thanks, Brad Bell* 1.3 (2014-11-26) ---------------- - Django up to 1.7 is supported. - Added a new `file_name` parameter. *Thanks, browniebroke* - Added support for the `ORGANIZER` field. *Thanks, browniebroke* 1.2 (2012-12-12) ---------------- - Removed support for Django 1.2. It should still work, but it's not supported. - We now require icalendar 3.1. - Added support for the `GEO` field. *Thanks, null_radix!* 1.1 (2012-10-26) ---------------- - Fixed issues running tests on Django 1.2 and Django 1.5. 1.0 (2012-05-06) ---------------- - Initial Release django-ical-1.9.2/CODE_OF_CONDUCT.md000066400000000000000000000045071444163353200165050ustar00rootroot00000000000000# Code of Conduct As contributors and maintainers of the Jazzband projects, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. We are committed to making participation in the Jazzband a harassment-free experience for everyone, regardless of the level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. Examples of unacceptable behavior by participants include: - The use of sexualized language or imagery - Personal attacks - Trolling or insulting/derogatory comments - Public or private harassment - Publishing other's private information, such as physical or electronic addresses, without explicit permission - Other unethical or unprofessional conduct The Jazzband roadies have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. By adopting this Code of Conduct, the roadies commit themselves to fairly and consistently applying these principles to every aspect of managing the jazzband projects. Roadies who do not follow or enforce the Code of Conduct may be permanently removed from the Jazzband roadies. This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the roadies at `roadies@jazzband.co`. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Roadies are obligated to maintain confidentiality with regard to the reporter of an incident. This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.3.0, available at [https://contributor-covenant.org/version/1/3/0/][version] [homepage]: https://contributor-covenant.org [version]: https://contributor-covenant.org/version/1/3/0/ django-ical-1.9.2/CONTRIBUTING.md000066400000000000000000000005671444163353200161410ustar00rootroot00000000000000[![Jazzband](https://jazzband.co/static/img/jazzband.svg)](https://jazzband.co/) This is a [Jazzband](https://jazzband.co/) project. By contributing you agree to abide by the [Contributor Code of Conduct](https://jazzband.co/about/conduct) and follow the [guidelines](https://jazzband.co/about/guidelines). Have ideas for how this project can improve? Open a pull request! django-ical-1.9.2/LICENSE000066400000000000000000000020641444163353200147070ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2012 Ian Lewis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. django-ical-1.9.2/MANIFEST.in000066400000000000000000000000601444163353200154320ustar00rootroot00000000000000include README.rst CHANGES.rst LICENSE tests.py django-ical-1.9.2/README.rst000066400000000000000000000032631444163353200153730ustar00rootroot00000000000000django-ical =========== |pypi| |docs| |build| |coverage| |jazzband| django-ical is a simple library/framework for creating `iCal `_ feeds based in Django's `syndication feed framework `_. This documentation is modeled after the documentation for the syndication feed framework so you can think of it as a simple extension. If you are familiar with the Django syndication feed framework you should be able to be able to use django-ical fairly quickly. It works the same way as the Django syndication framework but adds a few extension properties to support iCalendar feeds. django-ical uses the `icalendar `_ library under the hood to generate iCalendar feeds. Documentation ------------- Documentation is hosted on Read the Docs: https://django-ical.readthedocs.io/en/latest/ .. |pypi| image:: https://img.shields.io/pypi/v/django-ical.svg :alt: PyPI :target: https://pypi.org/project/django-ical/ .. |docs| image:: https://readthedocs.org/projects/django-ical/badge/?version=latest :alt: Documentation Status :scale: 100% :target: http://django-ical.readthedocs.io/en/latest/?badge=latest .. |build| image:: https://github.com/jazzband/django-ical/workflows/Test/badge.svg :target: https://github.com/jazzband/django-ical/actions :alt: GitHub Actions .. |coverage| image:: https://codecov.io/gh/jazzband/django-ical/branch/master/graph/badge.svg :target: https://codecov.io/gh/jazzband/django-ical :alt: Coverage .. |jazzband| image:: https://jazzband.co/static/img/badge.svg :target: https://jazzband.co/ :alt: Jazzband django-ical-1.9.2/django_ical/000077500000000000000000000000001444163353200161325ustar00rootroot00000000000000django-ical-1.9.2/django_ical/__init__.py000066400000000000000000000000001444163353200202310ustar00rootroot00000000000000django-ical-1.9.2/django_ical/feedgenerator.py000066400000000000000000000106351444163353200213230ustar00rootroot00000000000000""" iCalendar feed generation library -- used for generating iCalendar feeds. Sample usage: >>> from django_ical import feedgenerator >>> from datetime import datetime >>> feed = feedgenerator.ICal20Feed( ... title="My Events", ... link="http://www.example.com/events.ical", ... description="A iCalendar feed of my events.", ... language="en", ... ) >>> feed.add_item( ... title="Hello", ... link="http://www.example.com/test/", ... description="Testing.", ... start_datetime=datetime(2012, 5, 6, 10, 00), ... end_datetime=datetime(2012, 5, 6, 12, 00), ... ) >>> fp = open('test.ical', 'wb') >>> feed.write(fp, 'utf-8') >>> fp.close() For definitions of the iCalendar format see: http://www.ietf.org/rfc/rfc2445.txt """ from icalendar import Calendar, Event, Todo from django.utils.feedgenerator import SyndicationFeed __all__ = ("ICal20Feed", "DefaultFeed") FEED_FIELD_MAP = ( ("product_id", "prodid"), ("method", "method"), ("title", "x-wr-calname"), ("description", "x-wr-caldesc"), ("timezone", "x-wr-timezone"), ( "ttl", "x-published-ttl", ), # See format here: http://www.rfc-editor.org/rfc/rfc2445.txt (sec 4.3.6) ) ITEM_ELEMENT_FIELD_MAP = ( # 'item_guid' becomes 'unique_id' when passed to the SyndicationFeed ("unique_id", "uid"), ("title", "summary"), ("description", "description"), ("start_datetime", "dtstart"), ("end_datetime", "dtend"), ("updateddate", "last-modified"), ("created", "created"), ("timestamp", "dtstamp"), ("transparency", "transp"), ("location", "location"), ("geolocation", "geo"), ("link", "url"), ("organizer", "organizer"), ("categories", "categories"), ("rrule", "rrule"), ("exrule", "exrule"), ("rdate", "rdate"), ("exdate", "exdate"), ("status", "status"), ("attendee", "attendee"), ("valarm", None), # additional properties supported by the Todo class (VTODO calendar component). # see https://icalendar.readthedocs.io/en/latest/_modules/icalendar/cal.html#Todo ("completed", "completed"), ("percent_complete", "percent-complete"), ("priority", "priority"), ("due", "due"), ("calscale", "calscale"), ("method", "method"), ("prodid", "prodid"), ("version", "version"), ("attach", "attach"), ("class", "class"), ("comment", "comment"), ("resources", "resources"), ("duration", "duration"), ("freebusy", "freebusy"), ("tzid", "tzid"), ("tzname", "tzname"), ("tzoffsetfrom", "tzoffsetfrom"), ("tzoffsetto", "tzoffsetto"), ("tzurl", "tzurl"), ("contact", "contact"), ("recurrence_id", "recurrence-id"), ("related_to", "related-to"), ("action", "action"), ("repeat", "repeat"), ("trigger", "trigger"), ("sequence", "sequence"), ("request_status", "request-status"), ) class ICal20Feed(SyndicationFeed): """ iCalendar 2.0 Feed implementation. """ mime_type = "text/calendar; charset=utf-8" def write(self, outfile, encoding): """ Writes the feed to the specified file in the specified encoding. """ cal = Calendar() cal.add("version", "2.0") cal.add("calscale", "GREGORIAN") for ifield, efield in FEED_FIELD_MAP: val = self.feed.get(ifield) if val is not None: cal.add(efield, val) self.write_items(cal) to_ical = getattr(cal, "as_string", None) if not to_ical: to_ical = cal.to_ical outfile.write(to_ical()) def write_items(self, calendar): """ Write all elements to the calendar """ for item in self.items: component_type = item.get("component_type") if component_type == "todo": element = Todo() else: element = Event() for ifield, efield in ITEM_ELEMENT_FIELD_MAP: val = item.get(ifield) if val is not None: if ifield == "attendee": for list_item in val: element.add(efield, list_item) elif ifield == "valarm": for list_item in val: element.add_component(list_item) else: element.add(efield, val) calendar.add_component(element) DefaultFeed = ICal20Feed django-ical-1.9.2/django_ical/tests/000077500000000000000000000000001444163353200172745ustar00rootroot00000000000000django-ical-1.9.2/django_ical/tests/__init__.py000066400000000000000000000000001444163353200213730ustar00rootroot00000000000000django-ical-1.9.2/django_ical/tests/test_feed.py000066400000000000000000000461751444163353200216250ustar00rootroot00000000000000from datetime import date from datetime import datetime from datetime import timedelta from os import linesep from django.test import TestCase from django.test.client import RequestFactory from dateutil import tz import icalendar from django_ical import utils from django_ical.feedgenerator import ICal20Feed from django_ical.views import ICalFeed class TestICalFeed(ICalFeed): feed_type = ICal20Feed title = "Test Feed" description = "Test ICal Feed" items = [] class TestItemsFeed(ICalFeed): feed_type = ICal20Feed title = "Test Feed" description = "Test ICal Feed" def items(self): return [ { "component_type": "event", "title": "Title1", "description": "Description1", "link": "/event/1", "start": datetime(2012, 5, 1, 18, 0), "end": datetime(2012, 5, 1, 20, 0), "recurrences": { "rrules": [ utils.build_rrule(freq="DAILY", byhour=10), utils.build_rrule(freq="MONTHLY", bymonthday=4), ], "xrules": [ utils.build_rrule(freq="MONTHLY", bymonthday=-4), utils.build_rrule(freq="MONTHLY", byday="+3TU"), ], "rdates": [date(1999, 9, 2), date(1998, 1, 1)], "xdates": [date(1999, 8, 1), date(1998, 2, 1)], }, "geolocation": (37.386013, -122.082932), "organizer": "john.doe@example.com", "participants": [ { "email": "joe.unresponsive@example.com", "cn": "Joe Unresponsive", "partstat": "NEEDS-ACTION", }, { "email": "jane.attender@example.com", "cn": "Jane Attender", "partstat": "ACCEPTED", }, { "email": "dan.decliner@example.com", "cn": "Dan Decliner", "partstat": "DECLINED", }, { "email": "mary.maybe@example.com", "cn": "Mary Maybe", "partstat": "TENTATIVE", }, ], "modified": datetime(2012, 5, 2, 10, 0), }, { "component_type": "event", "title": "Title2", "description": "Description2", "link": "/event/2", "start": datetime(2012, 5, 6, 18, 0), "end": datetime(2012, 5, 6, 20, 0), "recurrences": { "rrules": [ utils.build_rrule( freq="WEEKLY", byday=["MO", "TU", "WE", "TH", "FR"] ) ], "xrules": [utils.build_rrule(freq="MONTHLY", byday="-3TU")], "rdates": [date(1997, 9, 2)], "xdates": [date(1997, 8, 1)], }, "geolocation": (37.386013, -122.082932), "modified": datetime(2012, 5, 7, 10, 0), "organizer": { "cn": "John Doe", "email": "john.doe@example.com", "role": "CHAIR", }, "categories": ['Cat1', 'Cat2'], "alarms": [ { "trigger": timedelta(minutes=-30), "action": "DISPLAY", "description": "Alarm2a", }, { "trigger": timedelta(days=-1), "action": "DISPLAY", "description": "Alarm2b", }, ], }, { "component_type": "todo", "title": "Submit Revised Internet-Draft", "description": "an important test", "link": "/event/3", "start": datetime(2007, 5, 14, 0), "due": datetime(2007, 5, 16, 0), "completed": datetime(2007, 3, 20), "priority": 1, "status": "NEEDS-ACTION", "organizer": { "cn": "Bossy Martin", "email": "bossy.martin@example.com", "role": "CHAIR" }, "modified": datetime(2012, 5, 2, 10, 0), "geolocation": (37.386013, 2.238985), "categories": ['CLEANING'], "percent_complete": 89, }, ] def item_component_type(self, obj): return obj.get("component_type", None) def item_title(self, obj): return obj["title"] def item_description(self, obj): return obj["description"] def item_start_datetime(self, obj): return obj["start"] def item_end_datetime(self, obj): return obj.get("end", None) def item_due_datetime(self, obj): return obj.get("due", None) def item_rrule(self, obj): return obj.get("recurrences", {}).get("rrules", None) def item_exrule(self, obj): return obj.get("recurrences", {}).get("xrules", None) def item_rdate(self, obj): return obj.get("recurrences", {}).get("rdates", None) def item_exdate(self, obj): return obj.get("recurrences", {}).get("xdates", None) def item_link(self, obj): return obj["link"] def item_geolocation(self, obj): return obj.get("geolocation", None) def item_updateddate(self, obj): return obj.get("modified", None) def item_pubdate(self, obj): return obj.get("modified", None) def item_completed(self, obj): return obj.get("completed", None) def item_percent_complete(self, obj): return obj.get("percent_complete", None) def item_priority(self, obj): return obj.get("priority", None) def item_due(self, obj): return obj.get("due", None) def item_categories(self, obj): return obj.get("categories") or [] def item_organizer(self, obj): organizer_dic = obj.get("organizer", None) if organizer_dic: if isinstance(organizer_dic, dict): organizer = icalendar.vCalAddress("MAILTO:%s" % organizer_dic["email"]) for key, val in organizer_dic.items(): if key != "email": organizer.params[key] = icalendar.vText(val) else: organizer = icalendar.vCalAddress("MAILTO:%s" % organizer_dic) return organizer def item_attendee(self, obj): """All calendars support ATTENDEE attribute, however, at this time, Apple calendar (desktop & iOS) and Outlook display event attendees, while Google does not. For SUBSCRIBED calendars it seems that it is not possible to use the default method to respond. As an alternative, you may review adding custom links to your description or setting up something like CalDav with authentication, which can enable the ability for attendees to respond via the default icalendar protocol.""" participants = obj.get("participants", None) if participants: attendee_list = list() default_attendee_params = { "cutype": icalendar.vText("INDIVIDUAL"), "role": icalendar.vText("REQ-PARTICIPANT"), "rsvp": icalendar.vText( "TRUE" ), # Does not seem to work for subscribed calendars. } for participant in participants: attendee = icalendar.vCalAddress("MAILTO:%s" % participant.pop("email")) participant_dic = default_attendee_params.copy() participant_dic.update(participant) for key, val in participant_dic.items(): attendee.params[key] = icalendar.vText(val) attendee_list.append(attendee) return attendee_list def item_valarm(self, obj): alarms = obj.get("alarms", None) if alarms: alarm_list = list() for alarm in alarms: valarm = icalendar.Alarm() for key, value in alarm.items(): valarm.add(key, value) alarm_list.append(valarm) return alarm_list class TestFilenameFeed(ICalFeed): feed_type = ICal20Feed title = "Test Filename Feed" description = "Test ICal Feed" def get_object(self, request): return {"id": 123} def items(self, obj): return [obj] def file_name(self, obj): return "%s.ics" % obj["id"] def item_link(self, item): return "" # Required by the syndication framework class ICal20FeedTest(TestCase): def test_basic(self): request = RequestFactory().get("/test/ical") view = TestICalFeed() response = view(request) calendar = icalendar.Calendar.from_ical(response.content) self.assertEqual(calendar["X-WR-CALNAME"], "Test Feed") self.assertEqual(calendar["X-WR-CALDESC"], "Test ICal Feed") def test_items(self): request = RequestFactory().get("/test/ical") view = TestItemsFeed() response = view(request) calendar = icalendar.Calendar.from_ical(response.content) self.assertEqual(len(calendar.subcomponents), 3) self.assertEqual(calendar.subcomponents[0]["SUMMARY"], "Title1") self.assertEqual(calendar.subcomponents[0]["DESCRIPTION"], "Description1") self.assertTrue(calendar.subcomponents[0]["URL"].endswith("/event/1")) self.assertEqual( calendar.subcomponents[0]["DTSTART"].to_ical(), b"20120501T180000" ) self.assertEqual( calendar.subcomponents[0]["DTEND"].to_ical(), b"20120501T200000" ) self.assertEqual( calendar.subcomponents[0]["GEO"].to_ical(), "37.386013;-122.082932" ) self.assertEqual( calendar.subcomponents[0]["LAST-MODIFIED"].to_ical(), b"20120502T100000Z" ) self.assertEqual( calendar.subcomponents[0]["ORGANIZER"].to_ical(), b"MAILTO:john.doe@example.com", ) self.assertEqual( calendar.subcomponents[0]["ATTENDEE"][0].to_ical(), b"MAILTO:joe.unresponsive@example.com", ) self.assertEqual( calendar.subcomponents[0]["ATTENDEE"][0].params.to_ical(), b'CN="Joe Unresponsive";CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;' b"RSVP=TRUE", ) self.assertEqual( calendar.subcomponents[0]["ATTENDEE"][1].to_ical(), b"MAILTO:jane.attender@example.com", ) self.assertEqual( calendar.subcomponents[0]["ATTENDEE"][1].params.to_ical(), b'CN="Jane Attender";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT;RSVP=TRUE', ) self.assertEqual( calendar.subcomponents[0]["ATTENDEE"][2].to_ical(), b"MAILTO:dan.decliner@example.com", ) self.assertEqual( calendar.subcomponents[0]["ATTENDEE"][2].params.to_ical(), b'CN="Dan Decliner";CUTYPE=INDIVIDUAL;PARTSTAT=DECLINED;ROLE=REQ-PARTICIPANT;RSVP=TRUE', ) self.assertEqual( calendar.subcomponents[0]["ATTENDEE"][3].to_ical(), b"MAILTO:mary.maybe@example.com", ) self.assertEqual( calendar.subcomponents[0]["ATTENDEE"][3].params.to_ical(), b'CN="Mary Maybe";CUTYPE=INDIVIDUAL;PARTSTAT=TENTATIVE;ROLE=REQ-PARTICIPANT;RSVP=TRUE', ) self.assertEqual( calendar.subcomponents[0]["RRULE"][0].to_ical(), b"FREQ=DAILY;BYHOUR=10" ) self.assertEqual( calendar.subcomponents[0]["RRULE"][1].to_ical(), b"FREQ=MONTHLY;BYMONTHDAY=4", ) self.assertEqual( calendar.subcomponents[0]["EXRULE"][0].to_ical(), b"FREQ=MONTHLY;BYMONTHDAY=-4", ) self.assertEqual( calendar.subcomponents[0]["EXRULE"][1].to_ical(), b"FREQ=MONTHLY;BYDAY=+3TU" ) self.assertEqual( calendar.subcomponents[0]["RDATE"].to_ical(), b"19990902,19980101" ) self.assertEqual( calendar.subcomponents[0]["EXDATE"].to_ical(), b"19990801,19980201" ) self.assertEqual(calendar.subcomponents[1]["SUMMARY"], "Title2") self.assertEqual(calendar.subcomponents[1]["DESCRIPTION"], "Description2") self.assertTrue(calendar.subcomponents[1]["URL"].endswith("/event/2")) self.assertEqual( calendar.subcomponents[1]["DTSTART"].to_ical(), b"20120506T180000" ) self.assertEqual( calendar.subcomponents[1]["DTEND"].to_ical(), b"20120506T200000" ) self.assertEqual( calendar.subcomponents[1]["RRULE"].to_ical(), b"FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", ) self.assertEqual( calendar.subcomponents[1]["EXRULE"].to_ical(), b"FREQ=MONTHLY;BYDAY=-3TU" ) self.assertEqual(calendar.subcomponents[1]["RDATE"].to_ical(), b"19970902") self.assertEqual(calendar.subcomponents[1]["EXDATE"].to_ical(), b"19970801") self.assertEqual( calendar.subcomponents[1]["GEO"].to_ical(), "37.386013;-122.082932" ) self.assertEqual( calendar.subcomponents[1]["LAST-MODIFIED"].to_ical(), b"20120507T100000Z" ) self.assertEqual( calendar.subcomponents[1]["ORGANIZER"].to_ical(), b"MAILTO:john.doe@example.com", ) self.assertEqual( calendar.subcomponents[1]["CATEGORIES"].to_ical(), b"Cat1,Cat2" ) self.assertIn( b"BEGIN:VALARM\r\nACTION:DISPLAY\r\nDESCRIPTION:Alarm2a\r\nTRIGGER:-PT30M\r\nEND:VALARM\r\n", [comp.to_ical() for comp in calendar.subcomponents[1].subcomponents], ) self.assertIn( b"BEGIN:VALARM\r\nACTION:DISPLAY\r\nDESCRIPTION:Alarm2b\r\nTRIGGER:-P1D\r\nEND:VALARM\r\n", [comp.to_ical() for comp in calendar.subcomponents[1].subcomponents], ) self.assertEqual(calendar.subcomponents[2]["SUMMARY"], "Submit Revised Internet-Draft") self.assertTrue(calendar.subcomponents[2]["URL"].endswith("/event/3")) self.assertEqual( calendar.subcomponents[2]["DTSTART"].to_ical(), b"20070514T000000" ) self.assertEqual( calendar.subcomponents[2]["DUE"].to_ical(), b"20070516T000000" ) self.assertEqual( calendar.subcomponents[2]["GEO"].to_ical(), "37.386013;2.238985" ) self.assertEqual( calendar.subcomponents[2]["LAST-MODIFIED"].to_ical(), b"20120502T100000Z" ) self.assertEqual( calendar.subcomponents[2]["ORGANIZER"].to_ical(), b"MAILTO:bossy.martin@example.com", ) self.assertEqual( calendar.subcomponents[2]["PRIORITY"].to_ical(), b"1" ) self.assertEqual( calendar.subcomponents[2]["CATEGORIES"].to_ical(), b"CLEANING" ) self.assertEqual( calendar.subcomponents[2]["PERCENT-COMPLETE"].to_ical(), b"89" ) def test_wr_timezone(self): """ Test for the x-wr-timezone property. """ class TestTimezoneFeed(TestICalFeed): timezone = "Asia/Tokyo" request = RequestFactory().get("/test/ical") view = TestTimezoneFeed() response = view(request) calendar = icalendar.Calendar.from_ical(response.content) self.assertEqual(calendar["X-WR-TIMEZONE"], "Asia/Tokyo") def test_timezone(self): tokyo = tz.gettz("Asia/Tokyo") # or JST or Japan Standard Time us_eastern = tz.gettz("US/Eastern") # or EDT or Eastern (Daylight) Time class TestTimezoneFeed(TestItemsFeed): def items(self): return [ { "title": "Title1", "description": "Description1", "link": "/event/1", "start": datetime(2012, 5, 1, 18, 00, tzinfo=tokyo), "end": datetime(2012, 5, 1, 20, 00, tzinfo=tokyo), "recurrences": { "rrules": [], "xrules": [], "rdates": [], "xdates": [], }, }, { "title": "Title2", "description": "Description2", "link": "/event/2", "start": datetime(2012, 5, 6, 18, 00, tzinfo=us_eastern), "end": datetime(2012, 5, 6, 20, 00, tzinfo=us_eastern), "recurrences": { "rrules": [], "xrules": [], "rdates": [], "xdates": [], }, }, ] request = RequestFactory().get("/test/ical") view = TestTimezoneFeed() response = view(request) calendar = icalendar.Calendar.from_ical(response.content) self.assertEqual(len(calendar.subcomponents), 2) self.assertEqual( calendar.subcomponents[0]["DTSTART"].to_ical(), b"20120501T180000" ) self.assertEqual(calendar.subcomponents[0]["DTSTART"].params["TZID"], "JST") self.assertEqual( calendar.subcomponents[0]["DTEND"].to_ical(), b"20120501T200000" ) self.assertEqual(calendar.subcomponents[0]["DTEND"].params["TZID"], "JST") self.assertEqual( calendar.subcomponents[1]["DTSTART"].to_ical(), b"20120506T180000" ) self.assertEqual(calendar.subcomponents[1]["DTSTART"].params["TZID"], "EDT") self.assertEqual( calendar.subcomponents[1]["DTEND"].to_ical(), b"20120506T200000" ) self.assertEqual(calendar.subcomponents[1]["DTEND"].params["TZID"], "EDT") def test_file_name(self): request = RequestFactory().get("/test/ical") view = TestFilenameFeed() response = view(request) self.assertIn("Content-Disposition", response) self.assertEqual( response["content-disposition"], 'attachment; filename="123.ics"' ) def test_file_type(self): request = RequestFactory().get("/test/ical") view = TestFilenameFeed() response = view(request) self.assertIn("Content-Type", response) self.assertEqual(response["content-type"], "text/calendar; charset=utf-8") def test_file_header(self): request = RequestFactory().get("/test/ical") view = TestFilenameFeed() response = view(request) header = b"BEGIN:VCALENDAR\r\nVERSION:2.0" self.assertTrue(response.content.startswith(header)) django-ical-1.9.2/django_ical/tests/test_recurrence.py000066400000000000000000000607351444163353200230550ustar00rootroot00000000000000"""Test calendar rrules.""" import datetime from django.test import TestCase from dateutil import tz from dateutil.rrule import DAILY from dateutil.rrule import MO from dateutil.rrule import MONTHLY from dateutil.rrule import TH from dateutil.rrule import TU from dateutil.rrule import WEEKLY from dateutil.rrule import YEARLY from dateutil.rrule import rrule from icalendar.prop import vRecur import recurrence from django_ical import utils class BuildRruleTest(TestCase): """Test building an Rrule for icalendar.""" def test_every_day(self): """Repeat every day.""" vrecurr = vRecur(utils.build_rrule(freq="DAILY")) assert vrecurr["FREQ"] == "DAILY" assert vrecurr.to_ical().decode() == "FREQ=DAILY" assert len(vrecurr.keys()) == 1 def test_daily_byhour(self): """Repeat every day at 10, 12 and 17.""" vrecurr = utils.build_rrule(freq="DAILY", byhour=[10, 12, 17]) assert vrecurr["FREQ"] == "DAILY" assert vrecurr["BYHOUR"] == [10, 12, 17] vRecur(vrecurr).to_ical().decode() == "FREQ=DAILY;BYHOUR=10,12,17" assert len(vrecurr.keys()) == 2 def test_daily_byhour_once(self): """Repeat every day at 10.""" vrecurr = utils.build_rrule(freq="DAILY", byhour=10) assert vrecurr["FREQ"] == "DAILY" assert vrecurr["BYHOUR"] == 10 vRecur(vrecurr).to_ical().decode() == "FREQ=DAILY;BYHOUR=10" assert len(vrecurr.keys()) == 2 def test_every_week(self): """Repeat every week.""" vrecurr = utils.build_rrule(freq="WEEKLY") assert vrecurr["FREQ"] == "WEEKLY" vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY" assert len(vrecurr.keys()) == 1 def test_ever_hour(self): """Repeat every hour.""" vrecurr = utils.build_rrule(freq="HOURLY") assert vrecurr["FREQ"] == "HOURLY" vRecur(vrecurr).to_ical().decode() == "FREQ=HOURLY" assert len(vrecurr.keys()) == 1 def test_ever_4_hours(self): """Repeat every 4 hours.""" vrecurr = utils.build_rrule(interval=4, freq="HOURLY") assert vrecurr["FREQ"] == "HOURLY" assert vrecurr["INTERVAL"] == 4 vRecur(vrecurr).to_ical().decode() == "FREQ=HOURLY;INTERVAL=4" assert len(vrecurr.keys()) == 2 def test_weekly_tue(self): """Repeat every week on Tuesday.""" vrecurr = utils.build_rrule(freq="WEEKLY", byday="TU") assert vrecurr["FREQ"] == "WEEKLY" assert vrecurr["BYDAY"] == "TU" vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;BYDAY=TU" assert len(vrecurr.keys()) == 2 def test_weekly_mo_wed(self): """Repeat every week on Monday, Wednesday.""" vrecurr = utils.build_rrule(freq="WEEKLY", byday=["MO", "WE"]) assert vrecurr["FREQ"] == "WEEKLY" assert vrecurr["BYDAY"] == ["MO", "WE"] vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;BYDAY=MO,WE" assert len(vrecurr.keys()) == 2 def test_every_weekday(self): """Repeat every weekday.""" vrecurr = utils.build_rrule(freq="WEEKLY", byday=["MO", "TU", "WE", "TH", "FR"]) assert vrecurr["FREQ"] == "WEEKLY" assert vrecurr["BYDAY"] == ["MO", "TU", "WE", "TH", "FR"] vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR" assert len(vrecurr.keys()) == 2 def test_every_2_weeks(self): """Repeat every 2 weeks.""" vrecurr = utils.build_rrule(interval=2, freq="WEEKLY") assert vrecurr["FREQ"] == "WEEKLY" assert vrecurr["INTERVAL"] == 2 vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;INTERVAL=2" assert len(vrecurr.keys()) == 2 def test_every_month(self): """Repeat every month.""" vrecurr = utils.build_rrule(freq="MONTHLY") assert vrecurr["FREQ"] == "MONTHLY" vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY" assert len(vrecurr.keys()) == 1 def test_every_6_months(self): """Repeat very 6 months.""" vrecurr = utils.build_rrule(interval=6, freq="MONTHLY") assert vrecurr["FREQ"] == "MONTHLY" assert vrecurr["INTERVAL"] == 6 vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;INTERVAL=6" assert len(vrecurr.keys()) == 2 def test_every_year(self): """Repeat every year.""" vrecurr = utils.build_rrule(freq="YEARLY") assert vrecurr["FREQ"] == "YEARLY" vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY" assert len(vrecurr.keys()) == 1 def test_every_month_on_the_4th(self): """Repeat every month on the 4th.""" vrecurr = utils.build_rrule(freq="MONTHLY", bymonthday=4) assert vrecurr["FREQ"] == "MONTHLY" assert vrecurr["BYMONTHDAY"] == 4 vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYMONTHDAY=4" assert len(vrecurr.keys()) == 2 def test_every_month_on_the_4th_last(self): """Repeat every month on the 4th last.""" vrecurr = utils.build_rrule(freq="MONTHLY", bymonthday=-4) assert vrecurr["FREQ"] == "MONTHLY" assert vrecurr["BYMONTHDAY"] == -4 vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYMONTHDAY=-4" assert len(vrecurr.keys()) == 2 def test_ever_month_3rd_tu(self): """Repeat every month on the 3rd Tuesday.""" vrecurr = utils.build_rrule(freq="MONTHLY", byday="+3TU") assert vrecurr["FREQ"] == "MONTHLY" assert vrecurr["BYDAY"] == "+3TU" vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYDAY=+3TU" assert len(vrecurr.keys()) == 2 def test_ever_month_3rd_last_tu(self): """Repeat every month on the 3rd last Tuesday.""" vrecurr = utils.build_rrule(freq="MONTHLY", byday="-3TU") assert vrecurr["FREQ"] == "MONTHLY" assert vrecurr["BYDAY"] == "-3TU" vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYDAY=-3TU" assert len(vrecurr.keys()) == 2 def test_ever_month_last_mo(self): """Repeat every month on the last Monday.""" vrecurr = utils.build_rrule(freq="MONTHLY", byday="-1MO") assert vrecurr["FREQ"] == "MONTHLY" assert vrecurr["BYDAY"] == "-1MO" vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYDAY=-1MO" assert len(vrecurr.keys()) == 2 def test_every_week_until_jan_2007(self): """Repeat every week until January 1, 2007.""" utc = tz.UTC jan2007 = datetime.datetime(2007, 1, 1, 0, 0, tzinfo=utc) vrecurr = utils.build_rrule(freq="WEEKLY", until=jan2007) assert vrecurr["FREQ"] == "WEEKLY" assert vrecurr["UNTIL"] == jan2007 vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;UNTIL=20070101T000000Z" assert len(vrecurr.keys()) == 2 def test_every_week_20_times(self): """Repeat every week for 20 times.""" vrecurr = utils.build_rrule(freq="WEEKLY", count=20) assert vrecurr["FREQ"] == "WEEKLY" assert vrecurr["COUNT"] == 20 vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;COUNT=20" assert len(vrecurr.keys()) == 2 def test_every_month_last_working_day(self): """Repeat the last working day of each month.""" vrecurr = utils.build_rrule( freq="MONTHLY", byday=["MO", "TU", "WE", "TH", "FR"], bysetpos=-1 ) assert vrecurr["FREQ"] == "MONTHLY" assert vrecurr["BYDAY"] == ["MO", "TU", "WE", "TH", "FR"] assert vrecurr["BYSETPOS"] == -1 vRecur( vrecurr ).to_ical().decode() == "FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1" assert len(vrecurr.keys()) == 3 def test_ever_month_last_day(self): """Repeat the last day of each month.""" vrecurr = utils.build_rrule(freq="MONTHLY", bymonthday=-1) assert vrecurr["FREQ"] == "MONTHLY" assert vrecurr["BYMONTHDAY"] == -1 vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYMONTHDAY=-1" assert len(vrecurr.keys()) == 2 def test_every_day_in_jan(self): """Repeat every day in January""" vrecurr = utils.build_rrule( freq="YEARLY", bymonth=1, byday=["MO", "TU", "WE", "TH", "FR", "SA", "SU"] ) assert vrecurr["FREQ"] == "YEARLY" assert vrecurr["BYMONTH"] == 1 assert vrecurr["BYDAY"] == ["MO", "TU", "WE", "TH", "FR", "SA", "SU"] vRecur( vrecurr ).to_ical().decode() == "FREQ=YEARLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYMONTH=1" assert len(vrecurr.keys()) == 3 def test_every_2nd_15th_of_month(self): """Repeat monthly on the 2nd and 15th of the month.""" vrecurr = utils.build_rrule(freq="MONTHLY", bymonthday=[4, 15]) assert vrecurr["FREQ"] == "MONTHLY" assert vrecurr["BYMONTHDAY"] == [4, 15] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYMONTHDAY=4,15" assert len(vrecurr.keys()) == 2 def test_every_fr_13th(self): """Repeat every Friday the 13th.""" vrecurr = utils.build_rrule(freq="YEARLY", bymonthday=13, byday="FR") assert vrecurr["FREQ"] == "YEARLY" assert vrecurr["BYMONTHDAY"] == 13 assert vrecurr["BYDAY"] == "FR" vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY;BYDAY=FR;BYMONTHDAY=13" assert len(vrecurr.keys()) == 3 class FromTextTests(TestCase): """Test build a vRecur dictionary from an RRULE string.""" def test_every_day(self): """Repeat every day.""" vrecurr = utils.build_rrule_from_text("FREQ=DAILY") assert vrecurr["FREQ"] == ["DAILY"] vRecur(vrecurr).to_ical().decode() == "FREQ=DAILY" assert len(vrecurr.keys()) == 1 def test_daily_byhour(self): """Repeat every day at 10, 12 and 17.""" vrecurr = utils.build_rrule_from_text("FREQ=DAILY;BYHOUR=10,12,17") assert vrecurr["FREQ"] == ["DAILY"] assert vrecurr["BYHOUR"] == [10, 12, 17] vRecur(vrecurr).to_ical().decode() == "FREQ=DAILY;BYHOUR=10,12,17" assert len(vrecurr.keys()) == 2 def test_every_week(self): """Repeat every week.""" vrecurr = utils.build_rrule_from_text("FREQ=WEEKLY") assert vrecurr["FREQ"] == ["WEEKLY"] vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY" assert len(vrecurr.keys()) == 1 def test_ever_hour(self): """Repeat every hour.""" vrecurr = utils.build_rrule_from_text("FREQ=HOURLY") assert vrecurr["FREQ"] == ["HOURLY"] vRecur(vrecurr).to_ical().decode() == "FREQ=HOURLY" assert len(vrecurr.keys()) == 1 def test_ever_4_hours(self): """Repeat every 4 hours.""" vrecurr = utils.build_rrule_from_text("INTERVAL=4;FREQ=HOURLY") assert vrecurr["FREQ"] == ["HOURLY"] assert vrecurr["INTERVAL"] == [4] vRecur(vrecurr).to_ical().decode() == "FREQ=HOURLY;INTERVAL=4" assert len(vrecurr.keys()) == 2 def test_weekly_tue(self): """Repeat every week on Tuesday.""" vrecurr = utils.build_rrule_from_text("FREQ=WEEKLY;BYDAY=TU") assert vrecurr["FREQ"] == ["WEEKLY"] assert vrecurr["BYDAY"] == ["TU"] vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;BYDAY=TU" assert len(vrecurr.keys()) == 2 def test_weekly_mo_wed(self): """Repeat every week on Monday, Wednesday.""" vrecurr = utils.build_rrule_from_text("FREQ=WEEKLY;BYDAY=MO,WE") assert vrecurr["FREQ"] == ["WEEKLY"] assert vrecurr["BYDAY"] == ["MO", "WE"] vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;BYDAY=MO,WE" assert len(vrecurr.keys()) == 2 def test_every_weekday(self): """Repeat every weekday.""" vrecurr = utils.build_rrule_from_text("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR") assert vrecurr["FREQ"] == ["WEEKLY"] assert vrecurr["BYDAY"] == ["MO", "TU", "WE", "TH", "FR"] vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR" assert len(vrecurr.keys()) == 2 def test_every_2_weeks(self): """Repeat every 2 weeks.""" vrecurr = utils.build_rrule_from_text("INTERVAL=2;FREQ=WEEKLY") assert vrecurr["FREQ"] == ["WEEKLY"] assert vrecurr["INTERVAL"] == [2] vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;INTERVAL=2" assert len(vrecurr.keys()) == 2 def test_every_month(self): """Repeat every month.""" vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY") assert vrecurr["FREQ"] == ["MONTHLY"] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY" assert len(vrecurr.keys()) == 1 def test_every_6_months(self): """Repeat very 6 months.""" vrecurr = utils.build_rrule_from_text("INTERVAL=6;FREQ=MONTHLY") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["INTERVAL"] == [6] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;INTERVAL=6" assert len(vrecurr.keys()) == 2 def test_every_year(self): """Repeat every year.""" vrecurr = utils.build_rrule_from_text("FREQ=YEARLY") assert vrecurr["FREQ"] == ["YEARLY"] vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY" assert len(vrecurr.keys()) == 1 def test_every_month_on_the_4th(self): """Repeat every month on the 4th.""" vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY;BYMONTHDAY=4") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYMONTHDAY"] == [4] assert len(vrecurr.keys()) == 2 vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY;BYMONTHDAY=+4") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYMONTHDAY"] == [4] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYMONTHDAY=4" assert len(vrecurr.keys()) == 2 def test_every_month_on_the_4th_last(self): """Repeat every month on the 4th last.""" vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY;BYMONTHDAY=-4") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYMONTHDAY"] == [-4] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYMONTHDAY=-4" assert len(vrecurr.keys()) == 2 def test_ever_month_3rd_tu(self): """Repeat every month on the 3rd Tuesday.""" vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY;BYDAY=+3TU") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYDAY"] == ["+3TU"] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYDAY=+3TU" assert len(vrecurr.keys()) == 2 def test_ever_month_3rd_last_tu(self): """Repeat every month on the 3rd last Tuesday.""" vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY;BYDAY=-3TU") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYDAY"] == ["-3TU"] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYDAY=-3TU" assert len(vrecurr.keys()) == 2 def test_ever_month_last_mo(self): """Repeat every month on the last Monday.""" vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY;BYDAY=-1MO") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYDAY"] == ["-1MO"] assert len(vrecurr.keys()) == 2 def test_ever_month_second_last_fr(self): """Repeat every month on the 2nd last Friday.""" vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY;BYDAY=-2FR") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYDAY"] == ["-2FR"] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYDAY=-2FR" assert len(vrecurr.keys()) == 2 def test_every_week_until_jan_2007(self): """Repeat every week until January 1, 2007.""" utc = tz.UTC vrecurr = utils.build_rrule_from_text("FREQ=WEEKLY;UNTIL=20070101T000000Z") assert vrecurr["FREQ"] == ["WEEKLY"] assert vrecurr["UNTIL"] == [datetime.datetime(2007, 1, 1, 0, 0, tzinfo=utc)] vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;UNTIL=20070101T000000Z" assert len(vrecurr.keys()) == 2 def test_every_week_20_times(self): """Repeat every week for 20 times.""" vrecurr = utils.build_rrule_from_text("FREQ=WEEKLY;COUNT=20") assert vrecurr["FREQ"] == ["WEEKLY"] assert vrecurr["COUNT"] == [20] vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;COUNT=20" assert len(vrecurr.keys()) == 2 def test_every_month_last_working_day(self): """Repeat the last working day of each month.""" vrecurr = utils.build_rrule_from_text( "FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1;" ) assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYDAY"] == ["MO", "TU", "WE", "TH", "FR"] assert vrecurr["BYSETPOS"] == [-1] vRecur( vrecurr ).to_ical().decode() == "FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1" assert len(vrecurr.keys()) == 3 def test_ever_month_last_day(self): """Repeat the last day of each month.""" vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY;BYMONTHDAY=-1") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYMONTHDAY"] == [-1] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYMONTHDAY=-1" assert len(vrecurr.keys()) == 2 def test_every_day_in_jan(self): """Repeat every day in January""" vrecurr = utils.build_rrule_from_text( "FREQ=YEARLY;BYMONTH=1;BYDAY=MO,TU,WE,TH,FR,SA,SU;" ) assert vrecurr["FREQ"] == ["YEARLY"] assert vrecurr["BYMONTH"] == [1] assert vrecurr["BYDAY"] == ["MO", "TU", "WE", "TH", "FR", "SA", "SU"] vRecur( vrecurr ).to_ical().decode() == "FREQ=YEARLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYMONTH=1" assert len(vrecurr.keys()) == 3 def test_every_2nd_15th_of_month(self): """Repeat monthly on the 2nd and 15th of the month.""" vrecurr = utils.build_rrule_from_text("FREQ=MONTHLY;BYMONTHDAY=4,15") assert vrecurr["FREQ"] == ["MONTHLY"] assert vrecurr["BYMONTHDAY"] == [4, 15] vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYMONTHDAY=4,15" assert len(vrecurr.keys()) == 2 def test_every_fr_13th(self): """Repeat every Friday the 13th.""" vrecurr = utils.build_rrule_from_text("FREQ=YEARLY;BYMONTHDAY=13;BYDAY=FR") assert vrecurr["FREQ"] == ["YEARLY"] assert vrecurr["BYMONTHDAY"] == [13] assert vrecurr["BYDAY"] == ["FR"] vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY;BYDAY=FR;BYMONTHDAY=13" assert len(vrecurr.keys()) == 3 class FromDateutilRruleTests(TestCase): """Build an ical string from a dateutil rrule.""" def test_weekly_by_month_year_day(self): rule = rrule( WEEKLY, bymonth=(1, 7), byyearday=(1, 100, 200, 365), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur( vrecurr ).to_ical().decode() == "FREQ=WEEKLY;BYYEARDAY=1,100,200,365;BYMONTH=1,7" def test_weekly_by_month_nweekday(self): rule = rrule( WEEKLY, count=3, bymonth=(1, 3), byweekday=(TU(1), TH(-1)), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur( vrecurr ).to_ical().decode() == "FREQ=WEEKLY;COUNT=3;BYDAY=TU,TH;BYMONTH=1,3" def test_weekly_by_monthday(self): rule = rrule( WEEKLY, count=3, bymonthday=(1, 3), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;COUNT=3;BYMONTHDAY=1,3" def test_weekly_by_weekday(self): rule = rrule( WEEKLY, count=3, byweekday=(TU, TH), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;COUNT=3;BYDAY=TU,TH" def test_daily_by_month_nweekday(self): rule = rrule( DAILY, count=3, bymonth=(1, 3), byweekday=(TU(1), TH(-1)), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur( vrecurr ).to_ical().decode() == "FREQ=DAILY;COUNT=3;BYDAY=TU,TH;BYMONTH=1,3" def test_yearly_month_nweekday(self): rule = rrule( YEARLY, count=3, bymonth=(1, 3), byweekday=(TU(1), TH(-1)), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur( vrecurr ).to_ical().decode() == "FREQ=YEARLY;COUNT=3;BYDAY=+1TU,-1TH;BYMONTH=1,3" def test_yearly_month_yearday(self): rule = rrule( YEARLY, count=4, bymonth=(4, 7), byyearday=(1, 100, 200, 365), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) assert ( vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY;COUNT=4;BYYEARDAY=1,100,200,365;BYMONTH=4,7" ) def test_yearly_weekno_weekday(self): rule = rrule( YEARLY, count=3, byweekno=1, byweekday=MO, dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY;COUNT=3;BYDAY=MO;BYWEEKNO=1" def test_yearly_setpos(self): rule = rrule( YEARLY, count=3, bymonthday=15, byhour=(6, 18), bysetpos=(3, -3), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) assert ( vRecur(vrecurr).to_ical().decode() == "FREQ=YEARLY;COUNT=3;BYHOUR=6,18;BYMONTHDAY=15;BYSETPOS=3,-3" ) def test_monthly_month_monthday(self): rule = rrule( MONTHLY, count=3, bymonth=(1, 3), bymonthday=(5, 7), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur( vrecurr ).to_ical().decode() == "FREQ=MONTHLY;COUNT=3;BYMONTHDAY=5,7;BYMONTH=1,3" def test_monthly_nweekday(self): rule = rrule( MONTHLY, count=3, byweekday=(TU(1), TH(-1)), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;COUNT=3;BYDAY=+1TU,-1TH" def test_monthly_month_nweekday(self): rule = rrule( MONTHLY, bymonth=(1, 3), byweekday=(TU(1), TH(-1)), dtstart=datetime.datetime(1997, 9, 2, 9, 0), ) vrecurr = utils.build_rrule_from_dateutil_rrule(rule) vRecur(vrecurr).to_ical().decode() == "FREQ=MONTHLY;BYDAY=+1TU,-1TH;BYMONTH=1,3" class FromDjangoRecurrenceRruleTests(TestCase): """Build an ical string from a django-recurrence rrule.""" def test_rule(self): rule = recurrence.Rule(recurrence.WEEKLY) vrecurr = utils.build_rrule_from_recurrences_rrule(rule) vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY" def test_complex_rule_serialization(self): rule = recurrence.Rule( recurrence.WEEKLY, interval=17, wkst=1, count=7, byday=[recurrence.to_weekday("-1MO"), recurrence.to_weekday("TU")], bymonth=[1, 3], ) vrecurr = utils.build_rrule_from_recurrences_rrule(rule) assert ( vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;COUNT=7;INTERVAL=17;BYDAY=-1MO,TU;BYMONTH=1,3;WKST=TU" ) def test_complex_rule_serialization_with_weekday_instance(self): rule = recurrence.Rule( recurrence.WEEKLY, interval=17, wkst=recurrence.to_weekday(1), count=7, byday=[recurrence.to_weekday("-1MO"), recurrence.to_weekday("TU")], bymonth=[1, 3], ) vrecurr = utils.build_rrule_from_recurrences_rrule(rule) assert ( vRecur(vrecurr).to_ical().decode() == "FREQ=WEEKLY;COUNT=7;INTERVAL=17;BYDAY=-1MO,TU;BYMONTH=1,3;WKST=TU" ) django-ical-1.9.2/django_ical/utils.py000066400000000000000000000060371444163353200176520ustar00rootroot00000000000000"""Utility functions to build calendar rules.""" from icalendar.prop import vRecur from recurrence import serialize def build_rrule( # noqa count=None, interval=None, bysecond=None, byminute=None, byhour=None, byweekno=None, bymonthday=None, byyearday=None, bymonth=None, until=None, bysetpos=None, wkst=None, byday=None, freq=None, ): """ Build rrule dictionary for vRecur class. :param count: int :param interval: int :param bysecond: int :param byminute: int :param byhour: int :param byweekno: int :param bymonthday: int :param byyearday: int :param bymonth: int :param until: datetime :param bysetpos: int :param wkst: str, two-letter weekday :param byday: weekday :param freq: str, frequency name ('WEEK', 'MONTH', etc) :return: dict """ result = {} if count is not None: result["COUNT"] = count if interval is not None: result["INTERVAL"] = interval if bysecond is not None: result["BYSECOND"] = bysecond if byminute is not None: result["BYMINUTE"] = byminute if byhour is not None: result["BYHOUR"] = byhour if byweekno is not None: result["BYWEEKNO"] = byweekno if bymonthday is not None: result["BYMONTHDAY"] = bymonthday if byyearday is not None: result["BYYEARDAY"] = byyearday if bymonth is not None: result["BYMONTH"] = bymonth if until is not None: result["UNTIL"] = until if bysetpos is not None: result["BYSETPOS"] = bysetpos if wkst is not None: result["WKST"] = wkst if byday is not None: result["BYDAY"] = byday if freq is not None: if freq not in vRecur.frequencies: raise ValueError(f"Frequency value should be one of: {vRecur.frequencies}") result["FREQ"] = freq return result def build_rrule_from_text(rrule_str): """Build an rrule from a serialzed RRULE string.""" recurr = vRecur() return recurr.from_ical(rrule_str) def build_rrule_from_recurrences_rrule(rule): """ Build rrule dictionary for vRecur class from a django_recurrences rrule. django_recurrences is a popular implementation for recurrences in django. https://pypi.org/project/django-recurrence/ this is a shortcut to interface between recurrences and icalendar. """ line = serialize(rule) if line.startswith("RRULE:"): line = line[6:] return build_rrule_from_text(line) def build_rrule_from_dateutil_rrule(rule): """ Build rrule dictionary for vRecur class from a dateutil rrule. Dateutils rrule is a popular implementation of rrule in python. https://pypi.org/project/python-dateutil/ this is a shortcut to interface between dateutil and icalendar. """ lines = str(rule).splitlines() for line in lines: if line.startswith("DTSTART:"): continue if line.startswith("RRULE:"): line = line[6:] return build_rrule_from_text(line) django-ical-1.9.2/django_ical/views.py000066400000000000000000000104311444163353200176400ustar00rootroot00000000000000""" Views for generating ical feeds. """ from datetime import datetime from calendar import timegm from inspect import signature from django.http import HttpResponse, Http404 from django.core.exceptions import ObjectDoesNotExist from django.contrib.syndication.views import Feed from django.utils.http import http_date from django_ical import feedgenerator __all__ = ("ICalFeed",) # Extra fields added to the Feed object # to support ical FEED_EXTRA_FIELDS = ("method", "product_id", "timezone") # Extra fields added to items (events) to # support ical ICAL_EXTRA_FIELDS = [ "component_type", # type of calendar component (event, todo) "timestamp", # dtstamp "created", # created "start_datetime", # dtstart "end_datetime", # dtend "transparency", # transp "location", # location "geolocation", # latitude;longitude "organizer", # email, cn, and role "rrule", # rrule "exrule", # exrule "rdate", # rdate "exdate", # exdate "status", # CONFIRMED|TENTATIVE|CANCELLED "attendee", # list of attendees "valarm", # list of icalendar.Alarm objects, # additional fields for tasks "completed", # completed "percent_complete", # percent-complete "priority", # priority "due", # due ] class ICalFeed(Feed): """ iCalendar Feed Existing Django syndication feeds :title: X-WR-CALNAME :description: X-WR-CALDESC :item_guid: UID :item_title: SUMMARY :item_description: DESCRIPTION :item_link: URL :item_updateddate: LAST-MODIFIED Extension fields :method: METHOD :timezone: X-WR-TIMEZONE :item_class: CLASS :item_timestamp: DTSTAMP :item_created: CREATED :item_start_datetime: DTSTART :item_end_datetime: DTEND :item_transparency: TRANSP :item_attendee: ATTENDEE :item_valarm: VALARM """ feed_type = feedgenerator.DefaultFeed def __call__(self, request, *args, **kwargs): """ Copied from django.contrib.syndication.views.Feed Supports file_name as a dynamic attr. """ try: obj = self.get_object(request, *args, **kwargs) except ObjectDoesNotExist as exc: raise Http404("Feed object does not exist.") from exc feedgen = self.get_feed(obj, request) response = HttpResponse(content_type=feedgen.mime_type) if hasattr(self, "item_pubdate") or hasattr(self, "item_updateddate"): # if item_pubdate or item_updateddate is defined for the feed, set # header so as ConditionalGetMiddleware is able to send 304 NOT MODIFIED response["Last-Modified"] = http_date( timegm(feedgen.latest_post_date().utctimetuple()) ) feedgen.write(response, "utf-8") filename = self._get_dynamic_attr("file_name", obj) if filename: response["Content-Disposition"] = f'attachment; filename="{filename}"' return response def _get_dynamic_attr(self, attname, obj, default=None): """ Copied from django.contrib.syndication.views.Feed (v1.7.1) """ try: attr = getattr(self, attname) except AttributeError: return default if callable(attr): num_args = len(signature(attr).parameters) if num_args == 0: return attr() if num_args == 1: return attr(obj) raise TypeError( "Number of arguments to _get_dynamic_attr needs to be 0 or 1" ) return attr # NOTE: Not used by icalendar but required # by the Django syndication framework. link = "" def method(self, obj): # pylint: disable=unused-argument return "PUBLISH" def feed_extra_kwargs(self, obj): kwargs = {} for field in FEED_EXTRA_FIELDS: val = self._get_dynamic_attr(field, obj) if val: kwargs[field] = val return kwargs def item_timestamp(self, obj): # pylint: disable=unused-argument return datetime.now() def item_extra_kwargs(self, item): kwargs = {} for field in ICAL_EXTRA_FIELDS: val = self._get_dynamic_attr("item_" + field, item) if val: kwargs[field] = val return kwargs django-ical-1.9.2/docs/000077500000000000000000000000001444163353200146305ustar00rootroot00000000000000django-ical-1.9.2/docs/Makefile000066400000000000000000000127311444163353200162740ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-ical.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-ical.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/django-ical" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/django-ical" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." django-ical-1.9.2/docs/make.bat000066400000000000000000000117731444163353200162460ustar00rootroot00000000000000@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source set I18NSPHINXOPTS=%SPHINXOPTS% source if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\django-ical.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\django-ical.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end django-ical-1.9.2/docs/source/000077500000000000000000000000001444163353200161305ustar00rootroot00000000000000django-ical-1.9.2/docs/source/changes.rst000066400000000000000000000000371444163353200202720ustar00rootroot00000000000000.. include:: ../../CHANGES.rst django-ical-1.9.2/docs/source/conf.py000066400000000000000000000177711444163353200174440ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # django-ical documentation build configuration file, created by # sphinx-quickstart on Sun May 6 14:57:42 2012. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os from pkg_resources import get_distribution # So that we can import django for the API reference. os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django.conf.global_settings") sys.path.append(os.path.abspath(".")) sys.path.append(os.path.abspath("../../")) # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ["sphinx.ext.autodoc"] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # The suffix of source filenames. source_suffix = ".rst" # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = "index" # General information about the project. project = "django-ical" copyright = "2012, Ian Lewis" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The full version, including alpha/beta/rc tags. release = get_distribution("django_ical").version # The short X.Y version. version = ".".join(release.split(".")[:2]) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # today = '' # Else, today_fmt is used as the format for a strftime call. # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all documents. # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = "haiku" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. # html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. # html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. # html_additional_pages = {} # If false, no module index is generated. # html_domain_indices = True # If false, no index is generated. # html_use_index = True # If true, the index is split into individual pages for each letter. # html_split_index = False # If true, links to the reST sources are added to the pages. # html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = "django-icaldoc" # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ("index", "django-ical.tex", "django-ical Documentation", "Ian Lewis", "manual") ] # The name of an image file (relative to this directory) to place at the top of # the title page. # latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. # latex_use_parts = False # If true, show page references after internal links. # latex_show_pagerefs = False # If true, show URL addresses after external links. # latex_show_urls = False # Documents to append as an appendix to all manuals. # latex_appendices = [] # If false, no module index is generated. # latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [("index", "django-ical", "django-ical Documentation", ["Ian Lewis"], 1)] # If true, show URL addresses after external links. # man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ( "index", "django-ical", "django-ical Documentation", "Ian Lewis", "django-ical", "One line description of project.", "Miscellaneous", ) ] # Documents to append as an appendix to all manuals. # texinfo_appendices = [] # If false, no module index is generated. # texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. # texinfo_show_urls = 'footnote' django-ical-1.9.2/docs/source/django_ical.feedgenerator000066400000000000000000000003401444163353200231130ustar00rootroot00000000000000======================================== django_ical.feedgenerator ======================================== .. contents:: :local: .. currentmodule:: django_ical.feedgenerator .. automodule:: django_ical.feedgenerator django-ical-1.9.2/docs/source/index.rst000066400000000000000000000022361444163353200177740ustar00rootroot00000000000000.. django-ical documentation master file, created by sphinx-quickstart on Sun May 6 14:57:42 2012. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. django-ical documentation ========================= django-ical is a simple library/framework for creating `ical `_ feeds based in Django's `syndication feed framework `_. This documentation is modeled after the documentation for the syndication feed framework so you can think of it as a simple extension. If you are familiar with the Django syndication feed framework you should be able to be able to use django-ical fairly quickly. It works the same way as the Django syndication framework but adds a few extension properties to support iCalendar feeds. django-ical uses the `icalendar `_ library under the hood to generate iCalendar feeds. Contents ======== .. toctree:: usage reference/index changelog Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` django-ical-1.9.2/docs/source/reference/000077500000000000000000000000001444163353200200665ustar00rootroot00000000000000django-ical-1.9.2/docs/source/reference/django_ical.feedgenerator.rst000066400000000000000000000003561444163353200256670ustar00rootroot00000000000000======================================== django_ical.feedgenerator ======================================== .. contents:: :local: .. currentmodule:: django_ical.feedgenerator .. automodule:: django_ical.feedgenerator :members: django-ical-1.9.2/docs/source/reference/django_ical.utils.rst000066400000000000000000000003261444163353200242120ustar00rootroot00000000000000======================================== django_ical.utils ======================================== .. contents:: :local: .. currentmodule:: django_ical.utils .. automodule:: django_ical.utils :members: django-ical-1.9.2/docs/source/reference/django_ical.views.rst000066400000000000000000000003261444163353200242070ustar00rootroot00000000000000======================================== django_ical.views ======================================== .. contents:: :local: .. currentmodule:: django_ical.views .. automodule:: django_ical.views :members: django-ical-1.9.2/docs/source/reference/index.rst000066400000000000000000000002751444163353200217330ustar00rootroot00000000000000=============== API Reference =============== :Release: |version| :Date: |today| .. toctree:: :maxdepth: 1 django_ical.feedgenerator django_ical.views django_ical.utils django-ical-1.9.2/docs/source/usage.rst000066400000000000000000000546241444163353200200010ustar00rootroot00000000000000The high-level framework ======================== Overview -------- The high level iCal feed-generating is supplied by the :class:`ICalFeed ` class. To create a feed, write a :class:`ICalFeed ` class and point to an instance of it in your `URLconf `_. With RSS feeds, the items in the feed represent articles or simple web pages. The :class:`ICalFeed ` class represents an iCalendar calendar. Calendars contain items which are events. Example ------- Let's look at a simple example. Here the item_start_datetime is a django-ical extension that supplies the start time of the event. .. code-block:: python from django_ical.views import ICalFeed from examplecom.models import Event class EventFeed(ICalFeed): """ A simple event calender """ product_id = '-//example.com//Example//EN' timezone = 'UTC' file_name = "event.ics" def items(self): return Event.objects.all().order_by('-start_datetime') def item_title(self, item): return item.title def item_description(self, item): return item.description def item_start_datetime(self, item): return item.start_datetime To connect a URL to this calendar, put an instance of the EventFeed object in your URLconf. For example: .. code-block:: python from django.conf.urls import patterns, url, include from myproject.feeds import EventFeed urlpatterns = patterns('', # ... (r'^latest/feed.ics$', EventFeed()), # ... ) Example how recurrences are built using the django-recurrence_ package: .. code-block:: python from django_ical.utils import build_rrule_from_recurrences_rrule from django_ical.views import ICalFeed from examplecom.models import Event class EventFeed(ICalFeed): """ A simple event calender """ # ... def item_rrule(self, item): """Adapt Event recurrence to Feed Entry rrule.""" if item.recurrences: rules = [] for rule in item.recurrences.rrules: rules.append(build_rrule_from_recurrences_rrule(rule)) return rules def item_exrule(self, item): """Adapt Event recurrence to Feed Entry exrule.""" if item.recurrences: rules = [] for rule in item.recurrences.exrules: rules.append(build_rrule_from_recurrences_rrule(rule)) return rules def item_rdate(self, item): """Adapt Event recurrence to Feed Entry rdate.""" if item.recurrences: return item.recurrences.rdates def item_exdate(self, item): """Adapt Event recurrence to Feed Entry exdate.""" if item.recurrences: return item.recurrences.exdates Note that in ``django_ical.utils`` are also convienience methods to build ``rrules`` from scratch, from string (serialized iCal) and ``dateutil.rrule``. File Downloads -------------- The `file_name` parameter is an optional used as base name when generating the file. By default django-ical will not set the Content-Disposition header of the response. By setting the file_name parameter you can cause django_ical to set the Content-Disposition header and set the file name. In the example below, it will be called "event.ics". .. code-block:: python class EventFeed(ICalFeed): """ A simple event calender """ product_id = '-//example.com//Example//EN' timezone = 'UTC' file_name = "event.ics" # ... The `file_name` parameter can be a method like other properties. Here we can set the file name to include the id of the object returned by `get_object()`. .. code-block:: python class EventFeed(ICalFeed): """ A simple event calender """ product_id = '-//example.com//Example//EN' timezone = 'UTC' def file_name(self, obj): return "feed_%s.ics" % obj.id # ... Alarms ------ Alarms must be `icalendar.Alarm` objects, a list is expected as the return value for `item_valarm`. .. code-block:: python from icalendar import Alarm from datetime import timedelta def item_valarm(self, item): valarm = Alarm() valarm.add('action', 'display') valarm.add('description', 'Your message text') valarm.add('trigger', timedelta(days=-1)) return [valarm] Tasks (Todos) ------------- It is also possible to generate representations of tasks (or deadlines, todos) which are represented in iCal with the dedicated `VTODO` component instead of the usual `VEVENT`. To do so, you can use a specific method to determine which type of component a given item should be translated as: .. code-block:: python from django_ical.views import ICalFeed from examplecom.models import Deadline class EventFeed(ICalFeed): """ A simple event calender with tasks """ product_id = '-//example.com//Example//EN' timezone = 'UTC' file_name = "event.ics" def items(self): return Deadline.objects.all().order_by('-due_datetime') def item_component_type(self): return 'todo' # could also be 'event', which is the default def item_title(self, item): return item.title def item_description(self, item): return item.description def item_due_datetime(self, item): return item.due_datetime Property Reference and Extensions --------------------------------- django-ical adds a number of extensions to the base syndication framework in order to support iCalendar feeds and ignores many fields used in RSS feeds. Here is a table of all of the fields that django-ical supports. +-----------------------+-----------------------+-----------------------------+ | Property name | iCalendar field name | Description | +=======================+=======================+=============================+ | product_id | `PRODID`_ | The calendar product ID | +-----------------------+-----------------------+-----------------------------+ | timezone | `X-WR-TIMEZONE`_ | The calendar timezone | +-----------------------+-----------------------+-----------------------------+ | title | `X-WR-CALNAME`_ | The calendar name/title | +-----------------------+-----------------------+-----------------------------+ | description | `X-WR-CALDESC`_ | The calendar description | +-----------------------+-----------------------+-----------------------------+ | method | `METHOD`_ | The calendar method such as | | | | meeting requests. | +-----------------------+-----------------------+-----------------------------+ | item_guid | `UID`_ | The event's unique id. | | | | This id should be | | | | *globally* unique so you | | | | should add an | | | | @ to your id. | +-----------------------+-----------------------+-----------------------------+ | item_title | `SUMMARY`_ | The event name/title | +-----------------------+-----------------------+-----------------------------+ | item_description | `DESCRIPTION`_ | The event description | +-----------------------+-----------------------+-----------------------------+ | item_link | `URL`_ | The event url | +-----------------------+-----------------------+-----------------------------+ | item_class | `CLASS`_ | The event class | | | | (e.g. PUBLIC, PRIVATE, | | | | CONFIDENTIAL) | +-----------------------+-----------------------+-----------------------------+ | item_created | `CREATED`_ | The event create time | +-----------------------+-----------------------+-----------------------------+ | item_updateddate | `LAST-MODIFIED`_ | The event modified time | +-----------------------+-----------------------+-----------------------------+ | item_start_datetime | `DTSTART`_ | The event start time | +-----------------------+-----------------------+-----------------------------+ | item_end_datetime | `DTEND`_ | The event end time | +-----------------------+-----------------------+-----------------------------+ | item_location | `LOCATION`_ | The event location | +-----------------------+-----------------------+-----------------------------+ | item_geolocation | `GEO`_ | The latitude and longitude | | | | of the event. The value | | | | returned by this property | | | | should be a two-tuple | | | | containing the latitude and | | | | longitude as float values. | | | | semicolon. Ex: | | | | *(37.386013, -122.082932)* | +-----------------------+-----------------------+-----------------------------+ | item_transparency | `TRANSP`_ | The event transparency. | | | | Defines whether the event | | | | shows up in busy searches. | | | | (e.g. OPAQUE, TRANSPARENT) | +-----------------------+-----------------------+-----------------------------+ | item_organizer | `ORGANIZER`_ | The event organizer. | | | | Expected to be a | | | | vCalAddress object. See | | | | `iCalendar`_ documentation | | | | or tests to know how to | | | | build them. | +-----------------------+-----------------------+-----------------------------+ | item_attendee | `ATTENDEE`_ | The event attendees. | | | | Expected to be a list of | | | | vCalAddress objects. See | | | | `iCalendar`_ documentation | | | | or tests to know how to | | | | build them. | +-----------------------+-----------------------+-----------------------------+ | item_rrule | `RRULE`_ | The recurrence rule for | | | | repeating events. | | | | See `iCalendar`_ | | | | documentation or tests to | | | | know how to build them. | +-----------------------+-----------------------+-----------------------------+ | item_rdate | `RDATE`_ | The recurring dates/times | | | | for a repeating event. | | | | See `iCalendar`_ | | | | documentation or tests to | | | | know how to build them. | +-----------------------+-----------------------+-----------------------------+ | item_exdate | `EXDATE`_ | The dates/times for | | | | exceptions of a recurring | | | | event. | | | | See `iCalendar`_ | | | | documentation or tests to | | | | know how to build them. | +-----------------------+-----------------------+-----------------------------+ | item_valarm | `VALARM`_ | Alarms for the event, must | | | | be a list of Alarm objects. | | | | See `iCalendar`_ | | | | documentation or tests to | | | | know how to build them. | +-----------------------+-----------------------+-----------------------------+ | item_status | `STATUS`_ | The status of an event. | | | | Can be CONFIRMED, CANCELLED | | | | or TENTATIVE. | +-----------------------+-----------------------+-----------------------------+ | item_completed | `COMPLETED`_ | The date a task was | | | | completed. | +-----------------------+-----------------------+-----------------------------+ | item_percent_complete | `PERCENT-COMPLETE`_ | A number from 0 to 100 | | | | indication the completion | | | | of the task. | +-----------------------+-----------------------+-----------------------------+ | item_priority | `PRIORITY`_ | An integer from 0 to 9. | | | | 0 means undefined. | | | | 1 means highest priority. | +-----------------------+-----------------------+-----------------------------+ | item_due | `DUE`_ | The date a task is due. | +-----------------------+-----------------------+-----------------------------+ | item_categories | `CATEGORIES`_ | A list of strings, each | | | | being a category of the | | | | task. | +-----------------------+-----------------------+-----------------------------+ | calscale | `CALSCALE`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | method | `METHOD`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | prodid | `PRODID`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | version | `VERSION`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | attach | `ATTACH`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | class | `CLASS`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | comment | `COMMENT`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | resources | `RESOURCES`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | duration | `DURATION`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | freebusy | `FREEBUSY`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | tzid | `TZID`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | tzname | `TZNAME`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | tzoffsetfrom | `TZOFFSETFROM`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | tzoffsetto | `TZOFFSETTO`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | tzurl | `TZURL`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | contact | `CONTACT`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | recurrence_id | `RECURRENCE_ID`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | related_to | `RELATED_TO`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | action | `ACTION`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | repeat | `REPEAT`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | trigger | `TRIGGER`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | sequence | `SEQUENCE`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ | request_status | `REQUEST_STATUS`_ | Not yet documented. | +-----------------------+-----------------------+-----------------------------+ .. note:: django-ical does not use the ``link`` property required by the Django syndication framework. The low-level framework ======================== Behind the scenes, the high-level iCalendar framework uses a lower-level framework for generating feeds' ical data. This framework lives in a single module: :mod:`django_ical.feedgenerator`. You use this framework on your own, for lower-level feed generation. You can also create custom feed generator subclasses for use with the feed_type option. See: `The syndication feed framework: Specifying the type of feed `_ .. _PRODID: http://www.kanzaki.com/docs/ical/prodid.html .. _METHOD: http://www.kanzaki.com/docs/ical/method.html .. _SUMMARY: http://www.kanzaki.com/docs/ical/summary.html .. _DESCRIPTION: http://www.kanzaki.com/docs/ical/description.html .. _UID: http://www.kanzaki.com/docs/ical/uid.html .. _CLASS: http://www.kanzaki.com/docs/ical/class.html .. _CREATED: http://www.kanzaki.com/docs/ical/created.html .. _LAST-MODIFIED: http://www.kanzaki.com/docs/ical/lastModified.html .. _DTSTART: http://www.kanzaki.com/docs/ical/dtstart.html .. _DTEND: http://www.kanzaki.com/docs/ical/dtend.html .. _GEO: http://www.kanzaki.com/docs/ical/geo.html .. _LOCATION: http://www.kanzaki.com/docs/ical/location.html .. _TRANSP: http://www.kanzaki.com/docs/ical/transp.html .. _URL: http://www.kanzaki.com/docs/ical/url.html .. _ORGANIZER: http://www.kanzaki.com/docs/ical/organizer.html .. _ATTENDEE: https://www.kanzaki.com/docs/ical/attendee.html .. _RRULE: https://www.kanzaki.com/docs/ical/rrule.html .. _EXRULE: https://www.kanzaki.com/docs/ical/exrule.html .. _RDATE: https://www.kanzaki.com/docs/ical/rdate.html .. _EXDATE: https://www.kanzaki.com/docs/ical/exdate.html .. _STATUS: https://www.kanzaki.com/docs/ical/status.html .. _VALARM: https://www.kanzaki.com/docs/ical/valarm.html .. _COMPLETED: https://www.kanzaki.com/docs/ical/completed.html .. _PERCENT-COMPLETE: https://www.kanzaki.com/docs/ical/percentComplete.html .. _PRIORITY: https://www.kanzaki.com/docs/ical/priority.html .. _DUE: https://www.kanzaki.com/docs/ical/due.html .. _CALSCALE: https://www.kanzaki.com/docs/ical/calscale.html .. _METHOD: https://www.kanzaki.com/docs/ical/method.html .. _PRODID: https://www.kanzaki.com/docs/ical/prodid.html .. _VERSION: https://www.kanzaki.com/docs/ical/version.html .. _ATTACH: https://www.kanzaki.com/docs/ical/attach.html .. _CLASS: https://www.kanzaki.com/docs/ical/class.html .. _COMMENT: https://www.kanzaki.com/docs/ical/comment.html .. _RESOURCES: https://www.kanzaki.com/docs/ical/resources.html .. _DURATION: https://www.kanzaki.com/docs/ical/duration.html .. _FREEBUSY: https://www.kanzaki.com/docs/ical/freebusy.html .. _TZID: https://www.kanzaki.com/docs/ical/tzid.html .. _TZNAME: https://www.kanzaki.com/docs/ical/tzname.html .. _TZOFFSETFROM: https://www.kanzaki.com/docs/ical/tzoffsetfrom.html .. _TZOFFSETTO: https://www.kanzaki.com/docs/ical/tzoffsetto.html .. _TZURL: https://www.kanzaki.com/docs/ical/tzurl.html .. _CONTACT: https://www.kanzaki.com/docs/ical/contact.html .. _RECURRENCE-ID: https://www.kanzaki.com/docs/ical/recurrenceId.html .. _RELATED-TO: https://www.kanzaki.com/docs/ical/relatedTo.html .. _ACTION: https://www.kanzaki.com/docs/ical/action.html .. _REPEAT: https://www.kanzaki.com/docs/ical/repeat.html .. _TRIGGER: https://www.kanzaki.com/docs/ical/trigger.html .. _SEQUENCE: https://www.kanzaki.com/docs/ical/sequence.html .. _REQUEST-STATUS: https://icalendar.org/iCalendar-RFC-5545/3-8-8-3-request-status.html .. _X-WR-CALNAME: http://en.wikipedia.org/wiki/ICalendar#Calendar_extensions .. _X-WR-CALDESC: http://en.wikipedia.org/wiki/ICalendar#Calendar_extensions .. _X-WR-TIMEZONE: http://en.wikipedia.org/wiki/ICalendar#Calendar_extensions .. _iCalendar: http://icalendar.readthedocs.org/en/latest/index.html .. _CATEGORIES: https://www.kanzaki.com/docs/ical/categories.html .. _django-recurrence: https://github.com/django-recurrence/django-recurrence django-ical-1.9.2/pyproject.toml000066400000000000000000000002051444163353200166110ustar00rootroot00000000000000[build-system] requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"] [tool.black] line-length = 88 target_version = ['py38'] django-ical-1.9.2/setup.py000066400000000000000000000034541444163353200154200ustar00rootroot00000000000000#!/usr/bin/env python from setuptools import setup, find_packages setup( name="django-ical", description="iCal feeds for Django based on Django's syndication feed framework.", long_description="\n".join( [ open("README.rst", encoding="utf-8").read(), open("CHANGES.rst", encoding="utf-8").read(), ] ), keywords="ical calendar django syndication feed", author="Ian Lewis", author_email="security@jazzband.com", maintainer="Jazzband", maintainer_email="security@jazzband.com", license="MIT License", url="https://github.com/jazzband/django-ical", classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Environment :: Plugins", "Framework :: Django", "Framework :: Django :: 3.2", "Framework :: Django :: 4.0", "Framework :: Django :: 4.1", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules", ], install_requires=["django>=3.2", "icalendar>=4.0.3", "django-recurrence>=1.11.1"], packages=find_packages(), test_suite="tests.main", use_scm_version=True, setup_requires=["setuptools_scm"], ) django-ical-1.9.2/test_settings.py000066400000000000000000000005301444163353200171470ustar00rootroot00000000000000TIME_ZONE="UTC" SECRET_KEY="snakeoil" DATABASES={ "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:", } } INSTALLED_APPS=[ "django.contrib.contenttypes", "django_ical", ] MIDDLEWARE_CLASSES=[ "django.middleware.common.CommonMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", ] django-ical-1.9.2/tests.py000066400000000000000000000012271444163353200154160ustar00rootroot00000000000000import os import sys def main(): """ Standalone Django model test with a 'memory-only-django-installation'. You can play with a django model without a complete django app installation. http://www.djangosnippets.org/snippets/1044/ """ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_settings") print(os.environ) import django from django.conf import settings django.setup() from django.test.utils import get_runner TestRunner = get_runner(settings) test_runner = TestRunner() failures = test_runner.run_tests(["django_ical"]) sys.exit(bool(failures)) if __name__ == "__main__": main() django-ical-1.9.2/tox.ini000066400000000000000000000016111444163353200152120ustar00rootroot00000000000000[tox] envlist = py310-djqa py{38,39,310,py38}-dj32 py{38,39,310,py38}-dj40 py{38,39,310,311,py38}-dj41 py{310}-djmain [gh-actions] python = 3.8: py38 3.9: py39 3.10: py310 3.11: py310 pypy-3.8: pypy38 [gh-actions:env] DJANGO = 3.2: dj32 4.0: dj40 4.1: dj41 main: djmain qa: djqa [testenv] usedevelop = true setenv = PYTHONDONTWRITEBYTECODE=1 deps = coverage==5.3 dj32: django>=3.1,<3.2 dj40: django>=4.0,<4.1 dj41: django>=4.1,<4.2 djmain: https://github.com/django/django/archive/main.tar.gz commands = coverage run setup.py test coverage report -m [testenv:py38-djqa] basepython = python3.8 ignore_errors = true skip_install = true setenv= DJANGO_SETTINGS_MODULE=test_settings deps = django==3.2 black==23.3.0 prospector==1.9.0 commands = prospector black --check --diff django_ical