Django应用程序,用于启用将事件导出为iCalendar文件。
项目描述
django-cal
Django应用程序,用于启用将事件导出为iCalendar文件。模仿了django.contrib.syndication的行为,并基于vobject。灵感主要来自Christian Joergensen和Derek 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.timezone
为 item_start
和 item_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 使用 hatchling
和 twine
完成
首先,更新 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 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 07f00f351d62572ef933d70d11d9329907eb55032f9bd6f336d30f3f4d41e38c |
|
MD5 | 6c8705fbc094504f75591bc2cd99275a |
|
BLAKE2b-256 | a44577f9d6f51d91e35509c18eeb6e10776d19093c189540602060857f47f268 |
django_cal-0.4.2-py3-none-any.whl 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | fb77ae1fe4f96daa4e1c3fa4705b1121cb6c31c87351366ef8f66b43fc1ef008 |
|
MD5 | 73e2854e1d1cac902f211e0d3f303193 |
|
BLAKE2b-256 | aab7fb9cbd7a078920bd689f8d3d2e61f45b0861e06c1682fb6b1df37f77c3cd |