From a4735e4fb38267d1f4e08b8506c39fffdfbf978f Mon Sep 17 00:00:00 2001 From: Mika dabelza abi <mika.dabelza@ui.ac.id> Date: Thu, 4 Jun 2020 09:58:32 +0700 Subject: [PATCH] Coldfix pbi 3 unggah materi restriksi --- app/forms.py | 10 +++++++++- app/templates/unggah.html | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/forms.py b/app/forms.py index a9fb6bf..e303249 100644 --- a/app/forms.py +++ b/app/forms.py @@ -1,10 +1,14 @@ from django import forms -from app.models import Materi +from app.models import Materi,Category from authentication.models import User class UploadMateriForm(forms.ModelForm): + + categories = forms.ModelMultipleChoiceField(queryset=Category.objects.all(),widget=forms.CheckboxSelectMultiple(attrs={'style' : 'column-count:2'}),required=True) + #categories.widget.attrs["style"] = "column-count:2" + class Meta: model = Materi fields = ["title", "author", "publisher", @@ -13,7 +17,11 @@ class UploadMateriForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(UploadMateriForm, self).__init__(*args, **kwargs) for field_name, field in self.fields.items(): + if (field_name == "categories"): + continue field.widget.attrs["class"] = "form-control" + self.fields['categories'].widget.attrs.update({'class' : "native"}) + class SuntingProfilForm(forms.ModelForm): diff --git a/app/templates/unggah.html b/app/templates/unggah.html index df06d7a..d9154e9 100644 --- a/app/templates/unggah.html +++ b/app/templates/unggah.html @@ -3,6 +3,23 @@ <!DOCTYPE html> <html lang="en"> +<style> + ul{margin:0; padding:0;} + + .native { + -webkit-column-width: 200px; + -moz-column-width: 200px; + -o-column-width: 200px; + -ms-column-width: 200px; + column-width: 200px; + + -webkit-column-rule-style: solid; + -moz-column-rule-style: solid; + -o-column-rule-style: solid; + -ms-column-rule-style: solid; + column-rule-style: solid; + } +</style> <head> <meta charset="utf-8"> -- GitLab