Ejemplo n.º 1
0
    def test_bs5accordion_active_false_not_rendered(self):
        test_form = SampleForm()
        test_form.helper = FormHelper()
        test_form.helper.layout = Layout(
            BS5Accordion(AccordionGroup("one", "first_name"),
                         # there is no ``active`` kwarg here.
                         ))

        # The first time, there should be one of them there.
        html = render_crispy_form(test_form)

        accordion_class = "collapse show"

        assert (html.count('<div id="one" class="accordion-collapse %s"' %
                           accordion_class) == 1)

        test_form.helper.layout = Layout(
            BS5Accordion(AccordionGroup("one", "first_name", active=False),
                         )  # now ``active`` manually set as False
        )

        # This time, it shouldn't be there at all.
        html = render_crispy_form(test_form)
        assert (html.count('<div id="one" class="accordion-collapse %s"' %
                           accordion_class) == 0)
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("aircraft"),
                    FloatingField("mass"),
                    FloatingField("is_registered"),
                ),
                AccordionGroup(
                    "Optional Information",
                    FloatingField("commission_date"),
                    FloatingField("registration_mark"),
                    FloatingField("digital_sky_uin_number"),
                    FloatingField("identification_photo"),
                ),
            ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Aircraft Details'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'aircrafts-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True
        self.fields['company'].queryset = Company.objects.filter(role=2)

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("company"),
                    FloatingField("website"),
                    FloatingField("email"),
                    FloatingField("phone_number"),
                    FloatingField("operator_type"),
                    FloatingField("address"),
                ),
                AccordionGroup(
                    "Optional Information",
                    "operational_authorizations",
                    "authorized_activities",
                    FloatingField("insurance_number"),
                    FloatingField("company_number"),
                    FloatingField("vat_number"),
                    FloatingField("country"),
                ),
            ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Operator'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'operators-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 4
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup("Mandatory Information",
                               FloatingField("operator"),
                               FloatingField("manufacturer"),
                               FloatingField("final_assembly"),
                               FloatingField("flight_controller_id"),
                               FloatingField("status"), FloatingField("photo"),
                               FloatingField("name")),
                HTML("""
                            <br>
                        """),
                ButtonHolder(
                    Submit('submit', '+ Add Aircraft'),
                    HTML(
                        """<a class="btn btn-secondary" href="{% url 'aircrafts-list' %}" role="button">Cancel</a>"""
                    ))))
        self.fields[
            'final_assembly'].queryset = AircraftAssembly.objects.filter(
                ~Exists(Aircraft.objects.filter(
                    final_assembly=OuterRef('pk')))).filter(status=2)
Ejemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("full_name"),
                    FloatingField("common_name"),
                    FloatingField("email"),
                    FloatingField("website"),
                    FloatingField("phone_number"),
                    FloatingField("company_number"),
                    FloatingField("address"),
                    FloatingField("role"),
                    FloatingField("country"),
                ),
                AccordionGroup(
                    "Optional Information",
                    FloatingField("documents"),
                    FloatingField("vat_number"),
                    FloatingField("insurance_number"),
                ),
            ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Company'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'companies-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("address_line_1"),
                    FloatingField("address_line_2"),
                    FloatingField("address_line_3"),
                    FloatingField("postcode"),
                    FloatingField("city"),
                    FloatingField("state"),
                    FloatingField("country"),
                ), ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Address'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'addresses-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 7
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("operator"),
                    FloatingField("person"),
                    FloatingField("photo"),
                ),
                AccordionGroup(
                    "Optional Information",
                    FloatingField("photo"),
                    FloatingField("identification_photo"),
                    FloatingField("tests"),
                ),
            ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Pilot'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'pilots-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("title"),
                    FloatingField("operation_max_height"),
                    FloatingField("operation_altitude_system"),
                    FloatingField("airspace_type"),
                    FloatingField("operation_area_type"),
                    FloatingField("risk_type"),
                    FloatingField("authorization_type"),
                    "permit_to_fly_above_crowd",
                ), ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Activity'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'activities-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 9
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("first_name"),
                    FloatingField("middle_name"),
                    FloatingField("last_name"),
                    FloatingField("email"),
                    FloatingField("phone_number"),
                    FloatingField("country"),
                ),
                AccordionGroup("Optional Information",
                               FloatingField("documents"),
                               FloatingField("date_of_birth")),
            ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Person'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'people-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 10
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        super(FlightOperationCreateForm,
              self).__init__(*args, **kwargs)  # populates the post
        self.fields['flight_plan'].queryset = FlightPlan.objects.filter(
            is_editable=True)

        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("name"),
                    FloatingField("drone"),
                    FloatingField("flight_plan"),
                    FloatingField("purpose"),
                    FloatingField("operator"),
                    FloatingField("pilot"),
                    "start_datetime",
                    "end_datetime",
                ),
                AccordionGroup("Optional Information",
                               FloatingField("type_of_operation")),
                HTML("""
                            <br>
                        """),
                ButtonHolder(
                    Submit('submit', '+ Add Operation'),
                    HTML(
                        """<a class="btn btn-secondary" href="{% url 'flightoperations-list' %}" role="button">Cancel</a>"""
                    ))))
Ejemplo n.º 11
0
 def test_bs5accordion(self):
     random.seed(0)
     form = SampleForm()
     form.helper = FormHelper()
     form.helper.form_tag = False
     form.helper.layout = Layout(
         BS5Accordion(
             AccordionGroup("one", "first_name"),
             AccordionGroup("two", "password1", "password2"),
         ))
     assert parse_form(form) == parse_expected("accordion.html")
Ejemplo n.º 12
0
    def __init__(self, *args, aircraft_model_id, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.model_qs = AircraftModel.objects.filter(id=aircraft_model_id)
        aircraft_model = AircraftModel.objects.get(id=aircraft_model_id)
        # The components that have not been selected

        self.all_master_components = aircraft_model.master_components.all()
        self.relevant_supplier_parts = SupplierPart.objects.filter(
            manufacturer_part__master_component__in=self.all_master_components)

        self.components_qs = AircraftComponent.objects.filter(~Exists(
            AircraftAssembly.objects.filter(
                components__in=OuterRef('pk')))).filter(
                    supplier_part__in=self.relevant_supplier_parts)

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("status"),
                    FloatingField("model"),
                    Field("components"),
                    HTML("""
                                <small>Select from available components, if no components are avialable, check the inventory and order new ones.</small>
                                <br>
                            """),
                ),
                HTML("""
                            <br>
                        """),
                ButtonHolder(
                    Submit('submit', '+ Add Aircraft Assembly'),
                    HTML(
                        """<a class="btn btn-secondary" href="{% url 'aircraft-assemblies-list' %}" role="button">Cancel</a>"""
                    ))))

        self.fields['model'] = forms.ModelChoiceField(required=True,
                                                      queryset=self.model_qs)

        self.fields['components'] = forms.ModelMultipleChoiceField(
            required=True,
            queryset=self.components_qs,
            widget=forms.SelectMultiple())
Ejemplo n.º 13
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup("Mandatory Information", FloatingField("name"),
                               'activity_type'), ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Activity'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'activities-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 14
0
    def __init__(self, *args, **kwargs):
        super(FlightPermissionCreateForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("operation"),
                ), ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Permission'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'flightpermissions-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 15
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information", FloatingField("component"),
                    FloatingField("signature_url"),
                    HTML("""
                            <br>
                        """),
                    ButtonHolder(
                        Submit('submit',
                               '+ Add Aircraft Component Signature Details'),
                        HTML(
                            """<a class="btn btn-secondary" href="{% url 'aircraft-components-signature-list' %}" role="button">Cancel</a>"""
                        )))))
Ejemplo n.º 16
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup("Mandatory Information",
                               FloatingField("operator"),
                               FloatingField("person"),
                               FloatingField("address"),
                               FloatingField("role_type")),
                HTML("""
                            <br>
                        """),
                ButtonHolder(
                    Submit('submit', '+ Add Contact'),
                    HTML(
                        """<a class="btn btn-secondary" href="{% url 'contacts-list' %}" role="button">Cancel</a>"""
                    ))))
Ejemplo n.º 17
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("name"),
                    FloatingField("popular_name"),
                    FloatingField("max_endurance"),
                    FloatingField("max_range"),
                    FloatingField("max_speed"),
                    FloatingField("category"),
                    FloatingField("dimension_length"),
                    FloatingField("dimension_breadth"),
                    FloatingField("dimension_height"),
                    FloatingField("series"),
                    FloatingField("sub_category"),
                    FloatingField("operating_frequency"),
                    FloatingField("type_certificate"),
                    FloatingField("max_certified_takeoff_weight"),
                    FloatingField("max_height_attainable"),
                    FloatingField("icao_aircraft_type_designator"),
                ),
                AccordionGroup(
                    "Master Components",
                    Field("master_components"),
                ), AccordionGroup(
                    "Documents",
                    Field("documents"),
                ),
                HTML("""
                            <br>
                        """),
                ButtonHolder(
                    Submit('submit', '+ Add Aircraft Model'),
                    HTML(
                        """<a class="btn btn-secondary" href="{% url 'aircraft-models-list' %}" role="button">Cancel</a>"""
                    ))))
Ejemplo n.º 18
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("name"),
                    FloatingField("family"),
                    FloatingField("drawing"),
                ),
                HTML("""
                            <br>
                        """),
                ButtonHolder(
                    Submit('submit', '+ Add Aircraft Master Component'),
                    HTML(
                        """<a class="btn btn-secondary" href="{% url 'aircraft-master-components-list' %}" role="button">Cancel</a>"""
                    ))))
Ejemplo n.º 19
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup("Mandatory Information", FloatingField("name"),
                               FloatingField("token_type"),
                               FloatingField("extension"),
                               FloatingField("association"), "credential"),
                AccordionGroup("Optional Information",
                               FloatingField("aircraft"),
                               FloatingField("manufacturer"),
                               FloatingField("operator"), 'is_active'),
            ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Credentials'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'credentials-list' %}" role="button">Cancel</a>"""
                )))
Ejemplo n.º 20
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("binary_file_url"),
                    FloatingField("binary_file_hash"),
                    FloatingField("version"),
                    FloatingField("manufacturer"),
                    FloatingField("friendly_name"),
                    "is_active",
                ),
                HTML("""
                            <br>
                        """),
                ButtonHolder(
                    Submit('submit', '+ Add Firmware'),
                    HTML(
                        """<a class="btn btn-secondary" href="{% url 'firmwares-list' %}" role="button">Cancel</a>"""
                    ))))
Ejemplo n.º 21
0
    def __init__(self, *args, **kwargs):
        super(FlightLogCreateForm,
              self).__init__(*args, **kwargs)  # populates the post
        self.fields['operation'].queryset = FlightOperation.objects.filter(
            is_editable=True)

        self.helper = FormHelper(self)
        self.helper.help_text_inline = True

        self.helper.layout = Layout(
            BS5Accordion(
                AccordionGroup(
                    "Mandatory Information",
                    FloatingField("operation"),
                    FloatingField("raw_log"),
                ), ),
            HTML("""
                            <br>
                        """),
            ButtonHolder(
                Submit('submit', '+ Add Log'),
                HTML(
                    """<a class="btn btn-secondary" href="{% url 'flightlogs-list' %}" role="button">Cancel</a>"""
                )))