Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
2e0107c8
Commit
2e0107c8
authored
Sep 09, 2014
by
Akshay Karthik
Browse files
re-add loop
parent
f91f0011
Changes
1
Hide whitespace changes
Inline
Side-by-side
go/go/models.py
View file @
2e0107c8
...
...
@@ -37,14 +37,14 @@ class URL( models.Model ):
hashids_counter
+=
1
short
=
hashids
.
encrypt
(
hashids_counter
)
tries
=
1
try
:
urls
=
URL
.
objects
.
get
(
short__iexact
=
short
)
tries
+=
1
hashids_counter
+=
1
except
URL
.
DoesNotExist
:
return
short
if
tries
>
100
:
return
None
while
tries
<
100
:
try
:
urls
=
URL
.
objects
.
get
(
short__iexact
=
short
)
tries
+=
1
hashids_counter
+=
1
except
URL
.
DoesNotExist
:
return
short
return
None
# this needs to be here instead of at the top because the model's manager must be available before this line
hashids_counter
=
URL
.
objects
.
count
()
...
...
Write
Preview
Markdown
is supported
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