Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
21
Issues
21
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
go
Commits
eebe7920
Verified
Commit
eebe7920
authored
Aug 21, 2017
by
David Haynes
🙆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove troubled python check
- this was actually not even used...
parent
9cbb8a0a
Pipeline
#1521
failed with stages
in 1 minute and 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
21 deletions
+6
-21
go/go/forms.py
go/go/forms.py
+1
-16
go/go/test_forms.py
go/go/test_forms.py
+5
-5
No files found.
go/go/forms.py
View file @
eebe7920
"""
go/forms.py
"""
# Future Imports
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
# Python stdlib Imports
from
datetime
import
datetime
,
timedelta
from
six.moves
import
urllib
# Django Imports
from
django.core.exceptions
import
ValidationError
...
...
@@ -26,7 +24,7 @@ from bootstrap3_datetime.widgets import DateTimePicker
from
crispy_forms.bootstrap
import
(
Accordion
,
AccordionGroup
,
PrependedText
,
StrictButton
)
from
crispy_forms.helper
import
FormHelper
from
crispy_forms.layout
import
HTML
,
Div
,
Field
,
Fieldset
,
Layout
,
Submit
from
crispy_forms.layout
import
HTML
,
Div
,
Field
,
Fieldset
,
Layout
class
URLForm
(
ModelForm
):
...
...
@@ -40,22 +38,9 @@ class URLForm(ModelForm):
"""
Prevent redirect loop links
"""
# get the entered target link
target
=
self
.
cleaned_data
.
get
(
'target'
)
try
:
final_url
=
urllib
.
request
.
urlopen
(
target
).
geturl
()
# if visiting the provided url results in an HTTP error, or redirects
# to a page that results in an HTTP error
except
urllib
.
error
.
URLError
as
e
:
# to permit users to enter sites that return most errors, but
# prevent them from entering sites that result in an HTTP 300 error
if
any
(
int
(
str
(
e
)[
11
:
14
])
==
errorNum
for
errorNum
in
range
(
300
,
308
)):
raise
ValidationError
(
"Link results in a 300 error"
)
else
:
final_url
=
""
# Commented out as this check cannont properly be tested since we cannot
# dynamically generate request.META.get('HTTP_HOST')
...
...
go/go/test_forms.py
View file @
eebe7920
...
...
@@ -44,7 +44,7 @@ class URLFormTest(TestCase):
"""
form_data
=
{
'target'
:
'http://srct.gmu.edu'
,
'target'
:
'http
s
://srct.gmu.edu'
,
'short'
:
'pls'
,
'expires'
:
'1 Day'
,
'expires_custom'
:
''
...
...
@@ -60,7 +60,7 @@ class URLFormTest(TestCase):
"""
form_data
=
{
'target'
:
'http://srct.gmu.edu'
,
'target'
:
'http
s
://srct.gmu.edu'
,
'short'
:
'pls'
,
'expires'
:
'Custom Date'
,
'expires_custom'
:
datetime
.
now
()
+
timedelta
(
days
=
1
)
...
...
@@ -92,7 +92,7 @@ class URLFormTest(TestCase):
"""
form_data
=
{
'target'
:
'http://srct.gmu.edu'
,
'target'
:
'http
s
://srct.gmu.edu'
,
'short'
:
'test'
,
'expires'
:
'1 Day'
,
'expires_custom'
:
''
...
...
@@ -108,7 +108,7 @@ class URLFormTest(TestCase):
"""
form_data
=
{
'target'
:
'http://srct.gmu.edu'
,
'target'
:
'http
s
://srct.gmu.edu'
,
'short'
:
'pls'
,
'expires'
:
'None'
,
'expires_custom'
:
''
...
...
@@ -124,7 +124,7 @@ class URLFormTest(TestCase):
"""
form_data
=
{
'target'
:
'http://srct.gmu.edu'
,
'target'
:
'http
s
://srct.gmu.edu'
,
'short'
:
'pls'
,
'expires'
:
'Custom Date'
,
'expires_custom'
:
datetime
.
now
()
-
timedelta
(
days
=
1
)
...
...
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