Beispiel #1
0
def viewClient(ID, user=None):
  if 'usertype' in session:
    if session['usertype'] == 'BiO' or session['usertype'] == 'ADM':
      return render_template('client.html', Client = db.getClient(ID), Detachments = db.getAllDetachmentsbyID(ID), user=escape(session['user']))
    else:
      flash('Unauthorized access')
      return redirect(url_for('logout'))
Beispiel #2
0
    def startSession(self, cardId, clientInfo):
        self._checkRegistered()
        if self._isSessionStarted():
            logging.error(
                "Duplicate start session from simplate id %s, cardId %s",
                unicode(self.simplateId), unicode(cardId))
            raise ServerError("Session already started")

        _logFunction("simplateId=", self.simplateId, ", cardId=", cardId,
                     ", clientInfo=", clientInfo)

        if not TryAddClient(cardId):
            logging.error("Duplicate cardId (simplate Id: %s): %s",
                          unicode(self.simplateId), unicode(cardId))
            raise ServerError("Duplicate cardId")

        client = db.getClient(cardId, self._isBarScenario())
        if not client:
            if self._isShopScenario():
                if cds_settings.MAKE_VIP_CLIENTS:
                    isVip = 1
                else:
                    isVip = 0
                client = db.createClient(cardId,
                                         cds_settings.CLIENT_INITIAL_BALANCE,
                                         isVip, clientInfo)

            elif self._isBarScenario():
                logging.warning(
                    "An unknown client came to the bar. Card id = %s",
                    unicode(cardId))
                RemoveClient(cardId)
                raise ServerError("Unknown client")

            else:  #this should never happen
                logging.critical("Unknown scenarioId: %d:", self.scenarioId)
                RemoveClient(cardId)
                raise ServerError("Unknown scenarioId")

        if not client:
            logging.critical("Could not get client information")
            RemoveClient(cardId)
            raise ServerError("Internal server error. See logs")

        self.cardId = cardId
        return client
Beispiel #3
0
    def startSession(self, cardId, clientInfo):
        self._checkRegistered()
        if self._isSessionStarted():
            logging.error("Duplicate start session from simplate id %s, cardId %s", unicode(self.simplateId), unicode(cardId))
            raise ServerError("Session already started")
            
        _logFunction("simplateId=", self.simplateId, ", cardId=",  cardId,  ", clientInfo=", clientInfo)

        if not TryAddClient(cardId):
            logging.error("Duplicate cardId (simplate Id: %s): %s", unicode(self.simplateId), unicode(cardId))
            raise ServerError("Duplicate cardId")

        
        client = db.getClient(cardId, self._isBarScenario())
        if not client:
            if self._isShopScenario():
                if cds_settings.MAKE_VIP_CLIENTS:
                    isVip = 1
                else:
                    isVip = 0
                client = db.createClient(cardId, cds_settings.CLIENT_INITIAL_BALANCE, isVip, clientInfo)
                
            elif self._isBarScenario():
                logging.warning("An unknown client came to the bar. Card id = %s", unicode(cardId))
                RemoveClient(cardId)
                raise ServerError("Unknown client")

            else: #this should never happen
                logging.critical("Unknown scenarioId: %d:", self.scenarioId)
                RemoveClient(cardId)
                raise ServerError("Unknown scenarioId")

        if not client:
            logging.critical("Could not get client information")
            RemoveClient(cardId)
            raise ServerError("Internal server error. See logs")

        self.cardId = cardId
        return client