Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
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
AURA
steering
Commits
7f7e61b0
Commit
7f7e61b0
authored
13 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
updated note migration.
parent
b9aea9d7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/management/commands/importnotes.py
+16
-12
16 additions, 12 deletions
program/management/commands/importnotes.py
with
16 additions
and
12 deletions
program/management/commands/importnotes.py
+
16
−
12
View file @
7f7e61b0
from
django.contrib.auth.models
import
User
from
django.core.exceptions
import
ObjectDoesNotExist
,
MultipleObjectsReturned
from
django.core.exceptions
import
ObjectDoesNotExist
,
MultipleObjectsReturned
,
ValidationError
from
django.core.management.base
import
NoArgsCommand
from
django.utils.html
import
clean_html
,
strip_tags
...
...
@@ -22,14 +22,14 @@ class Command(NoArgsCommand):
cursor
.
execute
(
"""
SELECT n.titel, n.datum, s.titel, n.notiz
FROM notizen AS n JOIN sendungen AS s ON n.sendung_id=s.id
WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_date)
AND n.titel !=
''
"""
)
WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_date)
"""
)
counter
=
0
for
ntitel
,
datum
,
stitel
,
notiz
in
cursor
.
fetchall
():
ntitel
=
strip_tags
(
ntitel
)
ntitel
=
strip_tags
(
ntitel
)
if
ntitel
else
strip_tags
(
stitel
)
stitel
=
strip_tags
(
stitel
)
notiz
=
clean_html
(
notiz
)
if
stitel
.
endswith
(
'
(Wiederholung)
'
):
stitel
=
stitel
[:
-
15
]
...
...
@@ -37,7 +37,9 @@ WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_d
year
,
month
,
day
=
datum
.
year
,
datum
.
month
,
datum
.
day
try
:
show
=
Show
.
objects
.
get
(
name
=
stitel
)
except
ObjectDoesNotExist
:
print
'
show with name
"
%s
"
not found
'
%
stitel
else
:
try
:
timeslot
=
TimeSlot
.
objects
.
get
(
programslot__show
=
show
,
start__year
=
year
,
start__month
=
month
,
start__day
=
day
)
except
ObjectDoesNotExist
:
...
...
@@ -46,15 +48,17 @@ WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_d
print
'
multiple timeslots found for sendung
"
%s
"
and datum
"
%s
"'
%
(
stitel
,
datum
)
else
:
note
=
Note
(
timeslot
=
timeslot
,
owner
=
OWNER
,
title
=
ntitel
,
content
=
notiz
)
try
:
note
.
sav
e
()
except
:
print
'
could not save note
"
%s
"
for show
"
%s
"
and datum
"
%s
"'
%
(
ntitel
,
stitel
,
datum
)
note
.
validate_uniqu
e
()
except
ValidationError
:
print
'
note already imported
for show
"
%s
"
and datum
"
%s
"'
%
(
stitel
,
datum
)
else
:
counter
+=
1
except
ObjectDoesNotExist
:
print
'
show with name
"
%s
"
not found
'
%
stitel
try
:
note
.
save
()
except
:
print
'
could not save note
"
%s
"
for show
"
%s
"
and datum
"
%s
"'
%
(
ntitel
,
stitel
,
datum
)
else
:
counter
+=
1
cursor
.
close
()
connection
.
close
()
...
...
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