コード例 #1
0
ファイル: tarif.py プロジェクト: gitesdewallonie/gites.core
    def values(self):
        heb = self._get_heb()

        if heb.type.type_heb_type == 'gite':
            tarifs_types = TarifsType.get(gite=True)
        else:
            tarifs_types = TarifsType.get(chambre=True)

        self.tarifs = Tarifs.get_hebergement_tarifs(heb.heb_pk)
        tarifs_table = []
        for tarifs_type in tarifs_types:
            if self.section_types and tarifs_type.type not in self.section_types:
                continue
            if self.section_subtypes and tarifs_type.subtype not in self.section_subtypes:
                continue
            line = self._get_tarif_line(tarifs_type)
            if line:
                tarifs_table.append(line)
        return tarifs_table
コード例 #2
0
    def apply_tarifs_changes(self):
        """ Apply tarifs changes """
        form = self.request.form
        heb_pk = form.get('tarif_heb_pk', None)

        if not heb_pk:
            return 1

        # new tarif from proprio are not directly valid
        roles = api.user.get_current().getRoles()
        is_admin = 'Manager' in roles and True or None
        valid = is_admin and True or None

        heb = Hebergement.first(heb_pk=heb_pk)

        if heb.type.type_heb_type == 'gite':
            tarifs_types = TarifsType.get(gite=True)
        elif heb.type.type_heb_type == 'chambre':
            tarifs_types = TarifsType.get(chambre=True)

        for tt in tarifs_types:
            if tt.type == "CHARGES":
                min, max, cmt = self._get_charges_values(form, tt)
                # Do not have to update_tarif CHARGES if not selected
                if cmt == None:
                    continue
            else:
                min = form.get('tarif_min_{0}_{1}'.format(tt.type, tt.subtype)) or None
                max = form.get('tarif_max_{0}_{1}'.format(tt.type, tt.subtype)) or None
                cmt = form.get('tarif_cmt_{0}_{1}'.format(tt.type, tt.subtype)) or None

            self._update_tarif(heb_pk,
                               tt.type,
                               tt.subtype,
                               min,
                               max,
                               cmt,
                               valid)
        if is_admin:
            return 1
        else:
            return 2