예제 #1
0
파일: api.py 프로젝트: svdoever/indico
class SetPaidHook(EventBaseHook):
    PREFIX = "api"
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)/pay'
    METHOD_NAME = 'api_pay'
    NO_CACHE = True
    COMMIT = True
    HTTP_POST = True

    def _getParams(self):
        super(SetPaidHook, self)._getParams()
        self.auth_key = get_query_parameter(self._queryParams, ["auth_key"])
        self.is_paid = get_query_parameter(self._queryParams, ["is_paid"]) == "yes"
        registrant_id = self._pathParams["registrant_id"]
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        self._registrant = self._conf.getRegistrantById(registrant_id)
        if not payment_event_settings.get(self._conf, 'enabled'):
            raise HTTPAPIError('E-payment is not enabled')

    def _hasAccess(self, aw):
        return self._conf.canManageRegistration(aw.getUser()) or self._conf.canModify(aw)

    def api_pay(self, aw):
        action = TransactionAction.complete if self._isPayed == '1' else TransactionAction.cancel
        register_transaction(registrant=self._registrant,
                             amount=self._registrant.getTotal(),
                             currency=self._registrant.getCurrency(),
                             action=action)
        return {
            "paid": self._registrant.getPayed(),
            "amount_paid": self._registrant.getTotal()
        }
예제 #2
0
class CheckInHook(EventBaseHook):
    PREFIX = "api"
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)/checkin'
    METHOD_NAME = 'api_checkin'
    NO_CACHE = True
    COMMIT = True
    HTTP_POST = True

    def _getParams(self):
        super(CheckInHook, self)._getParams()
        self._check_in = get_query_parameter(self._queryParams, ["checked_in"]) == "yes"
        self._secret = get_query_parameter(self._queryParams, ["secret"])
        registrant_id = self._pathParams["registrant_id"]
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        self._registrant = self._conf.getRegistrantById(registrant_id)

    def _hasAccess(self, aw):
        return (self._conf.canManageRegistration(aw.getUser()) or self._conf.canModify(aw)) \
            and self._secret == self._registrant.getCheckInUUID()

    def api_checkin(self, aw):
        self._registrant.setCheckedIn(self._check_in)
        checkin_date = format_datetime(self._registrant.getAdjustedCheckInDate(), format="short")

        return {
            "checked_in": self._check_in,
            "checkin_date": checkin_date if self._check_in else None
        }
예제 #3
0
파일: registration.py 프로젝트: Ictp/indico
class RegistrantHook(EventBaseHook):
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)'
    NO_CACHE = True

    def _getParams(self):
        super(RegistrantHook, self)._getParams()
        self._secret = get_query_parameter(self._queryParams, ["secret"])
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        registrant_id = self._pathParams["registrant_id"]
        self._registrant = self._conf.getRegistrantById(registrant_id)
        self._type = "registrant"

    def _hasAccess(self, aw):
        return self._conf.canManageRegistration(aw.getUser()) and self._secret == self._registrant.getCheckInUUID()

    def export_registrant(self, aw):
        registration_date = format_datetime(self._registrant.getAdjustedRegistrationDate(), format="short")
        checkin_date = format_datetime(self._registrant.getAdjustedCheckInDate(), format="short")
        self._registrant.getPayed()
        result = {
            "registrant_id": self._registrant.getId(),
            "full_name": self._registrant.getFullName(title=True, firstNameFirst=True),
            "checked_in": self._registrant.isCheckedIn(),
            "checkin_date": checkin_date if self._registrant.isCheckedIn() else None,
            "registration_date": registration_date,
            "payed": self._registrant.getPayed() if self._conf.getModPay().isActivated() else None,
            "pay_amount": self._registrant.getTotal() if self._conf.getModPay().isActivated() else None
        }
        regForm = self._conf.getRegistrationForm()
        personalData = regForm.getPersonalData().getRegistrantValues(self._registrant)
        result.update(personalData)
        return result
예제 #4
0
class SetPaidHook(EventBaseHook):
    PREFIX = "api"
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)/pay'
    METHOD_NAME = 'api_pay'
    NO_CACHE = True
    COMMIT = True
    HTTP_POST = True

    def _getParams(self):
        super(SetPaidHook, self)._getParams()
        self.auth_key = get_query_parameter(self._queryParams, ["auth_key"])
        self.is_paid = get_query_parameter(self._queryParams, ["is_paid"]) == "yes"
        registrant_id = self._pathParams["registrant_id"]
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        self._registrant = self._conf.getRegistrantById(registrant_id)
        if not payment_event_settings.get(self._conf, 'enabled'):
            raise HTTPAPIError('E-payment is not enabled')

    def _hasAccess(self, aw):
        return self._conf.canManageRegistration(aw.getUser()) or self._conf.canModify(aw)

    def api_pay(self, aw):
        action = TransactionAction.complete if self._isPayed == '1' else TransactionAction.cancel
        register_transaction(registrant=self._registrant,
                             amount=self._registrant.getTotal(),
                             currency=self._registrant.getCurrency(),
                             action=action)
        return {
            "paid": self._registrant.getPayed(),
            "amount_paid": self._registrant.getTotal()
        }
예제 #5
0
class UpdatePictureHook(EventBaseHook):
    PREFIX = "api"
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)/updatepicture'
    METHOD_NAME = 'api_update_picture'
    NO_CACHE = True
    COMMIT = True
    HTTP_POST = True

    def _getParams(self):
        super(UpdatePictureHook, self)._getParams()
        self._picture_payload = get_query_parameter(self._queryParams, ["picture_uri"])
        self._secret = get_query_parameter(self._queryParams, ["secret"])
        registrant_id = self._pathParams["registrant_id"]
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        self._registrant = self._conf.getRegistrantById(registrant_id)

    def _hasAccess(self, aw):
        return (self._conf.canManageRegistration(aw.getUser()) or self._conf.canModify(aw)) \
            and self._secret == self._registrant.getCheckInUUID()

    def api_update_picture(self, aw):
        try:
            from indico.util.data_uri import DataURI
            uri = DataURI(self._picture_payload)
            path = self._registrant.getPicture().getFilePath()
            data = uri.data
            _file = open(path,'w')
            _file.write(data)
            _file.close()
            return {"status": "true"}
        except:
            return {"status": "false"}
예제 #6
0
class UpdatePassportHook(EventBaseHook):
    PREFIX = "api"
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)/updatepassport'
    METHOD_NAME = 'api_update_passport'
    NO_CACHE = True
    COMMIT = True
    HTTP_POST = True

    def _getParams(self):
        super(UpdatePassportHook, self)._getParams()
        raw_passport_info = str(get_query_parameter(self._queryParams, ["passport_info"]))
        self._passport_info = json.loads(raw_passport_info,object_hook=ascii_encode_dict)
        self._secret = get_query_parameter(self._queryParams, ["secret"])
        registrant_id = self._pathParams["registrant_id"]
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        self._registrant = self._conf.getRegistrantById(registrant_id)

    def _hasAccess(self, aw):
        return (self._conf.canManageRegistration(aw.getUser()) or self._conf.canModify(aw)) \
            and self._secret == self._registrant.getCheckInUUID()

    def api_update_passport(self, aw):
        try:
            self._registrant.updateFromPassportScan(self._passport_info)
            return {"status": "true"}
        except Exception as e:
            return {"status": "false"}
예제 #7
0
파일: api.py 프로젝트: svdoever/indico
 def _checkParams(self):
     event = ConferenceHolder().getById(request.view_args['event_id'], True)
     if event is None:
         raise NotFound("No such event")
     if not event.canManageRegistration(request.oauth.user):
         raise Forbidden()
     registrant = event.getRegistrantById(request.view_args['registrant_id'])
     if registrant is None:
         raise NotFound("No such registrant")
     self.event = event
     self.registrant = registrant
예제 #8
0
파일: api.py 프로젝트: svdoever/indico
class RegistrantHook(EventBaseHook):
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)'
    METHOD_NAME = 'export_registrant'
    NO_CACHE = True
    DEFAULT_DETAIL = 'basic'

    def _getParams(self):
        super(RegistrantHook, self)._getParams()
        self.auth_key = get_query_parameter(self._queryParams, ["auth_key"])
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        registrant_id = self._pathParams["registrant_id"]
        self._registrant = self._conf.getRegistrantById(registrant_id)

    def _hasAccess(self, aw):
        return self._conf.canManageRegistration(aw.getUser()) or self._conf.canModify(aw)

    def export_registrant(self, aw):
        expInt = RegistrantFetcher(aw, self)
        return expInt.registrant()
예제 #9
0
class RegistrantHook(EventBaseHook):
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)'
    METHOD_NAME = 'export_registrant'
    NO_CACHE = True
    DEFAULT_DETAIL = 'basic'

    def _getParams(self):
        super(RegistrantHook, self)._getParams()
        self.auth_key = get_query_parameter(self._queryParams, ["auth_key"])
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        registrant_id = self._pathParams["registrant_id"]
        self._registrant = self._conf.getRegistrantById(registrant_id)

    def _hasAccess(self, aw):
        return self._conf.canManageRegistration(aw.getUser()) or self._conf.canModify(aw)

    def export_registrant(self, aw):
        expInt = RegistrantFetcher(aw, self)
        return expInt.registrant()
예제 #10
0
class SetPaidHook(EventBaseHook):
    PREFIX = "api"
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)/pay'
    METHOD_NAME = 'api_pay'
    NO_CACHE = True
    COMMIT = True
    HTTP_POST = True

    def _getParams(self):
        super(SetPaidHook, self)._getParams()
        self.auth_key = get_query_parameter(self._queryParams, ["auth_key"])
        self.is_paid = get_query_parameter(self._queryParams,
                                           ["is_paid"]) == "yes"
        registrant_id = self._pathParams["registrant_id"]
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        self._registrant = self._conf.getRegistrantById(registrant_id)
        if not self._conf.getModPay().isActivated():
            raise HTTPAPIError('E-payment is not enabled')

    def _hasAccess(self, aw):
        return self._conf.canManageRegistration(
            aw.getUser()) or self._conf.canModify(aw)

    def api_pay(self, aw):
        if self.is_paid:
            self._registrant.setPayed(True)
            data = {}
            data["OrderTotal"] = self._registrant.getTotal()
            data["Currency"] = self._registrant.getRegistrationForm(
            ).getCurrency()
            transaction = TransactionPayLaterMod(data)
            self._registrant.setTransactionInfo(transaction)
        else:
            self._registrant.setTransactionInfo(None)
            self._registrant.setPayed(False)
        return {
            "paid": self._registrant.getPayed(),
            "amount_paid": self._registrant.getTotal()
        }
예제 #11
0
class SetPaidHook(EventBaseHook):
    PREFIX = "api"
    RE = r'(?P<event>[\w\s]+)/registrant/(?P<registrant_id>[\w\s]+)/pay'
    METHOD_NAME = 'api_pay'
    NO_CACHE = True
    COMMIT = True
    HTTP_POST = True

    def _getParams(self):
        super(SetPaidHook, self)._getParams()
        self.auth_key = get_query_parameter(self._queryParams, ["auth_key"])
        self.is_paid = get_query_parameter(self._queryParams, ["is_paid"]) == "yes"
        registrant_id = self._pathParams["registrant_id"]
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        self._registrant = self._conf.getRegistrantById(registrant_id)
        if not self._conf.getModPay().isActivated():
            raise HTTPAPIError('E-payment is not enabled')

    def _hasAccess(self, aw):
        return self._conf.canManageRegistration(aw.getUser()) or self._conf.canModify(aw)

    def api_pay(self, aw):
        if self.is_paid:
            self._registrant.setPayed(True)
            data = {}
            data["OrderTotal"] = self._registrant.getTotal()
            data["Currency"] = self._registrant.getRegistrationForm().getCurrency()
            transaction = TransactionPayLaterMod(data)
            self._registrant.setTransactionInfo(transaction)
        else:
            self._registrant.setTransactionInfo(None)
            self._registrant.setPayed(False)
        return {
            "paid": self._registrant.getPayed(),
            "amount_paid": self._registrant.getTotal()
        }
예제 #12
0
class BaseRegistrantHook(EventBaseHook):
    METHOD_NAME = 'export_registrant'
    NO_CACHE = True
    DEFAULT_DETAIL = 'basic'

    def _getParams(self):
        super(BaseRegistrantHook, self)._getParams()
        self.auth_key = get_query_parameter(self._queryParams, ["auth_key"])
        self._conf = ConferenceHolder().getById(self._pathParams['event'])
        registrant_id = self._pathParams["registrant_id"]
        self._registrant = self._conf.getRegistrantById(registrant_id)

    def _hasAccess(self, aw):
        return self._conf.canManageRegistration(aw.getUser()) or self._conf.canModify(aw)

    def export_registrant(self, aw, bysession=None):


        expInt = RegistrantFetcher(aw, self)
        result =  expInt.registrant()
        if bysession and not self._registrant.getSession(bysession):
            result["canEnter"] = False
            result["canEnterMessage"] = "The registrant is not approved for this session"
        return result