跳转到主要内容

Django应用程序,用于启用将事件导出为iCalendar文件。

项目描述

django-cal

Django应用程序,用于启用将事件导出为iCalendar文件。模仿了django.contrib.syndication的行为,并基于vobject。灵感主要来自Christian JoergensenDerek Willis

该项目维护不严格,欢迎贡献,但没有计划进行新功能开发。欢迎新的维护者。

django-cal需要至少Django 3.2和Python 3.8。

文档

概述

请参阅Django的聚合订阅框架文档,django_cal模仿其行为:[Django聚合订阅框架文档](https://docs.django.ac.cn/en/dev/ref/contrib/syndication/)

安装

pip install django-cal

设置

定义一个自定义事件类,然后在您的urls.py中直接将其连接。

    from testapp.events import Testevents

    urlpatterns = patterns(
    "",
    (r"^ical$", Testevents()),
    )

定义事件属性

以下参数的工作方式类似于它们在django.contrib.syndication中的实现。这意味着,框架按以下顺序检查:`self.$param(obj)`、`self.$param()`、`self.$param`;`obj`是`self.get_object`返回的对象。

items           Returns the list of events.
                Must be set.
filename        Filename of the file returned in the view.
                Optional, defaults to 'events.ics'.
cal_name        Name of the calendar.
                Optional, defaults to None.
cal_desc        Description of the calendar.
                Optional, defaults to None.

item_summary    The "title" of the item.
                Optional, defaults to unicode representation of item.

item_end        Duration or end time of item.
item_duration   Optional, defaults to None. Must not define both.

item_rruleset   Optional, defaults to None.
                Should return dateutil.rruleset instance
                for recurrent events.

item_url        Optional, default calls item.get_absolute_url()
                Should return a URL with the fully-qualified domain and
                protocol (e.g. 'http://www.example.com/blog/') or an
                absolute path (e.g. '/events/'). If only a path is
                present, the 'django.contrib.sites' app will be used
                to insert the domain of the current site.
                Note: To find the current site, 'django.contrib.sites'
                      must be in your settings.INSTALLED_APPS (it is
                      there by default)

item_uid        All correspond to their vEvent equivalents.
item_start      All optional, all default to None.
item_description
item_categories
item_comment
item_location
item_last_modified
item_created

事件持续时间

django-cal 模仿 vobject 的行为,关于事件的开始和结束。简而言之:使用 Date 对象处理全天事件,DateTime 对象进行更细致的控制。定义持续时间或结束时间,不要同时定义两者。

时区

如果您需要时区支持,请使用 pytz.timezoneitem_startitem_end 创建一个“感知”的 datetime 对象并将其设置为 UTC。一位用户报告说,Gmail、Outlook、Apple Mail 等,在收到后都会正确显示在用户的本地时区。

示例:

from pytz import timezone

# dt is a naive datetime object known to represent US/Eastern time
loc_dt = timezone('US/Eastern').localize(dt)
utc = timezone('UTC')
aware_datetime = loc_dt.astimezone(utc)

复杂行为

self.get_object 可以被覆盖以允许更复杂的事件,就像 syndication feeds 一样。

贡献者备注

设置开发环境

在虚拟环境中

$ pip install .[tests]
$ pre-commit install

上传新版本

上传新 wheel 使用 hatchlingtwine 完成

首先,更新 pyproject.toml 中的版本号。

$ bumpver update --patch
$ python3 -m pip install --upgrade build twine
$ rm dist/* && python3 -m build
$ python3 -m twine upload dist/*
$ git push --tags

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪一个,请了解更多关于 安装包 的信息。

源代码分布

django_cal-0.4.2.tar.gz (7.6 kB 查看散列)

上传时间: 源代码

构建分布

django_cal-0.4.2-py3-none-any.whl (7.1 kB 查看散列)

上传时间: Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面