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
5ac81188
Commit
5ac81188
authored
Sep 19, 2019
by
tomatocurry1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed depricated registration related code
parent
9793c71f
Pipeline
#4806
failed with stages
in 59 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
5 additions
and
447 deletions
+5
-447
go/go/forms.py
go/go/forms.py
+1
-83
go/go/templates/core/signup.html
go/go/templates/core/signup.html
+0
-51
go/go/templates/not_registered.html
go/go/templates/not_registered.html
+0
-52
go/go/templates/public_landing.html
go/go/templates/public_landing.html
+1
-1
go/go/templates/registered.html
go/go/templates/registered.html
+0
-41
go/go/test_forms.py
go/go/test_forms.py
+1
-86
go/go/test_views.py
go/go/test_views.py
+0
-13
go/go/views.py
go/go/views.py
+2
-105
go/settings/test_urls.py
go/settings/test_urls.py
+0
-8
go/settings/urls.py
go/settings/urls.py
+0
-7
No files found.
go/go/forms.py
View file @
5ac81188
...
...
@@ -14,7 +14,7 @@ from django.utils import timezone
from
django.utils.safestring
import
mark_safe
# App Imports
from
.models
import
URL
,
RegisteredUser
from
.models
import
URL
# Other Imports
# from bootstrap3_datetime.widgets import DateTimePicker
...
...
@@ -275,85 +275,3 @@ class EditForm(URLForm):
class
Meta
(
URLForm
.
Meta
):
# what attributes are included
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 @
9793c71f
<!-- 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 @
9793c71f
<!-- 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 @
5ac81188
...
...
@@ -88,7 +88,7 @@ SRCT Go • Welcome
<br
/>
<hr
/>
<!-- carefully formatted login
and signup buttons
-->
<!-- carefully formatted login
button
-->
<!-- https://files.slack.com/files-pri/T025B796J-F0KPTCTD3/spin-dhaynes-buttons.gif -->
<div
class=
"fix row"
>
<div
class=
"col"
>
...
...
go/go/templates/registered.html
deleted
100644 → 0
View file @
9793c71f
<!-- 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 @
5ac81188
...
...
@@ -13,7 +13,7 @@ from django.contrib.auth.models import User
from
django.test
import
TestCase
# App Imports
from
.forms
import
SignupForm
,
URLForm
,
EditForm
from
.forms
import
URLForm
,
EditForm
from
.models
import
URL
,
RegisteredUser
class
URLFormTest
(
TestCase
):
...
...
@@ -146,88 +146,3 @@ class EditForm(TestCase):
"""
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_views.py
View file @
5ac81188
...
...
@@ -153,19 +153,6 @@ class DeleteTest(TestCase):
response
=
self
.
client
.
get
(
'/delete/test'
)
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
):
"""
...
...
go/go/views.py
View file @
5ac81188
...
...
@@ -20,7 +20,7 @@ from django.utils import timezone
from
ratelimit.decorators
import
ratelimit
# App Imports
from
.forms
import
SignupForm
,
URLForm
,
EditForm
from
.forms
import
URLForm
,
EditForm
from
.models
import
URL
,
RegisteredUser
...
...
@@ -51,9 +51,7 @@ def new_link(request):
"""
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
login. If they're logged in but not registered, they're given the
not_registered error page. If they are logged in AND registered, they
get the URL registration form.
login.
"""
# If the user is blocked, then display the you're blocked page.
...
...
@@ -317,107 +315,6 @@ def delete(request, short):
# do not allow them to delete
raise
PermissionDenied
()
@
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
):
"""
...
...
go/settings/test_urls.py
View file @
5ac81188
...
...
@@ -62,14 +62,6 @@ class UrlsTest(TestCase):
url
=
reverse
(
'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
):
"""
/myLinks - My-Links page, view and review links.
...
...
go/settings/urls.py
View file @
5ac81188
...
...
@@ -30,9 +30,6 @@ urlpatterns = [
url
(
r'^about/?$'
,
cache_page
(
60
*
15
)(
TemplateView
.
as_view
(
template_name
=
'core/about.html'
)),
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.
url
(
r'^newLink/?$'
,
go
.
views
.
new_link
,
name
=
'new_link'
),
...
...
@@ -45,10 +42,6 @@ urlpatterns = [
# /delete/<short> - Delete a link, no content display.
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.
url
(
r'^admin/?'
,
admin
.
site
.
urls
,
name
=
'go_admin'
),
...
...
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