Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gepetto
dashboard
Commits
f5f83aca
Commit
f5f83aca
authored
Jan 29, 2018
by
Guilhem Saurel
Browse files
slugify_with_dots
parent
5eefc019
Changes
3
Hide whitespace changes
Inline
Side-by-side
rainboard/migrations/0003_slugify_with_dots.py
0 → 100644
View file @
f5f83aca
# Generated by Django 2.0.1 on 2018-01-29 16:43
import
autoslug.fields
from
django.db
import
migrations
import
rainboard.utils
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'rainboard'
,
'0002_forges'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'repo'
,
name
=
'slug'
,
field
=
autoslug
.
fields
.
AutoSlugField
(
editable
=
False
,
populate_from
=
'name'
,
slugify
=
rainboard
.
utils
.
slugify_with_dots
),
),
]
rainboard/models.py
View file @
f5f83aca
...
...
@@ -10,7 +10,7 @@ from ndh.models import Links, NamedModel, TimeStampedModel
from
ndh.utils
import
enum_to_choices
import
git
from
.utils
import
SOURCES
,
TARGETS
from
.utils
import
SOURCES
,
TARGETS
,
slugify_with_dots
logger
=
logging
.
getLogger
(
'rainboard.models'
)
...
...
@@ -165,7 +165,7 @@ class Forge(Links, NamedModel):
class
Repo
(
TimeStampedModel
):
name
=
models
.
CharField
(
max_length
=
200
)
slug
=
AutoSlugField
(
populate_from
=
'name'
)
slug
=
AutoSlugField
(
populate_from
=
'name'
,
slugify
=
slugify_with_dots
)
forge
=
models
.
ForeignKey
(
Forge
,
on_delete
=
models
.
CASCADE
)
namespace
=
models
.
ForeignKey
(
Namespace
,
on_delete
=
models
.
CASCADE
)
project
=
models
.
ForeignKey
(
Project
,
on_delete
=
models
.
CASCADE
)
...
...
@@ -245,7 +245,7 @@ class Repo(TimeStampedModel):
try
:
return
git
.
remote
(
remote
)
except
ValueError
:
logger
.
info
(
f
'Creating remote
{
self
.
forge
.
slug
}
/
{
self
.
namespace
.
slug
}
/
{
self
.
project
.
slug
}
'
)
logger
.
info
(
f
'Creating remote
{
remote
}
'
)
return
git
.
create_remote
(
remote
,
self
.
get_clone_url
())
...
...
rainboard/utils.py
View file @
f5f83aca
from
enum
import
IntEnum
import
unicodedata
import
re
from
django.utils.safestring
import
mark_safe
SOURCES
=
IntEnum
(
'Sources'
,
'github gitlab redmine robotpkg'
)
TARGETS
=
IntEnum
(
'Targets'
,
'12.04 14.04 16.04 dubnium'
)
def
slugify_with_dots
(
value
):
"""
slugify a name but keep dots
"""
value
=
unicodedata
.
normalize
(
'NFKD'
,
value
).
encode
(
'ascii'
,
'ignore'
).
decode
(
'ascii'
)
value
=
re
.
sub
(
r
'[^\w\s\.-]'
,
''
,
value
).
strip
().
lower
()
return
mark_safe
(
re
.
sub
(
r
'[-\s]+'
,
'-'
,
value
))
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment