Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Collection of Practice
2019
1606885025-practice
Commits
20022472
Commit
20022472
authored
Dec 10, 2019
by
Rani Lasma Uli
Browse files
add migration
parent
59021c39
Pipeline
#27139
failed with stages
in 1 minute and 28 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lists/migrations/0004_remove_duplicates.py
0 → 100644
View file @
20022472
# -*- coding: utf-8 -*-
# Generated by Django 1.11.24 on 2019-12-10 16:01
from
__future__
import
unicode_literals
from
django.db
import
migrations
def
find_dupes
(
apps
,
schema_editor
):
List
=
apps
.
get_model
(
"lists"
,
"List"
)
for
list_
in
List
.
objects
.
all
():
items
=
list_
.
item_set
.
all
()
texts
=
set
()
for
ix
,
item
in
enumerate
(
items
):
if
item
.
text
in
texts
:
item
.
text
=
'{} ({})'
.
format
(
item
.
text
,
ix
)
item
.
save
()
texts
.
add
(
item
.
text
)
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'lists'
,
'0003_auto_20191121_1714'
),
]
operations
=
[
migrations
.
RunPython
(
find_dupes
),
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment