Ejemplo n.º 1
0
    def post(self):

        c = CustomerProject(
            **get_fillable(CustomerProject, **request.get_json()))
        db.session.add(c)
        db.session.commit()
        return Result.id(c.id)
Ejemplo n.º 2
0
    def post(self):
        data = request.get_json()

        group = UserGroup(name=data['name'].upper().strip())
        users = User.query.filter(User.id.in_(data['ids'])).all()

        for user in users:
            group.users.append(user)

        db.session.commit()

        return Result.id(group.id)
Ejemplo n.º 3
0
    def post(self):
        data = request.get_json().copy()

        if 'request_date' in data:
            data['request_date'] = local_to_utc(data['request_date'])
        if 'response_date' in data:
            data['response_date'] = local_to_utc(data['response_date'])

        financing = InstallationFinancing(
            **get_fillable(InstallationFinancing, **data))
        db.session.add(financing)
        db.session.commit()
        return Result.id(financing.id)
Ejemplo n.º 4
0
    def post(self):
        data = request.get_json().copy()
        if 'next_follow_up' in data:
            data['next_follow_up'] = local_to_utc(data['next_follow_up'])

        inst = Installation.query.filter_by(id=data['installation_id']).first()

        if inst is None:
            raise HttpNotFoundException()

        follow_up = InstallationFollowUp(
            **get_fillable(InstallationFollowUp, **data))
        follow_up.user_id = request.user.id

        if 'comment' in data:
            follow_up.comments.append(
                InstallationFollowUpComment(user_id=request.user.id,
                                            comment=data['comment']))

        inst.follow_ups.append(follow_up)
        db.session.commit()

        return Result.id(follow_up.id)
Ejemplo n.º 5
0
    def post(self):

        data = request.get_json().copy()
        data['start_date'] = local_to_utc(data['start_date'])

        c = Installation(**get_fillable(Installation, **data))
        if 'panels' in data:
            for panel in data['panels']:
                c.panels.append(
                    InstallationPanelModel(model_id=panel['id'],
                                           quantity=panel['quantity'],
                                           serials=panel['serials']))

        if 'inverters' in data:
            for inverter in data['inverters']:
                c.inverters.append(
                    InstallationInverterModel(model_id=inverter['id'],
                                              quantity=inverter['quantity'],
                                              serials=inverter['serials']))
        c.status = InstallationStatus()
        db.session.add(c)
        db.session.commit()
        return Result.id(c.id)