Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Maják
Commits
e546c923
Commit
e546c923
authored
2 years ago
by
jan.bednarik
Browse files
Options
Downloads
Patches
Plain Diff
calendar utils: Handle wrong calendars
parent
734b571b
No related branches found
No related tags found
2 merge requests
!627
calendar utils: Handle wrong calendars
,
!626
calendar utils: Handle wrong calendars
Pipeline
#9817
passed
2 years ago
Stage: build
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
calendar_utils/management/commands/update_callendars.py
+5
-1
5 additions, 1 deletion
calendar_utils/management/commands/update_callendars.py
calendar_utils/models.py
+12
-2
12 additions, 2 deletions
calendar_utils/models.py
with
17 additions
and
3 deletions
calendar_utils/management/commands/update_callendars.py
+
5
−
1
View file @
e546c923
import
logging
from
django.core.management.base
import
BaseCommand
from
...models
import
Calendar
logger
=
logging
.
getLogger
(
__name__
)
class
Command
(
BaseCommand
):
def
handle
(
self
,
*
args
,
**
options
):
...
...
@@ -12,7 +16,7 @@ class Command(BaseCommand):
cal
.
update_source
()
self
.
stdout
.
write
(
"
+ ok
"
)
except
Exception
as
e
:
# TODO logging
logger
.
error
(
"
Calendar update failed for %s
"
,
cal
.
url
,
exc_info
=
True
)
self
.
stdout
.
write
(
"
- failed
"
)
self
.
stdout
.
write
(
str
(
e
))
...
...
This diff is collapsed.
Click to expand it.
calendar_utils/models.py
+
12
−
2
View file @
e546c923
import
logging
from
datetime
import
date
,
timedelta
import
arrow
...
...
@@ -7,6 +8,8 @@ from icalevnt import icalevents
from
.parser
import
process_event_list
logger
=
logging
.
getLogger
(
__name__
)
def
_convert_arrow_to_datetime
(
event
):
event
[
"
start
"
]
=
event
[
"
start
"
].
datetime
...
...
@@ -86,11 +89,18 @@ class CalendarMixin(models.Model):
self
.
calendar
.
save
()
else
:
self
.
calendar
=
Calendar
.
objects
.
create
(
url
=
self
.
calendar_url
)
self
.
calendar
.
update_source
()
try
:
self
.
calendar
.
update_source
()
except
:
logger
.
error
(
"
Calendar update failed for %s
"
,
self
.
calendar
.
url
,
exc_info
=
True
)
# delete related Calendar when URL is cleared
if
not
self
.
calendar_url
and
self
.
calendar
:
self
.
calendar
.
delete
()
# TODO handle revisions and maybe other live pages with the same calendar
# self.calendar.delete()
self
.
calendar
=
None
super
().
save
(
*
args
,
**
kwargs
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment