Beispiel #1
0
    def update_traffic_fee(pid: str, uid: str,
                           data: dict[str, Any]) -> dict[str, Any]:
        ''' Update traffic fee

        Args:
            pid (str): Project id.
            uid (str): User id.
            data (dict): The data to update.

                - `apply`: `bool`.
                - `fee`: `int`.
                - `fromwhere`: `str`.
                - `howto`: `str`.

        Returns:
            Return the added data.

        TODO:
            Need refactor in pydantic.

        '''
        return FormDB().add_by_case(case='traffic_fee',
                                    pid=pid,
                                    uid=uid,
                                    data=data)
Beispiel #2
0
    def update_room(pid, uid, room, change_key=True):
        ''' Update room no

        :param str pid: pid
        :param str uid: uid
        :param str room: room

        '''
        _update = {'data.room': room}
        if change_key:
            _update['data.room_key'] = '%0.8x' % uuid4().fields[0]

        _query = {'case': 'accommodation', 'pid': pid, 'uid': uid}
        _query['$or'] = [{
            'data.room': {
                '$ne': room
            }
        }, {
            'data.room': {
                '$exists': False
            }
        }]

        return FormDB().find_one_and_update(
            _query,
            {'$set': _update},
            return_document=ReturnDocument.AFTER,
        )
Beispiel #3
0
    def all_drink(pid):
        ''' Get all drink

        :param str pid: project id

        '''
        for raw in FormDB().find({'case': 'drink', 'pid': pid}):
            yield raw
Beispiel #4
0
    def all_parking_card(pid):
        ''' Get all parking card

        :param str pid: project id

        '''
        for raw in FormDB().find({'case': 'parking_card', 'pid': pid}):
            yield raw
Beispiel #5
0
    def all_clothes(pid):
        ''' Get all clothes

        :param str pid: project id

        '''
        for raw in FormDB().find({'case': 'clothes', 'pid': pid}):
            yield raw
Beispiel #6
0
    def get_clothes(pid, uid):
        ''' Get clothes

        :param str pid: project id
        :param str uid: user id

        '''
        return FormDB().find_one({'case': 'clothes', 'pid': pid, 'uid': uid})
Beispiel #7
0
    def all_traffic_fee(pid):
        ''' Get All traffic_fee

        :param str pid: project id

        '''
        for raw in FormDB().find({'case': 'traffic_fee', 'pid': pid}):
            yield raw
Beispiel #8
0
    def all_appreciation(pid):
        ''' Get all appreciation

        :param str pid: project id

        '''
        for raw in FormDB().find({'case': 'appreciation', 'pid': pid}):
            yield raw
Beispiel #9
0
    def get_drink(pid, uid):
        ''' Get drink

        :param str pid: project id
        :param str uid: user id

        '''
        return FormDB().find_one({'case': 'drink', 'pid': pid, 'uid': uid})
Beispiel #10
0
 def get(pid):
     ''' Get data '''
     for raw in FormDB().find({
             'case': 'accommodation',
             'data.key': {
                 '$ne': 'no'
             }
     }):
         yield raw
Beispiel #11
0
    def all_volunteer_certificate(pid):
        ''' Get All volunteer certificate

        :param str pid: project id

        '''
        for raw in FormDB().find({
                'case': 'volunteer_certificate',
                'pid': pid
        }):
            yield raw
Beispiel #12
0
    def all_appreciation(pid: str) -> Generator[dict[str, Any], None, None]:
        ''' Get all appreciation

        Args:
            pid (str): Project id.

        Yields:
            Return the data in `pid`.

        '''
        for raw in FormDB().find({'case': 'appreciation', 'pid': pid}):
            yield raw
Beispiel #13
0
    def all_clothes(pid: str) -> Generator[dict[str, Any], None, None]:
        ''' Get all clothes

        Args:
            pid (str): Project id.

        Yields:
            Return the data in `pid`.

        '''
        for raw in FormDB().find({'case': 'clothes', 'pid': pid}):
            yield raw
Beispiel #14
0
    def get_drink(pid: str, uid: str) -> Optional[dict[str, Any]]:
        ''' Get drink

        Args:
            pid (str): Project id.
            uid (str): User id.

        Returns:
            The data or `None`.

        '''
        return FormDB().find_one({'case': 'drink', 'pid': pid, 'uid': uid})
Beispiel #15
0
    def all_parking_card(pid: str) -> Generator[dict[str, Any], None, None]:
        ''' Get all parking card

        Args:
            pid (str): Project id.

        Yields:
            Return the data in `pid`.

        '''
        for raw in FormDB().find({'case': 'parking_card', 'pid': pid}):
            yield raw
Beispiel #16
0
    def get_parking_card(pid, uid):
        ''' Get parking card

        :param str pid: project id
        :param str uid: user id

        '''
        return FormDB().find_one({
            'case': 'parking_card',
            'pid': pid,
            'uid': uid
        })
Beispiel #17
0
    def get_appreciation(pid, uid):
        ''' Get appreciation

        :param str pid: project id
        :param str uid: user id

        '''
        return FormDB().find_one({
            'case': 'appreciation',
            'pid': pid,
            'uid': uid
        })
Beispiel #18
0
    def get_volunteer_certificate(pid, uid):
        ''' Get volunteer certificate

        :param str pid: project id
        :param str uid: user id

        '''
        return FormDB().find_one({
            'case': 'volunteer_certificate',
            'pid': pid,
            'uid': uid
        })
Beispiel #19
0
    def all_traffic_fee(pid: str) -> Generator[dict[str, Any], None, None]:
        ''' Get All traffic_fee

        Args:
            pid (str): Project id.

        Yields:
            Return the data in `pid`.

        '''
        for raw in FormDB().find({'case': 'traffic_fee', 'pid': pid}):
            yield raw
Beispiel #20
0
    def get_traffic_fee(pid, uid):
        ''' Get traffic fee

        :param str pid: project id
        :param str uid: user id

        '''
        return FormDB().find_one({
            'case': 'traffic_fee',
            'pid': pid,
            'uid': uid
        })
Beispiel #21
0
    def update_drink(pid, uid, data):
        ''' Update drink

        :param str pid: project id
        :param str uid: user id
        :param dict data: form data

        .. note::
            - data:
                - y18: bool

        '''
        return FormDB().add_by_case(case='drink', pid=pid, uid=uid, data=data)
Beispiel #22
0
 def update_room_key(pid, uids):
     ''' update room key '''
     for uid in uids:
         FormDB().find_one_and_update(
             {
                 'case': 'accommodation',
                 'pid': pid,
                 'uid': uid
             },
             {'$set': {
                 'data.room_key': '%0.8x' % uuid4().fields[0]
             }},
         )
Beispiel #23
0
    def update_clothes(pid, uid, data):
        ''' Update clothes

        :param str pid: project id
        :param str uid: user id
        :param dict data: form data

        .. note::
            - data:
                - clothes: str, 'S / 38.5 / 55'

        '''
        return FormDB().add_by_case(case='clothes',
                                    pid=pid,
                                    uid=uid,
                                    data=data)
Beispiel #24
0
    def get_parking_card(pid: str, uid: str) -> Optional[dict[str, Any]]:
        ''' Get parking card

        Args:
            pid (str): Project id.
            uid (str): User id.

        Returns:
            The data or `None`.

        '''
        return FormDB().find_one({
            'case': 'parking_card',
            'pid': pid,
            'uid': uid
        })
Beispiel #25
0
    def update_volunteer_certificate(pid, uid, data):
        ''' Update volunteer certificate

        :param str pid: project id
        :param str uid: user id
        :param dict data: form data

        .. note::
            - data:
                - value: bool

        '''
        return FormDB().add_by_case(case='volunteer_certificate',
                                    pid=pid,
                                    uid=uid,
                                    data=data)
Beispiel #26
0
    def all_volunteer_certificate(
            pid: str) -> Generator[dict[str, Any], None, None]:
        ''' Get All volunteer certificate

        Args:
            pid (str): Project id.

        Yields:
            Return the data in `pid`.

        '''
        for raw in FormDB().find({
                'case': 'volunteer_certificate',
                'pid': pid
        }):
            yield raw
Beispiel #27
0
    def get_traffic_fee(pid: str, uid: str) -> Optional[dict[str, Any]]:
        ''' Get traffic fee

        Args:
            pid (str): Project id.
            uid (str): User id.

        Returns:
            The data or `None`.

        '''
        return FormDB().find_one({
            'case': 'traffic_fee',
            'pid': pid,
            'uid': uid
        })
Beispiel #28
0
    def get_volunteer_certificate(pid: str,
                                  uid: str) -> Optional[dict[str, Any]]:
        ''' Get volunteer certificate

        Args:
            pid (str): Project id.
            uid (str): User id.

        Returns:
            The data or `None`.

        '''
        return FormDB().find_one({
            'case': 'volunteer_certificate',
            'pid': pid,
            'uid': uid
        })
Beispiel #29
0
    def update_accommodation(pid, uid, data):
        ''' Update accommodation

        :param str pid: project id
        :param str uid: user id
        :param dict data: form data

        .. note::
            - data:
                - status: bool
                - key: str, in ('no', 'yes', 'yes-longtraffic')

        '''
        return FormDB().add_by_case(case='accommodation',
                                    pid=pid,
                                    uid=uid,
                                    data=data)
Beispiel #30
0
    def update_parking_card(pid, uid, data):
        ''' Update parking card

        :param str pid: project id
        :param str uid: user id
        :param dict data: form data

        .. note::
            - data:
                - carno: str
                - dates: list, ['2020-07-31', ]

        '''
        return FormDB().add_by_case(case='parking_card',
                                    pid=pid,
                                    uid=uid,
                                    data=data)