class ProjectForm(forms.Form): category = forms.ModelChoiceField(queryset=NewsCategory.objects.all(), empty_label="--Select Category--") title = forms.CharField(max_length=255) abstract = forms.CharField(widget=TinyMCE(mce_attrs={'height': 150})) description = forms.CharField(widget=TinyMCE(mce_attrs={'height': 500})) target_funds = forms.IntegerField() attachment = forms.FileField(required=False)
class WebCreateForm(forms.ModelForm): web_name = forms.CharField(required=True, label="Nazwa Podstrony") web_content = forms.CharField(widget=TinyMCE(attrs={ 'cols': 30, 'rows': 10 }), required=True, label="Text na podstronie") has_pictures = forms.BooleanField(required=False, label="Czy posiada zdjęcia") pictures = forms.ModelMultipleChoiceField( queryset=Pictures.objects.filter( has_gallery=False).order_by('-timestamp'), required=False, label='Wybierz Zdjęcia ( z L-Shift / L-Ctrl wybierasz kilka )') has_files = forms.BooleanField(required=False, label="Czy posiada Załączniki") web_filles = forms.ModelMultipleChoiceField( queryset=Files.objects.order_by('-timestamp'), required=False, label='Wybierz Załączniki ( z L-Shift / L-Ctrl wybierasz kilka )') class Meta: model = Webs fields = ('web_name', 'web_content', 'has_pictures', 'pictures', 'has_files', 'web_filles')
class PostForm(forms.ModelForm): description = forms.CharField(widget=TinyMCE(attrs={ 'cols': 80, 'rows': 30 }), label='') title = forms.CharField( widget=forms.TextInput(attrs={ 'class': 'cuguge_form_field form-control mt-2', 'placeholder': 'title' }), label='') phone = forms.CharField( widget=forms.TextInput(attrs={ 'id': 'post_form_phone', 'hidden': 'true', 'placeholder': 'title' }), label='') specie = forms.ModelChoiceField(widget=forms.Select( attrs={'class': 'cuguge_form_field form-control mt-2'}), queryset=Specie.objects.all(), initial='1', label='') post_type = forms.ModelChoiceField(widget=forms.Select( attrs={'class': 'cuguge_form_field form-control mt-2 mb-2'}), queryset=PostType.objects.all(), initial='1', label='') class Meta: model = Post fields = ('title', 'phone', 'specie', 'post_type', 'description')
class WriteArticleForm(forms.ModelForm): categories = [('prog', 'Programming'), ('robo', 'Robotics'), ('math', 'Mathematics'), ('cs', 'Computer Science'), ('bc', 'Blockchain'), ('iot', 'Internet Of Things'), ('ml', 'Machine Learning'), ('hard', 'Hardware'), ('do', 'DevOps')] title = forms.CharField(widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Title' }), max_length=256) annotation = forms.CharField( widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Annotation' }), max_length=150) logo = forms.ImageField(required=False) category = forms.ChoiceField( choices=categories, widget=forms.Select(attrs={'class': 'form-control'})) body = forms.CharField(widget=TinyMCE(attrs={'class': 'form-control'}, mce_attrs={'width': 800})) class Meta: model = Article fields = ['title', 'annotation', 'logo', 'category', 'body']
class PostForm(forms.ModelForm): content = forms.CharField(widget=TinyMCE( attrs={'cols': 80, 'rows': 30})) class Meta: model = Post fields = ('title', 'overview', 'content', 'thumbnail', 'categories', 'featured', 'previous_post', 'next_post')
class TutorialsAdmin(admin.ModelAdmin): fieldsets = [("Title/Date", { "fields": ["tutorial_title", "tutorial_published"] }), ("Content", { "fields": ["tutorial_content"] })] formfield_overrides = {models.TextField: {'widget': TinyMCE()}}
class Meta: model = Comment fields = ['name', 'email', 'content'] widgets = { 'name': forms.TextInput(attrs={'class': 'form-control'}), 'email': forms.TextInput(attrs={'class': 'form-control'}), 'content': TinyMCE(attrs={'class': 'form-control'}, mce_attrs=TINYMCE_COMMENT_CONFIG), }
class CreateThreadForm(forms.Form): prefix = forms.ModelChoiceField(queryset=ThreadPrefix.objects.all(), required=False) title = forms.CharField(label="Thread title", max_length=200) content = forms.CharField(widget=TinyMCE(attrs={ 'cols': 40, 'rows': 15 }), max_length=25000)
class BlogForm(forms.ModelForm): content = forms.CharField(widget=TinyMCE(attrs={ 'required': False, 'cols': 30, 'rows': 10 })) class Meta: model = BlogModel exclude = ['user', 'comments', 'featured']
class PostForm(forms.ModelForm): formfield_overrides = { models.TextField: { 'widget': TinyMCE() }, } class Meta: model = Post fields = '__all__'
class TutorialAdmin(admin.ModelAdmin): fields = [ "tutorials_title", "tutorials_published", "tutorials_content", "tutorials_slug", "tutorialseries", ] formfield_overrides = {models.TextField: {'widget': TinyMCE()}}
class TopicForm(ModelForm): content = CharField(widget=TinyMCE(attrs={ 'required': False, 'cols': 100, 'rows': 20 })) class Meta: model = Topic exclude = ('published_at', 'author', 'nbr_upvotes', 'nbr_comments')
class PostForm(forms.ModelForm): content = forms.CharField(widget=TinyMCE(attrs={ 'required': False, 'cols': 30, 'rows': 10 })) class Meta: model = Post fields = '__all__'
class ParagrapheForm(ModuleForm): contenu = forms.CharField(widget=TinyMCE()) img = forms.ImageField(allow_empty_file=True, required=False) intitule_img = forms.CharField(empty_value=True, required=False) class Meta: model = Paragraphe fields = [ 'contenu', 'img', 'intitule_img', 'date_creation', 'date_edition' ]
class PostForm(forms.ModelForm): content = forms.CharField(widget=TinyMCE(attrs={ 'required': True, 'cols': 30, 'rows': 10 })) title = forms.CharField(help_text='100 characters max.') class Meta: model = Post fields = ['title', 'content', 'post_pic']
class CursoAdmin(admin.ModelAdmin): #fields = ('curso_publicado', 'curso_titulo', 'curso_contenido') fieldsets = [ ('Titulo/fecha', {'fields': [ 'curso_titulo','curso_publicado']}), ('contenido', {'fields':['curso_contenido']}) ] formfield_overrides = { models.TextField: {'widget': TinyMCE()} }
class Meta: model = Use_Term fields = ('term', 'init_date', 'final_date') labels = { 'term': _('Term'), 'init_date': _('Initial Date'), 'final_date': _('Final Date') } widgets = { 'term': TinyMCE(), }
class BlogForm(forms.ModelForm): title = forms.CharField(widget=forms.TextInput( attrs={ 'class': 'blog-form-title', 'placeholder': 'Blog Title...' })) content = forms.CharField(widget=TinyMCE(attrs={'cols': 5, 'rows': 10})) class Meta: model = models.Entry fields = ['title', 'content']
class QuestionCreateForm(forms.ModelForm): content = forms.CharField(widget=TinyMCE(mce_attrs={'width': 800})) class Meta: model = Question def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['content'].widget.attrs.update( TinyMCE(mce_attrs={'width': 800})) fields = ('question', 'content')
class ReportCreateForm(forms.ModelForm): content = forms.CharField(widget=TinyMCE(mce_attrs={'width': 800})) class Meta: model = Report def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['content'].widget.attrs.update( TinyMCE(mce_attrs={'width': 800})) fields = ('title', 'category', 'content')
class CaseAdmin(admin.ModelAdmin): fields = [ 'divisions', 'caseworkers', 'intake_caseworker', 'referrer', 'client_name', 'client_email', 'client_phone', 'client_SID', 'client_pronouns', 'week_food', 'semester_food', 'week_housing', 'dependent', 'using_resources', 'screening_asked', 'case_question', 'open_date', 'incident_description', 'tags', 'is_open', 'close_date', 'updates' ] readonly_fields = ['updates', 'intake_caseworker'] list_display = ('get_divisions_display', 'open_date', 'client_name', 'is_open') list_filter = ['open_date', 'is_open', DivisionsListFilter] search_fields = ['tags__value', 'tags__acronym', 'client_name'] autocomplete_fields = ['caseworkers', 'referrer', 'tags'] actions = [close_cases, reopen_cases] formfield_overrides = { HTMLField: { 'widget': TinyMCE(mce_attrs={ 'width': '75%', **TINY_MCE_SETUP }) } } def get_queryset(self, request): """ Filters case queryset so that executive leadership (users in 'Office Leads') can see all cases in the system, but division leads can only see the cases which fall under their division """ qs = super().get_queryset(request) if request.user in Group.objects.get( name='Office Leads').user_set.all(): return qs # Chiefs and advocate can see everything return qs.filter(divisions__contains=request.user.caseworker.division) def save_model(self, request, obj, form, change): if change: was_open_before_change = Case.objects.get(pk=obj.pk).is_open if (not obj.is_open) and was_open_before_change and ( not obj.close_date): # If the case was just closed but the user did not input a close date, set the close date to today. obj.close_date = timezone.now() elif obj.is_open and (not was_open_before_change): # If the case was just reopened, set the close date to None obj.close_date = None else: if (not obj.is_open) and (not obj.close_date): # If a new case was just created but is closed (i.e. consultation) and the user did not select a close date, set the close date to today obj.close_date = timezone.now() obj.save()
class ShareNewsAdmin(admin.ModelAdmin): fieldsets = [ ('Vấn đề và tiêu đề', {'fields': ['subject', 'title']}), ('Lớp', {'fields': ['classroom']}), ('Nộ dụng và ngày tạo', {'fields': ['content', 'published']}), ('File', {'fields': ['file']}), ('Trạng thái hoạt động', {'fields': ['on_delete_flag','share_school_flag']}), ] list_display = ('subject', 'title', 'classroom', 'content', 'published', 'file', 'on_delete_flag','share_school_flag') formfield_overrides = { models.TextField: {'widget': TinyMCE()} }
class PostForm(forms.ModelForm): content = forms.CharField( widget=TinyMCE( attrs={'required': False, 'cols': 30, 'rows': 10} ) ) class Meta: model = models.Post fields = '__all__' exclude = ['author', 'read_time', 'hits'] widgets = {'publish': DateInput()}
class MainNewsForm(forms.ModelForm): content = forms.CharField(widget=TinyMCE(attrs={ 'cols': 30, 'rows': 10 }), required=False, label="Text na podstronie") title = forms.CharField(required=True, label='Tytuł ( Nie używać "/" w tekscie )') overview = forms.CharField(required=True, label='Wiadomość', widget=forms.Textarea(attrs={ 'rows': 4, 'cols': 40 })) has_thumbnail = forms.BooleanField(required=False, label='Czy posiada zdjęcie główne') thumbnail = forms.ImageField( required=False, label='Zdjęcie główne ( jeżeli posiada zdjęcie )') category = forms.ModelMultipleChoiceField( queryset=Category.objects.all(), required=True, label='Wybierz Kategorię ( z L-Shift / L-Ctrl wybierasz kilka )') has_own_web = forms.BooleanField(required=False, label='Czy posiada podstronę') has_gallery = forms.BooleanField(required=False, label='Czy posiada galerię') gallery = forms.ModelChoiceField( queryset=Gallery.objects.order_by('-timestamp'), required=False, label='Wybierz galerię ( jeżeli posiada galerię )') featured = forms.BooleanField(required=False, label='Pokaż na głównej stronie') class Meta: model = MainNews fields = ( 'featured', 'title', 'overview', 'has_thumbnail', 'thumbnail', 'category', 'has_own_web', 'content', 'has_gallery', 'gallery', )
class Meta: model = CaseUpdate fields = ['update_description', 'case', 'creator'] labels = {'update_description': ""} # user does not manually select which case a case update is for, or the creator widgets = { 'case': forms.HiddenInput(), 'creator': forms.HiddenInput(), 'update_description': TinyMCE(mce_attrs={ 'height': 200, **TINY_MCE_SETUP }) }
class mail_sender(forms.ModelForm): class Meta: model=email_model fields=['recipients','subject','body','user'] recipients=forms.CharField(max_length=1000, label="", widget=forms.TextInput( attrs={ "class":"form-control", "placeholder":'Recipients' } )) user=forms.CharField(max_length=500, label="Username", widget=forms.TextInput( attrs={ "class":"form-inline", "placeholder":'User' } ) ) subject=forms.CharField(max_length=200, label="", widget=forms.TextInput( attrs={ "class":"form-control", "placeholder":'Subject' } )) body=forms.CharField(max_length=2000, label="", widget=TinyMCE(attrs={ "class":"form-control", "placeholder":'Write you Body Message here!' }, mce_attrs={'width': "100%"}) )
class TitreForm(ModuleForm): description = forms.CharField(widget=TinyMCE(), empty_value=True) class Meta: model = Titre fields = [ 'code', 'intitule', 'description', 'position', 'date_creation', 'date_edition' ] widgets = { 'code': TextInput(attrs={'class': 'blue-grey-text text-darken-4'}), 'intitule': TextInput(attrs={'class': 'blue-grey-text text-darken-4'}), 'position': NumberInput(attrs={'class': 'blue-grey-text text-darken-4'}) }
class TutorialAdmin(admin.ModelAdmin): list_display = ['tutorial_title','tutorial_published','tutorial_slug','tutorial_series'] search_fields = ['tutorial_content','tutorial_content'] fieldsets = [ ('title',{'fields':['tutorial_title','tutorial_published']}), ('url',{'fields':['tutorial_slug']}), ('Series',{'fields':['tutorial_series']}), ('Content',{'fields':['tutorial_content']}) ] class Meta: model=Tutorial formfield_overrides = { models.TextField:{'widget':TinyMCE()} }
class Meta: model = Case fields = [ 'divisions', 'client_name', 'client_email', 'client_phone', 'client_SID', 'open_date', 'incident_description', 'intake_caseworker', 'referrer' ] widgets = { 'client_phone': PhoneNumberInternationalFallbackWidget(), 'incident_description': TinyMCE(mce_attrs=TINY_MCE_SETUP), 'intake_caseworker': forms.HiddenInput(), 'referrer': AutocompleteSelect(rel=Tag.cases.rel, admin_site=admin_site), }
class TasklistAdmin(admin.ModelAdmin): fieldsets = [ ('Task/date', { 'fields': ['task_title', 'task_due'] }), ('Description', { 'fields': ['task_priority'] }), ('List', { 'fields': ['task_list'] }), ('Owner', { 'fields': ['task_owner'] }), ] formfield_overrides = {models.TextField: {'widget': TinyMCE()}}