Example #1
0
 def get_form(self, request, obj=None, **kwargs):
     form = super(WorkflowAdmin, self).get_form(request, obj, **kwargs)
     if obj:
         form.base_fields['initial_state'].queryset = obj.states.all()
         if obj.slug == DEFAULT_WORKFLOW:
             set_field_read_only(form.base_fields['slug'], 'slug', obj)
     elif 'initial_state' in form.base_fields.keys():
         del form.base_fields['initial_state']
     return form
Example #2
0
 def get_form(self, request, obj=None, **kwargs):
     form = super(WorkflowAdmin, self).get_form(request, obj, **kwargs)
     if obj:
         form.base_fields['initial_state'].queryset = obj.states.all()
         if obj.slug == DEFAULT_WORKFLOW:
             set_field_read_only(form.base_fields['slug'], 'slug', obj)
     elif 'initial_state' in form.base_fields.keys():
         del form.base_fields['initial_state']
     return form
Example #3
0
 def get_form(self, request, obj=None, **kwargs):
     form = super(TransitionRelatedModelAdmin, self).get_form(request, obj, **kwargs)
     if obj:
         workflow = obj.workflow
         form.base_fields['destination'].queryset = State.objects.filter(workflow=workflow)
         if obj.slug in settings.STATIC_WORKFLOW_DATA['transitions']:
             set_field_read_only(form.base_fields['slug'], 'slug', obj)
     else:
         form.base_fields['destination'].queryset = self.basecontent.states.all()
     return form
Example #4
0
 def get_form(self, request, obj=None):
     form = super(RegisteredPluginAdmin, self).get_form(request, obj)
     if not has_required_dependencies(obj):
         installed_field = form.base_fields["installed"]
         help_text = installed_field.help_text
         installed_field.help_text = "%s %s" % (help_text, _("Not all dependencies are met"))
     if obj.broken:
         # a broken registered item will be not editable by anybody
         for field_name, field in form.base_fields.items():
             set_field_read_only(field, field_name, obj)
     return form
Example #5
0
 def get_form(self, request, obj=None, **kwargs):
     form = super(TransitionRelatedModelAdmin,
                  self).get_form(request, obj, **kwargs)
     if obj:
         workflow = obj.workflow
         form.base_fields['destination'].queryset = State.objects.filter(
             workflow=workflow)
         if obj.slug in settings.STATIC_WORKFLOW_DATA['transitions']:
             set_field_read_only(form.base_fields['slug'], 'slug', obj)
     else:
         form.base_fields[
             'destination'].queryset = self.basecontent.states.all()
     return form
Example #6
0
 def get_form(self, request, obj=None):
     form = super(RegisteredPluginAdmin, self).get_form(request, obj)
     if not has_required_dependencies(obj):
         installed_field = form.base_fields['installed']
         help_text = installed_field.help_text
         installed_field.help_text = "%s %s" \
                                     % (help_text,
                                       _('Not all dependencies are met'))
     if obj.broken:
         # a broken registered item will be not editable by anybody
         for field_name, field in form.base_fields.items():
             set_field_read_only(field, field_name, obj)
     return form
Example #7
0
    def get_form(self, request, obj=None, **kwargs):
        form = super(RegisteredItemAdmin,
                     self).get_form(request, obj, **kwargs)
        broken_item = is_broken(obj)

        if broken_item:
            # a broken registered item will be not editable by anybody
            for field_name, field in form.base_fields.items():
                set_field_read_only(field, field_name, obj)

        if not broken_item and 'config' in form.base_fields.keys():
            config = obj.get_registry_item().get_config()
            config_field = form.base_fields['config']
            config_field.set_config(config)

        return form
Example #8
0
    def get_form(self, request, obj=None, **kwargs):
        form = super(RegisteredItemAdmin, self).get_form(request, obj,
                                                         **kwargs)
        broken_item = is_broken(obj)

        if broken_item:
            # a broken registered item will be not editable by anybody
            for field_name, field in form.base_fields.items():
                set_field_read_only(field, field_name, obj)

        if not broken_item and 'config' in form.base_fields.keys():
            config = obj.get_registry_item().get_config()
            config_field = form.base_fields['config']
            config_field.set_config(config)

        return form
Example #9
0
 def get_form(self, request, obj=None):
     form = super(ThemeAdmin, self).get_form(request, obj)
     if not obj.installed:
         set_field_read_only(form.base_fields['active'], 'active', obj)
     return form
Example #10
0
 def get_form(self, request, obj=None):
     form = super(ThemeAdmin, self).get_form(request, obj)
     if not obj.installed:
         set_field_read_only(form.base_fields['active'], 'active', obj)
     return form