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
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
17b4e24a
Commit
17b4e24a
authored
Dec 29, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small club update
parent
2f2d5292
Pipeline
#660
failed with stage
in 3 minutes and 23 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
club/migrations/0006_auto_20161229_0040.py
club/migrations/0006_auto_20161229_0040.py
+20
-0
club/models.py
club/models.py
+1
-6
club/views.py
club/views.py
+4
-1
No files found.
club/migrations/0006_auto_20161229_0040.py
0 → 100644
View file @
17b4e24a
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.utils.timezone
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'club'
,
'0005_auto_20161120_1149'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'membership'
,
name
=
'start_date'
,
field
=
models
.
DateField
(
verbose_name
=
'start date'
,
default
=
django
.
utils
.
timezone
.
now
),
),
]
club/models.py
View file @
17b4e24a
...
...
@@ -143,7 +143,7 @@ class Membership(models.Model):
"""
user
=
models
.
ForeignKey
(
User
,
verbose_name
=
_
(
'user'
),
related_name
=
"memberships"
,
null
=
False
,
blank
=
False
)
club
=
models
.
ForeignKey
(
Club
,
verbose_name
=
_
(
'club'
),
related_name
=
"members"
,
null
=
False
,
blank
=
False
)
start_date
=
models
.
DateField
(
_
(
'start date'
))
start_date
=
models
.
DateField
(
_
(
'start date'
)
,
default
=
timezone
.
now
)
end_date
=
models
.
DateField
(
_
(
'end date'
),
null
=
True
,
blank
=
True
)
role
=
models
.
IntegerField
(
_
(
'role'
),
choices
=
sorted
(
settings
.
SITH_CLUB_ROLES
.
items
()),
default
=
sorted
(
settings
.
SITH_CLUB_ROLES
.
items
())[
0
][
0
])
...
...
@@ -156,11 +156,6 @@ class Membership(models.Model):
if
Membership
.
objects
.
filter
(
user
=
self
.
user
).
filter
(
club
=
self
.
club
).
filter
(
end_date
=
None
).
exists
():
raise
ValidationError
(
_
(
'User is already member of that club'
))
def
save
(
self
,
*
args
,
**
kwargs
):
if
not
self
.
id
:
self
.
start_date
=
timezone
.
now
()
return
super
(
Membership
,
self
).
save
(
*
args
,
**
kwargs
)
def
__str__
(
self
):
return
self
.
club
.
name
+
' - '
+
self
.
user
.
username
+
' - '
+
str
(
settings
.
SITH_CLUB_ROLES
[
self
.
role
])
+
str
(
" - "
+
str
(
_
(
'past member'
))
if
self
.
end_date
is
not
None
else
""
...
...
club/views.py
View file @
17b4e24a
...
...
@@ -99,7 +99,10 @@ class ClubMemberForm(forms.ModelForm):
required_css_class
=
'required'
class
Meta
:
model
=
Membership
fields
=
[
'user'
,
'role'
,
'description'
]
fields
=
[
'user'
,
'role'
,
'start_date'
,
'description'
]
widgets
=
{
'start_date'
:
SelectDate
}
user
=
AutoCompleteSelectField
(
'users'
,
required
=
True
,
label
=
_
(
"Select user"
),
help_text
=
None
)
def
save
(
self
,
*
args
,
**
kwargs
):
...
...
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