mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-24 20:33:11 +00:00
[Printer] Refactor form et url
This commit is contained in:
parent
0a1ee79414
commit
bab1ca8f66
2 changed files with 8 additions and 39 deletions
|
@ -10,6 +10,7 @@ from django.forms import (
|
||||||
Form,
|
Form,
|
||||||
ModelForm,
|
ModelForm,
|
||||||
)
|
)
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
|
@ -27,12 +28,12 @@ class JobWithOptionsForm(FormRevMixin, ModelForm):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
self.user = kwargs.pop('user')
|
self.user = kwargs.pop('user')
|
||||||
super(JobWithOptionsForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(JobWithOptionsForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
self.fields['printAs'].label = 'Print As'
|
if not self.user.adherent.club_members.all():
|
||||||
self.fields['printAs'].empty_label = self.user.pseudo
|
self.fields.pop('printAs')
|
||||||
self.fields['printAs'].queryset = self.user.adherent.club_members.all()
|
else:
|
||||||
self.fields['disposition'].label = 'disposition'
|
self.fields['printAs'].label = _('Print As')
|
||||||
self.fields['color'].label = 'color'
|
self.fields['printAs'].empty_label = self.user.pseudo
|
||||||
self.fields['count'].label = 'count'
|
self.fields['printAs'].queryset = self.user.adherent.club_members.all()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = JobWithOptions
|
model = JobWithOptions
|
||||||
|
@ -46,34 +47,3 @@ class JobWithOptionsForm(FormRevMixin, ModelForm):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class PrintForm(FormRevMixin, ModelForm):
|
|
||||||
|
|
||||||
jid = forms.IntegerField(widget=forms.HiddenInput())
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
|
||||||
self.user = kwargs.pop('user')
|
|
||||||
super(PrintForm, self).__init__(*args, prefix=prefix, **kwargs)
|
|
||||||
self.fields['printAs'].label = 'Print As'
|
|
||||||
self.fields['printAs'].empty_label = self.user.pseudo
|
|
||||||
self.fields['printAs'].queryset = self.user.adherent.club_members.all()
|
|
||||||
self.fields['disposition'].label = 'disposition'
|
|
||||||
self.fields['color'].label = 'color'
|
|
||||||
self.fields['count'].label = 'count'
|
|
||||||
|
|
||||||
self.fields['jid'].widget.attrs['readonly'] = True
|
|
||||||
self.fields['printAs'].widget.attrs['readonly'] = True
|
|
||||||
self.fields['filename'].widget.attrs['readonly'] = True
|
|
||||||
self.fields['price'].widget.attrs['readonly'] = True
|
|
||||||
self.fields['pages'].widget.attrs['readonly'] = True
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = JobWithOptions
|
|
||||||
exclude = [
|
|
||||||
'user',
|
|
||||||
'starttime',
|
|
||||||
'endtime',
|
|
||||||
'status',
|
|
||||||
'file',
|
|
||||||
'paid',
|
|
||||||
]
|
|
||||||
|
|
|
@ -13,6 +13,5 @@ from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^new_job/$', views.new_job, name="new-job"),
|
url(r'^new_job/$', views.new_job, name="new-job"),
|
||||||
url(r'^success/$', views.success, name="success"),
|
url(r'^print_job/(?P<printoperationid>[0-9]+)$', views.print_job, name='print-job')
|
||||||
url(r'^payment/$', views.payment, name="payment"),
|
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue