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
818b7d8b
Commit
818b7d8b
authored
Feb 01, 2014
by
Jean Michel Rouly
Browse files
Remigrated logic back into view so it works now omg
parent
4b940ea2
Changes
1
Show whitespace changes
Inline
Side-by-side
go/go/views.py
View file @
818b7d8b
...
...
@@ -2,7 +2,7 @@ from go.models import URL, RegisteredUser
from
go.forms
import
URLForm
,
SignupForm
from
datetime
import
timedelta
from
django.conf
import
settings
from
django.http
import
Http404
from
django.http
import
Http404
,
HttpResponseServerError
from
django.utils
import
timezone
from
django.contrib.auth.models
import
User
from
django.core.exceptions
import
PermissionDenied
...
...
@@ -93,7 +93,16 @@ def index(request):
if
len
(
short
)
>
0
:
url
.
short
=
short
else
:
url
.
short
=
URL
.
generate_valid_short
()
# If the user didn't enter a short url, generate a random
# one. However, if a random one can't be generated, return
# a 500 server error.
random_short
=
URL
.
generate_valid_short
()
if
random_short
is
None
:
return
HttpResponseServerError
(
render
(
request
,
'500.html'
,
{})
)
else
:
url
.
short
=
random_short
# Grab the expiration field value. It's currently an unsable
# string value, so we need to parse it into a datetime object
...
...
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