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
e4b766d1
authored
Nov 11, 2017
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add network limit to profile
parent
132b5fe8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
1 deletions
+30
-1
circle/dashboard/forms.py
+8
-1
circle/dashboard/migrations/0007_profile_network_limit.py
+20
-0
circle/dashboard/models.py
+2
-0
No files found.
circle/dashboard/forms.py
View file @
e4b766d1
...
...
@@ -1310,6 +1310,9 @@ class UserEditForm(forms.ModelForm):
instance_limit
=
forms
.
IntegerField
(
label
=
_
(
'Instance limit'
),
min_value
=
0
,
widget
=
NumberInput
)
network_limit
=
forms
.
IntegerField
(
label
=
_
(
'Virtual network limit'
),
min_value
=
0
,
widget
=
NumberInput
)
two_factor_secret
=
forms
.
CharField
(
label
=
_
(
'Two-factor authentication secret'
),
help_text
=
_
(
"Remove the secret key to disable two-factor "
...
...
@@ -1319,18 +1322,22 @@ class UserEditForm(forms.ModelForm):
super
(
UserEditForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
"instance_limit"
]
.
initial
=
(
self
.
instance
.
profile
.
instance_limit
)
self
.
fields
[
"network_limit"
]
.
initial
=
(
self
.
instance
.
profile
.
network_limit
)
self
.
fields
[
"two_factor_secret"
]
.
initial
=
(
self
.
instance
.
profile
.
two_factor_secret
)
class
Meta
:
model
=
User
fields
=
(
'email'
,
'first_name'
,
'last_name'
,
'instance_limit'
,
'
is_active'
,
"two_factor_secret"
,
)
'
network_limit'
,
'is_active'
,
'two_factor_secret'
,
)
def
save
(
self
,
commit
=
True
):
user
=
super
(
UserEditForm
,
self
)
.
save
()
user
.
profile
.
instance_limit
=
(
self
.
cleaned_data
[
'instance_limit'
]
or
None
)
user
.
profile
.
network_limit
=
(
self
.
cleaned_data
[
'network_limit'
]
or
None
)
user
.
profile
.
two_factor_secret
=
(
self
.
cleaned_data
[
'two_factor_secret'
]
or
None
)
user
.
profile
.
save
()
...
...
circle/dashboard/migrations/0007_profile_network_limit.py
0 → 100644
View file @
e4b766d1
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-10 00:41
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'dashboard'
,
'0006_auto_20170707_1909'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'profile'
,
name
=
'network_limit'
,
field
=
models
.
IntegerField
(
default
=
2
,
verbose_name
=
b
'Virtual network limit'
),
),
]
circle/dashboard/models.py
View file @
e4b766d1
...
...
@@ -178,6 +178,8 @@ class Profile(Model):
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
)
network_limit
=
IntegerField
(
default
=
2
,
verbose_name
=
"Virtual network limit"
)
use_gravatar
=
BooleanField
(
verbose_name
=
_
(
"Use Gravatar"
),
default
=
True
,
help_text
=
_
(
"Whether to use email address as Gravatar profile image"
))
...
...
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