Skip to content
Snippets Groups Projects

Resolve "Direct printer select in issue form"

Merged Jonathan Weth requested to merge 12-direct-printer-select-in-issue-form into main
2 files
+ 36
0
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 14
0
@@ -9,6 +9,13 @@ from aleksis.apps.kort.models import Card, CardLayout, CardLayoutMediaFile, Card
class CardForm(forms.ModelForm):
printer = forms.ModelChoiceField(
queryset=None,
label=_("Card Printer"),
help_text=_("Select a printer to directly print the newly issued card."),
required=False,
)
class Meta:
model = Card
fields = ["person", "valid_until", "layout"]
@@ -28,6 +35,13 @@ class CardForm(forms.ModelForm):
super().__init__(*args, **kwargs)
self.fields["layout"].required = True
layouts = CardLayout.objects.all()
if layouts.count() == 1:
self.fields["layout"].initial = layouts.first()
printers = CardPrinter.objects.all()
self.fields["printer"].queryset = printers
class CardPrinterForm(forms.ModelForm):
layout = Layout(
Loading