Exemplo n.º 1
0
    def log_in(self, request, username, password, **kws):
        session = get_session('school')
        account = session.query(Account).filter(
            func.lower(Account.email) == username.lower())

        if account.count() == 1:
            account = account.first()
        else:
            account = None
            send(u"Benutzer konnte nicht gefunden werden", BASE_MESSAGE_TYPE)
            return 

        if account is not None:
            return account
            pwhash = hashed(password, account.salt)
            if account.password == pwhash:
                if account.activated is not None:
                    return account
                activation = kws.get('activation')
                if activation is not None:
                    if activation == account.activation:
                        account.activated = datetime.now()
                        return account
                    else:
                        return SuccessMarker(
                            'Activation failed', False,
                            url=activate_url(request.path, **kws))
                else:
                    return SuccessMarker(
                        'Aktivierungs-Key Fehlt', False,
                        url=activate_url(request.path, **kws))
        send("Falsches Passwort", BASE_MESSAGE_TYPE)
        return None
Exemplo n.º 2
0
def test_send_receive():
    utils.send('Something')

    messages = utils.receive('nothing')
    assert messages == None

    messages = list(utils.receive())
    assert len(messages) == 1
    assert messages[0]['type'] == BASE_MESSAGE_TYPE
Exemplo n.º 3
0
 def __call__(self, form):
     form.updateLines(mark_selected=True)
     session = get_session(form.context.db_key)
     for line in form.lines:
         if line.selected:
             obj = line.getContent()
             session.delete(obj)
     send(_(u"Deletion successful."))
     url = get_absolute_url(form.context, form.request)
     return SuccessMarker('Deleted', True, url=url)
Exemplo n.º 4
0
 def __call__(self, form):
     form.updateLines(mark_selected=True)
     session = get_session(form.context.db_key)
     for line in form.lines:
         if line.selected:
             obj = line.getContent()
             session.delete(obj)
     send(_(u"Deletion successful."))
     url = get_absolute_url(form.context, form.request)
     return SuccessMarker('Deleted', True, url=url)
Exemplo n.º 5
0
def test_send_receive_some():
    """verify we get all message if there are some"""
    utils.send('Tomorrow, and tomorrow, and tomorrow,')
    utils.send('Creeps in this petty pace from day to day,')
    utils.send('To the last syllable of recorded time;')
    utils.send('And all our yesterdays have lighted fools')
    utils.send('The way to dusty death. Out, out, brief candle!')

    messages = list(utils.receive())
    assert len(messages) == 5
Exemplo n.º 6
0
    def Update(self):
        data, errors = self.extractData()
        if errors:
            self.submissionError = errors
            return FAILURE

        session = self.context.__parent__.session
        apply_data_event(self.fields, self.context, data)
        session.add(self.context)

        send(_(u"Your contents get updated."))
        url = get_absolute_url(self.context, self.request)
        return SuccessMarker("Updated", True, url=url)
Exemplo n.º 7
0
    def Update(self):
        data, errors = self.extractData()
        if errors:
            self.submissionError = errors
            return FAILURE

        session = self.context.__parent__.session
        apply_data_event(self.fields, self.context, data)
        session.add(self.context)

        send(_(u"Your contents get updated."))
        url = get_absolute_url(self.context, self.request)
        return SuccessMarker('Updated', True, url=url)
Exemplo n.º 8
0
    def add(self):
        data, errors = self.extractData()
        if errors:
            return FAILURE

        if data["activation"] != ON_DATES:
            del data["enable"]
            del data["disable"]

        item = self.context.model(**data)
        self.context.add(item)
        send(_(u"Content created."))
        url = get_absolute_url(self.context, self.request)
        return SuccessMarker("Created", True, url=url)
Exemplo n.º 9
0
    def add(self):
        data, errors = self.extractData()
        if errors:
            return FAILURE

        if data['activation'] != ON_DATES:
            del data['enable']
            del data['disable']

        item = self.context.model(**data)
        self.context.add(item)
        send(_(u"Content created."))
        url = get_absolute_url(self.context, self.request)
        return SuccessMarker('Created', True, url=url)
Exemplo n.º 10
0
def test_send_receive_type():
    result = utils.send('Something', type='error')
    assert result == True

    messages = list(utils.receive(type='nothing'))
    assert len(messages) == 0

    messages = list(utils.receive())
    assert len(messages) == 0

    messages = list(utils.receive(type='error'))
    assert len(messages) == 1
Exemplo n.º 11
0
 def flash(self, message, type=BASE_MESSAGE_TYPE):
     return send(message, type=type)
Exemplo n.º 12
0
def message(message):
    send(message)
Exemplo n.º 13
0
def test_send_receive_failing_name():
    messages = utils.receive(name='unexisting')
    assert messages == None

    result = utils.send('Some message', name='unexisting')
    assert result == False
Exemplo n.º 14
0
def message(message):
    send(message)