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
6520581f
Verified
Commit
6520581f
authored
May 19, 2018
by
David Haynes
🙆
Browse files
Migrate to the Pipfile system
- much, more more control
parent
9ba9ca02
Changes
11
Hide whitespace changes
Inline
Side-by-side
Dockerfile
View file @
6520581f
...
...
@@ -12,4 +12,5 @@ WORKDIR /go/
ADD
. /go/
# Install pip dependecies
RUN
pip
install
-r
/go/requirements/dev.txt
RUN
pip
install
pipenv
RUN
pipenv
install
--system
--deploy
Pipfile
0 → 100644
View file @
6520581f
[[source]]
url
=
"https://pypi.org/simple"
verify_ssl
=
true
name
=
"pypi"
[dev-packages]
pylint
=
"*"
pylint-django
=
"*"
"autopep8"
=
"*"
[packages]
django
=
"<2.1,>=2.0"
django-crispy-forms
=
"==1.7.0"
django-ratelimit
=
"==1.0.1"
django-redis-cache
=
"==1.7.1"
django-qrcode
=
{
git
=
"https://github.com/dhaynespls/django-qrcode.git"
,
editable
=
true
}
django-cas-client
=
{
git
=
"https://github.com/kstateome/django-cas.git"
,
editable
=
true
}
"django-bootstrap3-datetimepicker"
=
{
git
=
"https://github.com/dhaynespls/django-bootstrap3-datetimepicker.git"
,
editable
=
true
}
hashids
=
"==1.2.0"
mysqlclient
=
"*"
[requires]
python_version
=
"3.6"
Pipfile.lock
0 → 100644
View file @
6520581f
{
"_meta"
:
{
"hash"
:
{
"sha256"
:
"00e93a32d56376e61c103f31302646aa9b2aaac10a9c1c442507aaa42643522c"
},
"pipfile-spec"
:
6
,
"requires"
:
{
"python_version"
:
"3.6"
},
"sources"
:
[
{
"name"
:
"pypi"
,
"url"
:
"https://pypi.org/simple"
,
"verify_ssl"
:
true
}
]
},
"default"
:
{
"django"
:
{
"hashes"
:
[
"sha256:26b34f4417aa38d895b6b5307177b51bc3f4d53179d8696a5c19dcb50582523c"
,
"sha256:71d1a584bb4ad2b4f933d07d02c716755c1394feaac1ce61ce37843ac5401092"
],
"index"
:
"pypi"
,
"version"
:
"==2.0.5"
},
"django-bootstrap3-datetimepicker"
:
{
"editable"
:
true
,
"git"
:
"https://github.com/dhaynespls/django-bootstrap3-datetimepicker.git"
},
"django-cas-client"
:
{
"editable"
:
true
,
"git"
:
"https://github.com/kstateome/django-cas.git"
},
"django-crispy-forms"
:
{
"hashes"
:
[
"sha256:b29a9a671194e3a482891f319f69da81e30ae81c075f6e37adb14a83ba2c409b"
,
"sha256:d37fe72eb550b41ba651c06293fb861d5a9e6e3ada23304718858cd6250d258d"
],
"index"
:
"pypi"
,
"version"
:
"==1.7.0"
},
"django-qrcode"
:
{
"editable"
:
true
,
"git"
:
"https://github.com/dhaynespls/django-qrcode.git"
},
"django-ratelimit"
:
{
"hashes"
:
[
"sha256:a74f23069291441792f960b6ac662579560a7c959e2e8444ecf140bf1a9041c4"
,
"sha256:cd3fdaadd335147df20bd00a226190ea21cea52f56b867b0f7ede7beaa3bd1e1"
],
"index"
:
"pypi"
,
"version"
:
"==1.0.1"
},
"django-redis-cache"
:
{
"hashes"
:
[
"sha256:2b4e3510bbcaf3d331975717afd6f15a36fbaf7622504599d2727dc99f90c64d"
],
"index"
:
"pypi"
,
"version"
:
"==1.7.1"
},
"hashids"
:
{
"hashes"
:
[
"sha256:6539b892a426e75747a9c0ad69409e9566f9c21b79310fc3424b5b6726f28da6"
],
"index"
:
"pypi"
,
"version"
:
"==1.2.0"
},
"mysqlclient"
:
{
"hashes"
:
[
"sha256:1e85e48b167e2af3bb08f273fdbd1ad6401cbe75057fa6513f97387dc7b282dc"
,
"sha256:2d9ec33de39f4d9c64ad7322ede0521d85829ce36a76f9dd3d6ab76a9c8648e5"
,
"sha256:371df79d000af56b4e540b7ce2120d1c9afb04b751bfce25a1eb609c50fd10ff"
,
"sha256:b3b1a7e4468180afb79289b54069d9499242946a4cedf3928cbf6b2a13800016"
,
"sha256:d56e379c03efad746e84705cbb97401f60d1f98b05e11a27f2d9c2d043936974"
],
"index"
:
"pypi"
,
"version"
:
"==1.3.12"
},
"pytz"
:
{
"hashes"
:
[
"sha256:65ae0c8101309c45772196b21b74c46b2e5d11b6275c45d251b150d5da334555"
,
"sha256:c06425302f2cf668f1bba7a0a03f3c1d34d4ebeef2c72003da308b3947c7f749"
],
"version"
:
"==2018.4"
},
"redis"
:
{
"hashes"
:
[
"sha256:8a1900a9f2a0a44ecf6e8b5eb3e967a9909dfed219ad66df094f27f7d6f330fb"
,
"sha256:a22ca993cea2962dbb588f9f30d0015ac4afcc45bee27d3978c0dbe9e97c6c0f"
],
"version"
:
"==2.10.6"
}
},
"develop"
:
{
"astroid"
:
{
"hashes"
:
[
"sha256:032f6e09161e96f417ea7fad46d3fac7a9019c775f202182c22df0e4f714cb1c"
,
"sha256:dea42ae6e0b789b543f728ddae7ddb6740ba33a49fb52c4a4d9cb7bb4aa6ec09"
],
"version"
:
"==1.6.4"
},
"autopep8"
:
{
"hashes"
:
[
"sha256:2284d4ae2052fedb9f466c09728e30d2e231cfded5ffd7b1a20c34123fdc4ba4"
],
"index"
:
"pypi"
,
"version"
:
"==1.3.5"
},
"isort"
:
{
"hashes"
:
[
"sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af"
,
"sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8"
,
"sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497"
],
"version"
:
"==4.3.4"
},
"lazy-object-proxy"
:
{
"hashes"
:
[
"sha256:0ce34342b419bd8f018e6666bfef729aec3edf62345a53b537a4dcc115746a33"
,
"sha256:1b668120716eb7ee21d8a38815e5eb3bb8211117d9a90b0f8e21722c0758cc39"
,
"sha256:209615b0fe4624d79e50220ce3310ca1a9445fd8e6d3572a896e7f9146bbf019"
,
"sha256:27bf62cb2b1a2068d443ff7097ee33393f8483b570b475db8ebf7e1cba64f088"
,
"sha256:27ea6fd1c02dcc78172a82fc37fcc0992a94e4cecf53cb6d73f11749825bd98b"
,
"sha256:2c1b21b44ac9beb0fc848d3993924147ba45c4ebc24be19825e57aabbe74a99e"
,
"sha256:2df72ab12046a3496a92476020a1a0abf78b2a7db9ff4dc2036b8dd980203ae6"
,
"sha256:320ffd3de9699d3892048baee45ebfbbf9388a7d65d832d7e580243ade426d2b"
,
"sha256:50e3b9a464d5d08cc5227413db0d1c4707b6172e4d4d915c1c70e4de0bbff1f5"
,
"sha256:5276db7ff62bb7b52f77f1f51ed58850e315154249aceb42e7f4c611f0f847ff"
,
"sha256:61a6cf00dcb1a7f0c773ed4acc509cb636af2d6337a08f362413c76b2b47a8dd"
,
"sha256:6ae6c4cb59f199d8827c5a07546b2ab7e85d262acaccaacd49b62f53f7c456f7"
,
"sha256:7661d401d60d8bf15bb5da39e4dd72f5d764c5aff5a86ef52a042506e3e970ff"
,
"sha256:7bd527f36a605c914efca5d3d014170b2cb184723e423d26b1fb2fd9108e264d"
,
"sha256:7cb54db3535c8686ea12e9535eb087d32421184eacc6939ef15ef50f83a5e7e2"
,
"sha256:7f3a2d740291f7f2c111d86a1c4851b70fb000a6c8883a59660d95ad57b9df35"
,
"sha256:81304b7d8e9c824d058087dcb89144842c8e0dea6d281c031f59f0acf66963d4"
,
"sha256:933947e8b4fbe617a51528b09851685138b49d511af0b6c0da2539115d6d4514"
,
"sha256:94223d7f060301b3a8c09c9b3bc3294b56b2188e7d8179c762a1cda72c979252"
,
"sha256:ab3ca49afcb47058393b0122428358d2fbe0408cf99f1b58b295cfeb4ed39109"
,
"sha256:bd6292f565ca46dee4e737ebcc20742e3b5be2b01556dafe169f6c65d088875f"
,
"sha256:cb924aa3e4a3fb644d0c463cad5bc2572649a6a3f68a7f8e4fbe44aaa6d77e4c"
,
"sha256:d0fc7a286feac9077ec52a927fc9fe8fe2fabab95426722be4c953c9a8bede92"
,
"sha256:ddc34786490a6e4ec0a855d401034cbd1242ef186c20d79d2166d6a4bd449577"
,
"sha256:e34b155e36fa9da7e1b7c738ed7767fc9491a62ec6af70fe9da4a057759edc2d"
,
"sha256:e5b9e8f6bda48460b7b143c3821b21b452cb3a835e6bbd5dd33aa0c8d3f5137d"
,
"sha256:e81ebf6c5ee9684be8f2c87563880f93eedd56dd2b6146d8a725b50b7e5adb0f"
,
"sha256:eb91be369f945f10d3a49f5f9be8b3d0b93a4c2be8f8a5b83b0571b8123e0a7a"
,
"sha256:f460d1ceb0e4a5dcb2a652db0904224f367c9b3c1470d5a7683c0480e582468b"
],
"version"
:
"==1.3.1"
},
"mccabe"
:
{
"hashes"
:
[
"sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"
,
"sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
],
"version"
:
"==0.6.1"
},
"pycodestyle"
:
{
"hashes"
:
[
"sha256:74abc4e221d393ea5ce1f129ea6903209940c1ecd29e002e8c6933c2b21026e0"
,
"sha256:cbc619d09254895b0d12c2c691e237b2e91e9b2ecf5e84c26b35400f93dcfb83"
,
"sha256:cbfca99bd594a10f674d0cd97a3d802a1fdef635d4361e1a2658de47ed261e3a"
],
"version"
:
"==2.4.0"
},
"pylint"
:
{
"hashes"
:
[
"sha256:aa519865f8890a5905fa34924fed0f3bfc7d84fc9f9142c16dac52ffecd25a39"
,
"sha256:c353d8225195b37cc3aef18248b8f3fe94c5a6a95affaf885ae21a24ca31d8eb"
],
"index"
:
"pypi"
,
"version"
:
"==1.9.1"
},
"pylint-django"
:
{
"hashes"
:
[
"sha256:8818c2034df5fad2dc4bd029a91f088a6a3d8eaad5070c19b32ba3fef04b25dc"
,
"sha256:ca68fe67837956d408600bdd6c4e9ef6cccb48f058a6640eed729845a25912b0"
],
"index"
:
"pypi"
,
"version"
:
"==0.11"
},
"pylint-plugin-utils"
:
{
"hashes"
:
[
"sha256:053ade7c76f83242225b49d47624d9ecb803c60347e2c5127e97a19bf0c9f95e"
],
"version"
:
"==0.2.6"
},
"six"
:
{
"hashes"
:
[
"sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9"
,
"sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"
],
"version"
:
"==1.11.0"
},
"wrapt"
:
{
"hashes"
:
[
"sha256:d4d560d479f2c21e1b5443bbd15fe7ec4b37fe7e53d335d3b9b0a7b1226fe3c6"
],
"version"
:
"==1.10.11"
}
}
}
go/go/forms.py
View file @
6520581f
...
...
@@ -127,49 +127,49 @@ class URLForm(ModelForm):
# The main "layout" defined
self
.
helper
.
layout
=
Layout
(
Fieldset
(
''
,
#######################
Accordion
(
# Step 1: Long URL
AccordionGroup
(
'Step 1: Long URL'
,
Div
(
HTML
(
"""
#######################
Accordion
(
# Step 1: Long URL
AccordionGroup
(
'Step 1: Long URL'
,
Div
(
HTML
(
"""
<h4>Paste the URL you would like to shorten:</h4>
<br />"""
),
'target'
,
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
),
# Step 2: Short URL
AccordionGroup
(
'Step 2: Short URL'
,
Div
(
HTML
(
"""
'target'
,
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
),
# Step 2: Short URL
AccordionGroup
(
'Step 2: Short URL'
,
Div
(
HTML
(
"""
<h4>Create a custom Go address:</h4>
<br />"""
),
PrependedText
(
'short'
,
'https://go.gmu.edu/'
,
template
=
'crispy/customPrepended.html'
),
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
,),
# Step 3: Expiration
AccordionGroup
(
'Step 3: URL Expiration'
,
Div
(
HTML
(
"""
PrependedText
(
'short'
,
'https://go.gmu.edu/'
,
template
=
'crispy/customPrepended.html'
),
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
,),
# Step 3: Expiration
AccordionGroup
(
'Step 3: URL Expiration'
,
Div
(
HTML
(
"""
<h4>Set when you would like your Go address to expire:</h4>
<br />"""
),
'expires'
,
Field
(
'expires_custom'
),
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
),
# FIN
template
=
'crispy/accordian.html'
),
#######################
HTML
(
"""
'expires'
,
Field
(
'expires_custom'
),
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
),
# FIN
template
=
'crispy/accordian.html'
),
#######################
HTML
(
"""
<br />"""
),
StrictButton
(
'Shorten'
,
css_class
=
"btn btn-primary btn-md col-md-4"
,
type
=
'submit'
)))
StrictButton
(
'Shorten'
,
css_class
=
"btn btn-primary btn-md col-md-4"
,
type
=
'submit'
)))
class
Meta
:
"""
...
...
@@ -180,6 +180,7 @@ class URLForm(ModelForm):
# what attributes are included
fields
=
[
'target'
]
class
EditForm
(
URLForm
):
"""
The form that is used in editing URLs.
...
...
@@ -187,6 +188,7 @@ class EditForm(URLForm):
A modification of the URL creation form... now for editing URLs. Inherit
custom form fields for DRY purposes.
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
"""
On initialization of the form, crispy forms renders this layout.
...
...
@@ -206,49 +208,50 @@ class EditForm(URLForm):
# The main "layout" defined
self
.
helper
.
layout
=
Layout
(
Fieldset
(
''
,
#######################
Accordion
(
# Step 1: Long URL
AccordionGroup
(
'Step 1: Long URL'
,
Div
(
HTML
(
"""
#######################
Accordion
(
# Step 1: Long URL
AccordionGroup
(
'Step 1: Long URL'
,
Div
(
HTML
(
"""
<h4>Modify the URL you would like to shorten:</h4>
<br />"""
),
'target'
,
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
),
# Step 2: Short URL
AccordionGroup
(
'Step 2: Short URL'
,
Div
(
HTML
(
"""
'target'
,
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
),
# Step 2: Short URL
AccordionGroup
(
'Step 2: Short URL'
,
Div
(
HTML
(
"""
<h4>Modify the Go address:</h4>
<br />"""
),
PrependedText
(
'short'
,
'https://go.gmu.edu/'
,
template
=
'crispy/customPrepended.html'
),
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
,),
# Step 3: Expiration
AccordionGroup
(
'Step 3: URL Expiration'
,
Div
(
HTML
(
"""
PrependedText
(
'short'
,
'https://go.gmu.edu/'
,
template
=
'crispy/customPrepended.html'
),
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
,),
# Step 3: Expiration
AccordionGroup
(
'Step 3: URL Expiration'
,
Div
(
HTML
(
"""
<h4>Modify the expiration date:</h4>
<br />"""
),
'expires'
,
Field
(
'expires_custom'
,
template
=
"crispy/customDateField.html"
),
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
),
# FIN
template
=
'crispy/accordian.html'
),
#######################
HTML
(
"""
'expires'
,
Field
(
'expires_custom'
,
template
=
"crispy/customDateField.html"
),
style
=
"background: rgb(#F6F6F6);"
),
active
=
True
,
template
=
'crispy/accordian-group.html'
),
# FIN
template
=
'crispy/accordian.html'
),
#######################
HTML
(
"""
<br />"""
),
StrictButton
(
'Submit Changes'
,
css_class
=
"btn btn-primary btn-md col-md-4"
,
type
=
'submit'
)))
StrictButton
(
'Submit Changes'
,
css_class
=
"btn btn-primary btn-md col-md-4"
,
type
=
'submit'
)))
class
Meta
(
URLForm
.
Meta
):
"""
...
...
@@ -257,6 +260,7 @@ class EditForm(URLForm):
# 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
...
...
@@ -311,18 +315,19 @@ class SignupForm(ModelForm):
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'
)))
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
:
"""
...
...
go/go/models.py
View file @
6520581f
...
...
@@ -23,6 +23,7 @@ HASHIDS = Hashids(
salt
=
"srct.gmu.edu"
,
alphabet
=
(
string
.
ascii_lowercase
+
string
.
digits
)
)
class
RegisteredUser
(
models
.
Model
):
"""
This is simply a wrapper model for the User model which, if an object
...
...
@@ -63,6 +64,7 @@ class RegisteredUser(models.Model):
self
.
user
,
self
.
approved
)
@
receiver
(
post_save
,
sender
=
User
)
def
handle_regUser_creation
(
sender
,
instance
,
created
,
**
kwargs
):
"""
...
...
@@ -72,6 +74,7 @@ def handle_regUser_creation(sender, instance, created, **kwargs):
if
created
:
RegisteredUser
.
objects
.
create
(
user
=
instance
)
class
URL
(
models
.
Model
):
"""
This model represents a stored URL redirection rule. Each URL has an
...
...
go/go/views.py
View file @
6520581f
...
...
@@ -25,6 +25,7 @@ from ratelimit.decorators import ratelimit
from
.forms
import
SignupForm
,
URLForm
,
EditForm
from
.models
import
URL
,
RegisteredUser
def
index
(
request
):
"""
If a user is logged in, this view displays all the information about all
...
...
@@ -69,6 +70,7 @@ def index(request):
'sort_methods'
:
SORT_METHODS
})
@
login_required
def
new_link
(
request
):
"""
...
...
@@ -120,6 +122,7 @@ def new_link(request):
'form'
:
url_form
,
})
@
login_required
def
my_links
(
request
):
"""
...
...
@@ -135,6 +138,8 @@ def my_links(request):
return
index
(
request
)
# Rate limits are completely arbitrary
@
ratelimit
(
key
=
'user'
,
rate
=
'3/m'
,
method
=
'POST'
,
block
=
True
)
@
ratelimit
(
key
=
'user'
,
rate
=
'25/d'
,
method
=
'POST'
,
block
=
True
)
def
post
(
request
,
url_form
):
...
...
@@ -189,6 +194,7 @@ def post(request, url_form):
url
.
save
()
return
url
def
view
(
request
,
short
):
"""
This view allows the user to "view details" about a URL. Note that they
...
...
@@ -207,6 +213,7 @@ def view(request, short):
'domain'
:
domain
,
})
@
login_required
def
edit
(
request
,
short
):
"""
...
...
@@ -222,7 +229,6 @@ def edit(request, short):
else
:
return
render
(
request
,
'not_registered.html'
)
# Get the URL that is going to be edited
url
=
get_object_or_404
(
URL
,
short__iexact
=
short
)
...
...
@@ -234,7 +240,8 @@ def edit(request, short):
if
request
.
method
==
'POST'
:
# Now we initialize the form again but this time we have the POST
# request
url_form
=
EditForm
(
request
.
POST
,
host
=
request
.
META
.
get
(
'HTTP_HOST'
))
url_form
=
EditForm
(
request
.
POST
,
host
=
request
.
META
.
get
(
'HTTP_HOST'
))
# Make a copy of the old URL
copy
=
url
...
...
@@ -269,7 +276,8 @@ def edit(request, short):
# The short was not edited and thus, we can directly edit the url
else
:
if
url_form
.
cleaned_data
.
get
(
'target'
).
strip
()
!=
copy
.
target
:
copy
.
target
=
url_form
.
cleaned_data
.
get
(
'target'
).
strip
()
copy
.
target
=
url_form
.
cleaned_data
.
get
(
'target'
).
strip
()
copy
.
save
()
# Grab the expiration field value. It's currently an unsable
...
...
@@ -285,7 +293,8 @@ def edit(request, short):
elif
expires
==
URLForm
.
MONTH
:
edited_expires
=
timezone
.
now
()
+
timedelta
(
weeks
=
3
)
elif
expires
==
URLForm
.
CUSTOM
:
edited_expires
=
url_form
.
cleaned_data
.
get
(
'expires_custom'
)
edited_expires
=
url_form
.
cleaned_data
.
get
(
'expires_custom'
)
else
:
pass
# leave the field NULL
...
...
@@ -352,6 +361,7 @@ def delete(request, short):
# do not allow them to delete
raise
PermissionDenied
()
@
login_required
def
signup
(
request
):
"""
...
...
@@ -460,6 +470,7 @@ def signup(request):
'registered'
:
False
,
})
def
redirection
(
request
,
short
):
"""
This view redirects a user based on the short URL they requested.
...
...
@@ -493,6 +504,7 @@ def redirection(request, short):
url
.
save
()
return
redirect
(
url
.
target
)
def
staff_member_required
(
view_func
,
redirect_field_name
=
REDIRECT_FIELD_NAME
,
login_url
=
'/'
):
"""
Decorator function for views that checks that the user is logged in and is
...
...
@@ -504,6 +516,7 @@ def staff_member_required(view_func, redirect_field_name=REDIRECT_FIELD_NAME, lo
redirect_field_name
=
redirect_field_name
)(
view_func
)
@
staff_member_required
def
useradmin
(
request
):
"""
...
...
@@ -518,7 +531,8 @@ def useradmin(request):
# If we're approving users
if
'_approve'
in
request
.
POST
:
for
name
in
userlist
:
to_approve
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
to_approve
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
to_approve
.
approved
=
True
to_approve
.
save
()
...
...
@@ -542,7 +556,8 @@ def useradmin(request):
# If we're denying users
elif
'_deny'
in
request
.
POST
:
for
name
in
userlist
:
to_deny
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
to_deny
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
if
settings
.
EMAIL_HOST
and
settings
.
EMAIL_PORT
:
user_mail
=
to_deny
.
user
.
username
+
settings
.
EMAIL_DOMAIN
# Send an email letting them know they are denied
...
...
@@ -567,7 +582,8 @@ def useradmin(request):
# If we're blocking users
elif
'_block'
in
request
.
POST
:
for
name
in
userlist
:
to_block
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
to_block
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
if
settings
.
EMAIL_HOST
and
settings
.
EMAIL_PORT
:
user_mail
=
to_block
.
user
.
username
+
settings
.
EMAIL_DOMAIN
send_mail
(
...
...
@@ -592,7 +608,8 @@ def useradmin(request):
# If we're un-blocking users
elif
'_unblock'
in
request
.
POST
:
for
name
in
userlist
:
to_un_block
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
to_un_block
=
RegisteredUser
.
objects
.
get
(
user__username__exact
=
name
)
if
settings
.
EMAIL_HOST
and
settings
.
EMAIL_PORT
: