Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e1db1dc1
authored
Feb 06, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: Temporary user quota
Closes #44
parent
94d421a9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
circle/dashboard/migrations/0003_auto__add_field_profile_instance_limit.py
+0
-0
circle/dashboard/models.py
+5
-3
circle/dashboard/views.py
+16
-1
No files found.
circle/dashboard/migrations/0003_auto__add_field_profile_instance_limit.py
0 → 100644
View file @
e1db1dc1
This diff is collapsed.
Click to expand it.
circle/dashboard/models.py
View file @
e1db1dc1
...
...
@@ -2,14 +2,16 @@ from logging import getLogger
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.db.models
import
Model
,
ForeignKey
,
OneToOneField
,
CharField
from
django.db.models
import
(
Model
,
ForeignKey
,
OneToOneField
,
CharField
,
IntegerField
)
from
django.utils.translation
import
ugettext_lazy
as
_
from
vm.models
import
Instance
logger
=
getLogger
(
__name__
)
class
Favourite
(
Model
):
instance
=
ForeignKey
(
Instance
)
user
=
ForeignKey
(
User
)
...
...
@@ -24,6 +26,7 @@ class Profile(Model):
org_id
=
CharField
(
# may be populated from eduPersonOrgId field
unique
=
True
,
blank
=
True
,
null
=
True
,
max_length
=
64
,
help_text
=
_
(
'Unique identifier of the person, e.g. a student number.'
))
instance_limit
=
IntegerField
(
default
=
5
)
if
hasattr
(
settings
,
'SAML_ORG_ID_ATTRIBUTE'
):
...
...
@@ -51,7 +54,6 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
value
,
sender
.
username
)
return
False
pre_user_save
.
connect
(
save_org_id
,
weak
=
False
)
else
:
logger
.
debug
(
"Do not register save_org_id to djangosaml2 pre_user_save"
)
circle/dashboard/views.py
View file @
e1db1dc1
...
...
@@ -683,7 +683,6 @@ class VmCreate(LoginRequiredMixin, TemplateView):
})
return
self
.
render_to_response
(
context
)
# TODO handle not ajax posts
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
self
.
form_class
(
request
.
POST
)
if
not
form
.
is_valid
():
...
...
@@ -691,6 +690,22 @@ class VmCreate(LoginRequiredMixin, TemplateView):
post
=
form
.
cleaned_data
user
=
request
.
user
try
:
limit
=
user
.
profile
.
instance_limit
except
Exception
as
e
:
logger
.
debug
(
'No profile or instance limit:
%
s'
,
e
)
else
:
current
=
Instance
.
active
.
filter
(
owner
=
user
)
.
count
()
logger
.
debug
(
'current use:
%
d, limit:
%
d'
,
current
,
limit
)
if
limit
<
current
:
messages
.
error
(
request
,
_
(
'Instance limit (
%
d) exceeded.'
)
%
limit
)
if
request
.
is_ajax
():
return
HttpResponse
(
json
.
dumps
({
'redirect'
:
'/'
}),
content_type
=
"application/json"
)
else
:
return
redirect
(
'/'
)
template
=
post
[
'template'
]
if
not
template
.
has_level
(
request
.
user
,
'user'
):
raise
PermissionDenied
()
...
...
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