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
314acd1d
Commit
314acd1d
authored
Sep 26, 2019
by
Zac Wood
Browse files
Merge branch '199-remove-signup' into 'v2.3'
Resolve "Remove /signup" See merge request
!138
parents
249aaa01
ac819e83
Pipeline
#4812
passed with stages
in 1 minute and 59 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
go/go/forms.py
View file @
314acd1d
...
@@ -14,7 +14,7 @@ from django.utils import timezone
...
@@ -14,7 +14,7 @@ from django.utils import timezone
from
django.utils.safestring
import
mark_safe
from
django.utils.safestring
import
mark_safe
# App Imports
# App Imports
from
.models
import
URL
,
RegisteredUser
from
.models
import
URL
# Other Imports
# Other Imports
# from bootstrap3_datetime.widgets import DateTimePicker
# from bootstrap3_datetime.widgets import DateTimePicker
...
@@ -275,85 +275,3 @@ class EditForm(URLForm):
...
@@ -275,85 +275,3 @@ class EditForm(URLForm):
class
Meta
(
URLForm
.
Meta
):
class
Meta
(
URLForm
.
Meta
):
# what attributes are included
# what attributes are included
fields
=
URLForm
.
Meta
.
fields
fields
=
URLForm
.
Meta
.
fields
class
SignupForm
(
ModelForm
):
"""
The form that is used when a user is signing up to be a RegisteredUser
"""
# The full name of the RegisteredUser
full_name
=
CharField
(
required
=
True
,
label
=
'Full Name (Required)'
,
max_length
=
100
,
widget
=
TextInput
(),
help_text
=
"We can fill in this field based on information provided by https://peoplefinder.gmu.edu."
,
)
# The RegisteredUser's chosen organization
organization
=
CharField
(
required
=
True
,
label
=
'Organization (Required)'
,
max_length
=
100
,
widget
=
TextInput
(),
help_text
=
"Or whatever
\"
group
\"
you would associate with on campus."
,
)
# The RegisteredUser's reason for signing up to us Go
description
=
CharField
(
required
=
False
,
label
=
'Description (Optional)'
,
max_length
=
200
,
widget
=
Textarea
(),
help_text
=
"Describe what type of links you would intend to create with Go."
,
)
# A user becomes registered when they agree to the TOS
registered
=
BooleanField
(
required
=
True
,
# ***Need to replace lower url with production URL***
# ie. go.gmu.edu/about#terms
label
=
mark_safe
(
'Do you accept the <a href="http://127.0.0.1:8000/about#terms">Terms of Service</a>?'
),
help_text
=
"Esssentially the GMU Responsible Use of Computing policies."
,
)
def
__init__
(
self
,
request
,
*
args
,
**
kwargs
):
"""
On initialization of the form, crispy forms renders this layout
"""
# Necessary to call request in forms.py, is otherwise restricted to
# views.py and models.py
self
.
request
=
request
super
(
SignupForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
helper
=
FormHelper
()
self
.
helper
.
form_class
=
'form-horizontal'
self
.
helper
.
label_class
=
'col-md-4'
self
.
helper
.
field_class
=
'col-md-6'
self
.
helper
.
layout
=
Layout
(
Fieldset
(
''
,
Div
(
# Place in form fields
Div
(
'full_name'
,
'organization'
,
'description'
,
'registered'
,
css_class
=
'well'
),
# Extras at bottom
StrictButton
(
'Submit'
,
css_class
=
'btn btn-primary btn-md col-md-4'
,
type
=
'submit'
),
css_class
=
'col-md-6'
)))
class
Meta
:
"""
Metadata about this ModelForm
"""
# what model this form is for
model
=
RegisteredUser
# what attributes are included
fields
=
[
'full_name'
,
'organization'
,
'description'
,
'registered'
]
go/go/templates/core/signup.html
deleted
100644 → 0
View file @
249aaa01
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- load django crispy forms' tags -->
{% load crispy_forms_tags %}
<!-- define the page title block -->
{% block title %}
SRCT Go
•
Apply
{% endblock %}
<!-- define the content block for the page -->
{% block content %}
<!-- define the page header div -->
<div
class=
"page-header"
id=
"banner"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h1>
<span
class=
"fa-stack fa-lg"
>
<i
class=
"fa fa-circle fa-stack-2x"
></i>
<i
class=
"fa fa-user-plus fa-stack-1x fa-inverse"
></i>
</span>
Apply to Go
</h1>
</div>
</div>
</div>
<!-- Define the div that describes why we need a signup process -->
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<p>
In order to prevent abuse of the URL Shortner, users must be manually approved.
<br></br>
You will need to list the organization you represent and, while optional, we would like to know
<br
/>
why you would like to use Go and
some examples where you would use this service.
<br></br>
Please indicate below if you are interested.
</p>
<br
/>
<legend></legend>
</div>
</div>
<!-- call django crispy forms to render the go signup form here -->
{% crispy form %}
{% endblock %}
go/go/templates/not_registered.html
deleted
100644 → 0
View file @
249aaa01
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- define the page title block -->
{% block title %}
SRCT Go
•
Account Not Approved
{% endblock %}
<!-- define the content block for the page -->
{% block content %}
<!-- define the page header div -->
<div
class=
"page-header"
id=
"banner"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h1>
<span
class=
"fa-stack fa-lg"
>
<i
class=
"fa fa-circle fa-stack-2x"
></i>
<i
class=
"fa fa-ban fa-stack-1x fa-inverse"
></i>
</span>
Account Not Approved
</h1>
</div>
</div>
</div>
<!-- define the div that explains why you need to be registered -->
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<p>
Because Go allows users to represent their group or organization with
George Mason branding, user accounts must be manually approved by a Go
official.
</p>
<br
/>
<p>
{% if not request.user.registereduser.registered %}
If you have not done so, you may
<a
href=
"{% url 'signup' %}"
>
sign up
</a>
for an account.
<br></br>
This process takes time. Please be patient.
{% else %}
According to our database you have registered, but are not yet approved, to use Go.
<br
/>
This process takes time. Please be patient.
{% endif %}
</p>
<br/><br/>
</div>
</div>
{% endblock %}
go/go/templates/public_landing.html
View file @
314acd1d
...
@@ -88,7 +88,7 @@ SRCT Go • Welcome
...
@@ -88,7 +88,7 @@ SRCT Go • Welcome
<br
/>
<br
/>
<hr
/>
<hr
/>
<!-- carefully formatted login
and signup
button
s
-->
<!-- carefully formatted login button -->
<!-- https://files.slack.com/files-pri/T025B796J-F0KPTCTD3/spin-dhaynes-buttons.gif -->
<!-- https://files.slack.com/files-pri/T025B796J-F0KPTCTD3/spin-dhaynes-buttons.gif -->
<div
class=
"fix row"
>
<div
class=
"fix row"
>
<div
class=
"col"
>
<div
class=
"col"
>
...
...
go/go/templates/registered.html
deleted
100644 → 0
View file @
249aaa01
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- define the page title block -->
{% block title %}
SRCT Go
•
Registration Email Sent
{% endblock %}
<!-- define the content block for the page -->
{% block content %}
<!-- define the page header div -->
<div
class=
"page-header"
id=
"banner"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<h1>
<span
class=
"fa-stack fa-lg"
>
<i
class=
"fa fa-circle fa-stack-2x"
></i>
<i
class=
"fa fa-envelope-o fa-stack-1x fa-inverse"
></i>
</span>
Registration Email Sent
</h1>
</div>
</div>
</div>
<!-- define the div that tells the user that they have registered -->
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<p>
Your registration request has been sent!
<br></br>
You will recieve a confirmation email when your application has been received
and once it has been approved.
<br
/>
Please be patient, our administrators will handle your application as soon as they can.
</p>
</div>
</div>
{% endblock %}
go/go/test_forms.py
View file @
314acd1d
...
@@ -13,7 +13,7 @@ from django.contrib.auth.models import User
...
@@ -13,7 +13,7 @@ from django.contrib.auth.models import User
from
django.test
import
TestCase
from
django.test
import
TestCase
# App Imports
# App Imports
from
.forms
import
SignupForm
,
URLForm
,
EditForm
from
.forms
import
URLForm
,
EditForm
from
.models
import
URL
,
RegisteredUser
from
.models
import
URL
,
RegisteredUser
class
URLFormTest
(
TestCase
):
class
URLFormTest
(
TestCase
):
...
@@ -146,88 +146,3 @@ class EditForm(TestCase):
...
@@ -146,88 +146,3 @@ class EditForm(TestCase):
"""
"""
self
.
assertEqual
(
"Hello World!"
,
"Hello World!"
)
self
.
assertEqual
(
"Hello World!"
,
"Hello World!"
)
class
SignupFormTest
(
TestCase
):
"""
Test cases for the Signup form
"""
def
test_valid_form
(
self
):
"""
Test that forms are validated correctly given valid data.
"""
form_data
=
{
'full_name'
:
'David Haynes'
,
'organization'
:
'SRCT'
,
'description'
:
'the big brown fox jumps over the lazy dog'
,
'registered'
:
'True'
}
form
=
SignupForm
(
request
=
None
,
data
=
form_data
)
print
(
form
.
errors
)
self
.
assertTrue
(
form
.
is_valid
())
def
test_invalid_full_name
(
self
):
"""
Test invalid full_name field
"""
form_data
=
{
'full_name'
:
''
,
'organization'
:
'SRCT'
,
'description'
:
'the big brown fox jumps over the lazy dog'
,
'registered'
:
'True'
}
form
=
SignupForm
(
request
=
None
,
data
=
form_data
)
print
(
form
.
errors
)
self
.
assertFalse
(
form
.
is_valid
())
def
test_invalid_organization
(
self
):
"""
Test invalid organization field
"""
form_data
=
{
'full_name'
:
'David Haynes'
,
'organization'
:
''
,
'description'
:
'the big brown fox jumps over the lazy dog'
,
'registered'
:
'True'
}
form
=
SignupForm
(
request
=
None
,
data
=
form_data
)
print
(
form
.
errors
)
self
.
assertFalse
(
form
.
is_valid
())
def
test_blank_description
(
self
):
"""
Test blank description field
"""
form_data
=
{
'full_name'
:
'David Haynes'
,
'organization'
:
'SRCT'
,
'description'
:
''
,
'registered'
:
'True'
}
form
=
SignupForm
(
request
=
None
,
data
=
form_data
)
print
(
form
.
errors
)
self
.
assertTrue
(
form
.
is_valid
())
def
test_invalid_registered
(
self
):
"""
Test invalid registered field
"""
form_data
=
{
'full_name'
:
'David Haynes'
,
'organization'
:
'SRCT'
,
'description'
:
'the big brown fox jumps over the lazy dog'
,
'registered'
:
'False'
}
form
=
SignupForm
(
request
=
None
,
data
=
form_data
)
print
(
form
.
errors
)
self
.
assertFalse
(
form
.
is_valid
())
go/go/test_models.py
View file @
314acd1d
...
@@ -182,7 +182,7 @@ class RegisteredUserTest(TestCase):
...
@@ -182,7 +182,7 @@ class RegisteredUserTest(TestCase):
get_user
=
User
.
objects
.
get
(
username
=
'dhaynes'
)
get_user
=
User
.
objects
.
get
(
username
=
'dhaynes'
)
get_registered_user
=
RegisteredUser
.
objects
.
get
(
user
=
get_user
)
get_registered_user
=
RegisteredUser
.
objects
.
get
(
user
=
get_user
)
self
.
assert
Fals
e
(
get_registered_user
.
approved
)
self
.
assert
Tru
e
(
get_registered_user
.
approved
)
# blocked ------------------------------------------------------------------
# blocked ------------------------------------------------------------------
...
@@ -198,7 +198,7 @@ class RegisteredUserTest(TestCase):
...
@@ -198,7 +198,7 @@ class RegisteredUserTest(TestCase):
self
.
assertTrue
(
get_registered_user
.
blocked
)
self
.
assertTrue
(
get_registered_user
.
blocked
)
def
test_
approv
ed_default
(
self
):
def
test_
block
ed_default
(
self
):
"""
"""
test the blocked bool default
test the blocked bool default
"""
"""
...
...
go/go/test_views.py
View file @
314acd1d
...
@@ -153,19 +153,6 @@ class DeleteTest(TestCase):
...
@@ -153,19 +153,6 @@ class DeleteTest(TestCase):
response
=
self
.
client
.
get
(
'/delete/test'
)
response
=
self
.
client
.
get
(
'/delete/test'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
response
.
status_code
,
302
)
class
SignupTest
(
TestCase
):
"""
Test cases for the signup view
"""
def
test_signup_get_anon
(
self
):
"""
Test that the signup view redirects anons to login with cas on an EXTERNAL
CAS link, so 302 REDIRECT.
"""
response
=
self
.
client
.
get
(
'/signup'
)
self
.
assertEqual
(
response
.
status_code
,
302
)
class
RedirectionTest
(
TestCase
):
class
RedirectionTest
(
TestCase
):
"""
"""
...
...
go/go/views.py
View file @
314acd1d
...
@@ -20,7 +20,7 @@ from django.utils import timezone
...
@@ -20,7 +20,7 @@ from django.utils import timezone
from
ratelimit.decorators
import
ratelimit
from
ratelimit.decorators
import
ratelimit
# App Imports
# App Imports
from
.forms
import
SignupForm
,
URLForm
,
EditForm
from
.forms
import
URLForm
,
EditForm
from
.models
import
URL
,
RegisteredUser
from
.models
import
URL
,
RegisteredUser
...
@@ -51,9 +51,7 @@ def new_link(request):
...
@@ -51,9 +51,7 @@ def new_link(request):
"""
"""
This view handles the homepage that the user is presented with when
This view handles the homepage that the user is presented with when
they request '/newLink'. If they're not logged in, they're redirected to
they request '/newLink'. If they're not logged in, they're redirected to
login. If they're logged in but not registered, they're given the
login.
not_registered error page. If they are logged in AND registered, they
get the URL registration form.
"""
"""
# If the user is blocked, then display the you're blocked page.
# If the user is blocked, then display the you're blocked page.
...
@@ -314,108 +312,6 @@ def delete(request, short):
...
@@ -314,108 +312,6 @@ def delete(request, short):
url
.
delete
()
url
.
delete
()
return
redirect
(
'my_links'
)
return
redirect
(
'my_links'
)
@
login_required
def
signup
(
request
):
"""
This view presents the user with a registration form. You can register
yourself.
"""
# Do not display signup page to registered or approved users
if
request
.
user
.
registereduser
.
blocked
:
return
render
(
request
,
'banned.html'
)
elif
request
.
user
.
registereduser
.
approved
:
return
redirect
(
'/'
)
elif
request
.
user
.
registereduser
.
registered
:
return
redirect
(
'registered'
)
# Initialize our signup form
signup_form
=
SignupForm
(
request
,
initial
=
{
'full_name'
:
request
.
user
.
first_name
+
" "
+
request
.
user
.
last_name
}
)
# Set the full_name field to readonly since CAS will fill that in for them
signup_form
.
fields
[
'full_name'
].
widget
.
attrs
[
'readonly'
]
=
'readonly'
# If a POST request is received, then the user has submitted a form and it's
# time to parse the form and create a new RegisteredUser
if
request
.
method
==
'POST'
:
# Now we initialize the form again but this time we have the POST
# request
signup_form
=
SignupForm
(
request
,
request
.
POST
,
instance
=
request
.
user
.
registereduser
,
initial
=
{
'full_name'
:
request
.
user
.
first_name
+
" "
+
request
.
user
.
last_name
}
)
# set the readonly flag again for good measure
signup_form
.
fields
[
'full_name'
].
widget
.
attrs
[
'readonly'
]
=
'readonly'
# Django will check the form to make sure it's valid
if
signup_form
.
is_valid
():
# Grab data from the form and store into variables
description
=
signup_form
.
cleaned_data
.
get
(
'description'
)
full_name
=
signup_form
.
cleaned_data
.
get
(
'full_name'
)
organization
=
signup_form
.
cleaned_data
.
get
(
'organization'
)
# Only send mail if we've defined the mailserver
if
settings
.
EMAIL_HOST
and
settings
.
EMAIL_PORT
:
user_mail
=
request
.
user
.
username
+
settings
.
EMAIL_DOMAIN
# Email sent to notify Admins
to_admin
=
EmailMessage
(
'Signup from %s'
%
(
request
.
user
.
registereduser
.
user
),
######################
'%s signed up at %s
\n\n
'
'Username: %s
\n
'
'Organization: %s
\n\n
'
'Message: %s
\n\n
'
'You can contact the user directly by replying to this email or '
'reply all to contact the user and notfiy the mailing list.
\n
'
'Please head to go.gmu.edu/useradmin to approve or '
'deny this application.'
%
(
str
(
full_name
),
str
(
timezone
.
now
()).
strip
(),
str
(
request
.
user
.
registereduser
.
user
),
str
(
organization
),
str
(
description
)
),
######################
settings
.
EMAIL_FROM
,
[
settings
.
EMAIL_TO
],
reply_to
=
[
user_mail
]
)
to_admin
.
send
()
# Confirmation email sent to Users
send_mail
(
'We have received your Go application!'
,
######################
'Hey there %s,
\n\n
'
'The Go admins have received your application and are '
'currently in the process of reviewing it.
\n\n
'
'You will receive another email when you have been '
'approved.
\n\n
'
'- Go Admins'
%
(
str
(
full_name
)),
######################
settings
.
EMAIL_FROM
,
[
user_mail
]
)
# Make sure that our new RegisteredUser object is clean, then save
# it and let's redirect to tell the user they have registered.
signup_form
.
save
()
return
redirect
(
'registered'
)
# render signup.html passing along the form and the current registered
# status
return
render
(
request
,
'core/signup.html'
,
{
'form'
:
signup_form
,
'registered'
:
False
,
})
def
redirection
(
request
,
short
):
def
redirection
(
request
,
short
):
"""
"""
This view redirects a user based on the short URL they requested.
This view redirects a user based on the short URL they requested.
...
...
go/settings/test_urls.py
View file @
314acd1d
...
@@ -62,14 +62,6 @@ class UrlsTest(TestCase):
...
@@ -62,14 +62,6 @@ class UrlsTest(TestCase):
url
=
reverse
(
'about'
)
url
=
reverse
(
'about'
)
self
.
assertEqual
(
url
,
'/about'
)
self
.
assertEqual
(
url
,
'/about'
)
def
test_signup_reverse
(
self
):
"""
/signup - Signup page for access.
"""
url
=
reverse
(
'signup'
)
self
.
assertEqual
(
url
,
'/signup'
)
def
test_my_links_reverse
(
self
):
def
test_my_links_reverse
(
self
):
"""
"""
/myLinks - My-Links page, view and review links.
/myLinks - My-Links page, view and review links.
...
@@ -143,14 +135,6 @@ class UrlsTest(TestCase):
...
@@ -143,14 +135,6 @@ class UrlsTest(TestCase):
url
=
reverse
(
'delete'
,
args
=
[
'dhaynes123_-'
])
url
=
reverse
(
'delete'
,
args
=
[
'dhaynes123_-'
])
self
.
assertEqual
(
url
,
'/delete/dhaynes123_-'
)
self
.
assertEqual
(
url
,
'/delete/dhaynes123_-'
)
def
test_registered_reverse
(
self
):
"""
/registered - registration complete page
"""
url
=
reverse
(
'registered'
)
self
.
assertEqual
(
url
,
'/registered'
)
# The /admin URL is not tested as it is never resolves in source and generally
# The /admin URL is not tested as it is never resolves in source and generally
# Django yells at you if the admin page breaks
# Django yells at you if the admin page breaks
...
...
go/settings/urls.py
View file @
314acd1d
...
@@ -30,9 +30,6 @@ urlpatterns = [
...
@@ -30,9 +30,6 @@ urlpatterns = [
url
(
r
'^about/?$'
,
cache_page
(
60
*
15
)(
TemplateView
.
as_view
(
template_name
=
'core/about.html'
)),
url
(
r
'^about/?$'
,
cache_page
(
60
*
15
)(
TemplateView
.
as_view
(
template_name
=
'core/about.html'
)),
name
=
'about'
),
name
=
'about'
),
# /signup - Signup page for access. Cached for 15 minutes
url
(
r
'^signup/?$'
,
cache_page
(
60
*
15
)(
go
.
views
.
signup
),
name
=
'signup'
),
# /newLink - My-Links page, view and review links.
# /newLink - My-Links page, view and review links.
url
(
r
'^newLink/?$'
,
go
.
views
.
new_link
,
name
=
'new_link'
),
url
(
r
'^newLink/?$'
,
go
.
views
.
new_link
,
name
=
'new_link'
),
...
@@ -45,10 +42,6 @@ urlpatterns = [
...
@@ -45,10 +42,6 @@ urlpatterns = [
# /delete/<short> - Delete a link, no content display.
# /delete/<short> - Delete a link, no content display.
url
(
r
'^delete/(?P<short>[-\w]+)$'
,
go
.
views
.
delete
,
name
=
'delete'
),
url
(
r
'^delete/(?P<short>[-\w]+)$'
,
go
.
views
.
delete
,
name
=
'delete'
),
# /registered - registration complete page. Cached for 15 minutes
url
(
r
'^registered/?$'
,
cache_page
(
60
*
15
)(
TemplateView
.
as_view
(
template_name
=
'registered.html'
)),
name
=
'registered'
),
# /admin - Administrator interface.
# /admin - Administrator interface.
url
(
r
'^admin/?'
,
admin
.
site
.
urls
,
name
=
'go_admin'
),