-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add event parameter instead of Delete (Nextcloud workaround) #3
Comments
From what I get from the (sparse) caldav documentation, it could be something like |
Hello, CalCleaner is a graphical software that provides no way to do automation (a.k.a. scripting). I do not think it is a good base if you want to run automated updates of your calendars (cron, etc.). Here is the first PoC I made to cleanup calendars: #!/usr/bin/env python3
from datetime import datetime, timedelta
from caldav import DAVClient
# Informations de connexion au serveur de calendriers.
CALDAV_URL = "http://localhost:8080/remote.php/dav"
CALDAV_USER = "admin"
CALDAV_PASSWORD = "password"
# Date au-delà de laquelle les événements sont considérés comme trop vieux
# Ici il s'agit des événements qui ont plus de 4 mois (aujourd'hui moins 16
# semaines)
DATE_OLD = datetime.now() - timedelta(weeks=16)
# On ouvre la connexion avec le serveur
with DAVClient(CALDAV_URL, username=CALDAV_USER, password=CALDAV_PASSWORD) as dav_client:
# On récupère le principal (objet « racine » du serveur)
dav_principal = dav_client.principal()
# On récupère tous les calendriers accessibles
calendars = dav_principal.calendars()
# On prend les calendriers un par un
for calendar in calendars:
# On affiche le nom du calendrier et le nombre total d'événements qu'il
# contient
print("Calendar: %s" % calendar.name)
print(" Events: %i" % len(calendar.events()))
# On récupère les vieux événements.
# Comme il faut fournir un intervalle on récupère ceux entre le premier
# janvier 1900 et la date calculée plus haut
old_events = calendar.date_search(
start=datetime(1900, 1, 1),
end=DATE_OLD,
expand=True,
)
# On en profite pour afficher le nombre de vieux événements qui seront
# supprimés
print(" Old events: %i" % len(old_events))
# On supprime tous les vieux événements, un par un
for old_event in old_events:
old_event.delete() Sorry for the French comments, it came from my blog post about CalCleaner: This script is probably easier to adapt to your needs and can be run using cron :) |
I close this issue as it seems it is no more needed :) |
Indeed, I went the script way. Thanks for your reply and advices! |
Hi Flozz,
Thanks for this amazing and useful work! I have a need due to Nextcloud limitation in calendar management, and I think this project could be a very (very) good starting point.
User need and Nextcloud limitation
I want to share a calendar of upcoming events (appointments) to a client, without revealing personal data contained in appointment's details.
But Nextcloud calendars cannot be shared with availability only. The efforts of the dev team now is to look into "Free/busy" options but at user's level, not calendar's.
The only option to fullfil the user need is : calendar full share via link (with details), then hide details on a per-event basis (setting in UI : if shared, show full / show as busy only / do not show).
Proposed workaround
To make the option practically viable (ergo not adding a manual step at every appointment's confirmation), I think we could have an automated run on all events of a calendar, to add/set visibility of all event to the desired state.
Then the share via link would only show what is needed.
Limitation : new events created without visibility settings would be public until next run of the script. But maybe we can automate this as well ?
Implementation forking Calcleaner
I think I have to dig around this file:
calcleaner/calcleaner/caldav_helpers.py
Line 82 in 1eb5842
To each event I would have to add "CLASS:CONFIDENTIAL" to mark as busy, or "CLASS:PRIVATE" to hide it from share.
Can you help me getting this done ? How would you approach this ?
I will also point NC community to this issue, just in case it raises interest.
Thanks again!
-- Jaxom
The text was updated successfully, but these errors were encountered: