Example #1
0
    def __init__(self, request, *args, **kwargs):
        # Obtain list of projects
        self.target_choices = common.get_project_list_choices(request)
        # Obtain list of dsl filters
        self.dsl_filter_choices = common.get_dsl_filter_list_choices(request)
        # Obtain list of object types
        self.object_type_choices = common.get_object_type_choices(request)

        # Initialization
        super(CreateSimplePolicy, self).__init__(request, *args, **kwargs)

        # Overwrite target_id input form
        self.fields['target_id'] = forms.ChoiceField(choices=self.target_choices,
                                                     label=_("Project"),
                                                     help_text=_("The project where the rule will be apply."),
                                                     required=True)
        # Overwrite filter_id input form
        self.fields['filter_id'] = forms.ChoiceField(choices=self.dsl_filter_choices,
                                                     label=_("Filter"),
                                                     help_text=_("The id of the filter which will be used."),
                                                     required=True)
        # Overwrite object_type input form
        self.fields['object_type'] = forms.ChoiceField(choices=self.object_type_choices,
                                                       label=_("Object Type"),
                                                       help_text=_("The type of object the rule will be applied to."),
                                                       required=False)
Example #2
0
    def __init__(self, request, *args, **kwargs):
        # Obtain list of projects
        self.project_choices = common.get_project_list_choices(request)
        # Obtain list of storage policies
        self.storage_policy_choices = common.get_storage_policy_list_choices(request)

        # Initialization
        super(CreateSLA, self).__init__(request, *args, **kwargs)

        # Overwrite target_id input form
        self.fields['project_id'] = forms.ChoiceField(choices=self.project_choices,
                                                      label=_("Project"),
                                                      help_text=_("The project where the rule will be apply."),
                                                      required=True)

        self.fields['policy_id'] = forms.ChoiceField(choices=self.storage_policy_choices,
                                                     label=_("Storage Policy (Ring)"),
                                                     help_text=_("The storage policy that you want to assign to the specific project."),
                                                     required=True)