Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
814e1e3c
Commit
814e1e3c
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
common functionality extracted to separate class
parent
858fbb7b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!117
Resolve "extend worker class"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/forms/contact_attempt_forms.py
+12
-18
12 additions, 18 deletions
smash/web/forms/contact_attempt_forms.py
with
12 additions
and
18 deletions
smash/web/forms/contact_attempt_forms.py
+
12
−
18
View file @
814e1e3c
...
...
@@ -2,19 +2,14 @@ from django import forms
from
django.forms
import
ModelForm
from
web.forms.forms
import
DATETIMEPICKER_DATE_ATTRS
from
web.models
import
ContactAttempt
,
Worker
class
ContactAttempt
Add
Form
(
ModelForm
):
class
ContactAttemptForm
(
ModelForm
):
datetime_when
=
forms
.
DateTimeField
(
label
=
'
When? (YYYY-MM-DD HH:MM)
'
,
widget
=
forms
.
DateTimeInput
(
DATETIMEPICKER_DATE_ATTRS
)
)
class
Meta
:
model
=
ContactAttempt
fields
=
'
__all__
'
def
__init__
(
self
,
*
args
,
**
kwargs
):
user
=
kwargs
.
pop
(
'
user
'
,
None
)
if
user
is
None
:
...
...
@@ -22,6 +17,15 @@ class ContactAttemptAddForm(ModelForm):
self
.
user
=
Worker
.
get_by_user
(
user
)
if
self
.
user
is
None
:
raise
TypeError
(
"
Worker not defined for:
"
+
user
.
username
)
super
(
ContactAttemptForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
class
ContactAttemptAddForm
(
ContactAttemptForm
):
class
Meta
:
model
=
ContactAttempt
fields
=
'
__all__
'
def
__init__
(
self
,
*
args
,
**
kwargs
):
subject
=
kwargs
.
pop
(
'
subject
'
,
None
)
super
(
ContactAttemptAddForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'
subject
'
].
initial
=
subject
.
id
...
...
@@ -29,21 +33,11 @@ class ContactAttemptAddForm(ModelForm):
self
.
fields
[
'
worker
'
].
initial
=
self
.
user
class
ContactAttemptEditForm
(
ModelForm
):
datetime_when
=
forms
.
DateTimeField
(
label
=
'
When? (YYYY-MM-DD HH:MM)
'
,
widget
=
forms
.
DateTimeInput
(
DATETIMEPICKER_DATE_ATTRS
)
)
class
ContactAttemptEditForm
(
ContactAttemptForm
):
class
Meta
:
model
=
ContactAttempt
fields
=
'
__all__
'
def
__init__
(
self
,
*
args
,
**
kwargs
):
user
=
kwargs
.
pop
(
'
user
'
,
None
)
if
user
is
None
:
raise
TypeError
(
"
User not defined
"
)
self
.
user
=
Worker
.
get_by_user
(
user
)
if
self
.
user
is
None
:
raise
TypeError
(
"
Worker not defined for:
"
+
user
.
username
)
super
(
ContactAttemptEditForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'
subject
'
].
disabled
=
True
\ No newline at end of file
self
.
fields
[
'
subject
'
].
disabled
=
True
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment