Пример #1
0
    def is_accessible(self):
        if not current_user.is_active() or not current_user.is_authenticated():
            return False

        if current_user.has_role('superuser'):
            return True

        return False
Пример #2
0
    def is_accessible(self):
        if not current_user.is_active() or not current_user.is_authenticated():
            return False

        if current_user.has_role(Constants.ADMIN_ROLE):
            return True

        return False
Пример #3
0
    def is_accessible(self):
        if not current_user.is_active() or not current_user.is_authenticated:
            return False

        if current_user.has_role('admin'):
            return True

        return False
Пример #4
0
    def is_accessible(self):
        if not current_user.is_active() or not current_user.is_authenticated():
            return False

        if current_user.has_role(Constants.ADMIN_ROLE):
            return True

        return False
Пример #5
0
def can_add_thing_to_collection(collection, thing=None):
    if thing and collection.has_thing(thing):
        return False
    if collection.accessibility == 'public':
        return current_user.is_active() and current_user.is_authenticated()
    elif collection.accessibility == 'semi-public':
        return current_user.has_role('admin') or current_user.has_role('editor') or collection.is_creator(current_user) or collection.has_editor(current_user)
    elif collection.accessibility == 'private':
        return current_user.has_role('admin') or current_user.has_role('editor') or collection.is_creator(current_user) or collection.has_editor(current_user)
Пример #6
0
    def is_accessible(self):
        if not self.require_authentication:
            return True

        if not current_user.is_active() or not current_user.is_authenticated():
            return False

        if all(current_user.has_role(r) for r in self.required_roles):
            return True

        return False
Пример #7
0
    def is_accessible(self):
        if not self.require_authentication:
            return True

        if not current_user.is_active() or not current_user.is_authenticated():
            return False

        if all(current_user.has_role(r) for r in self.required_roles):
            return True

        return False
Пример #8
0
    def is_accessible(self):
        if not current_user.is_active() or not current_user.is_authenticated():
            return False

        if current_user.is_authenticated():
            return True

        '''if current_user.has_role('admin'):
            return True'''

        return False
Пример #9
0
    def is_accessible(self):
        if (
            not current_user.is_active()
            or not current_user.is_authenticated()
        ):
            return False

        if current_user.has_role("superuser"):
            return True

        return False
Пример #10
0
def can_add_thing_to_collection(collection, thing=None):
    if thing and collection.has_thing(thing):
        return False
    if collection.accessibility == 'public':
        return current_user.is_active() and current_user.is_authenticated()
    elif collection.accessibility == 'semi-public':
        return current_user.has_role('admin') or current_user.has_role(
            'editor') or collection.is_creator(
                current_user) or collection.has_editor(current_user)
    elif collection.accessibility == 'private':
        return current_user.has_role('admin') or current_user.has_role(
            'editor') or collection.is_creator(
                current_user) or collection.has_editor(current_user)
Пример #11
0
def return_label():
    '''
    Retrun label
    '''

    rm = resources.model
    fill_selects()
    weather = get_weather()
    if weather:
        track = db.session.query(rm.Track).filter_by(id=weather.track).first()
        g.session = weather.session
    else:
        track = False
    if not track:
        name = u"Трек не выбран"
    else:
        name = track.name
    form = ReturnLabel()
    if current_user.is_anonymous():
        g.anonymous = 1
        user_info = None
    else:
        g.anonymous = 0
        user_info = db.session.query(rm.UserInfo).filter_by(id=current_user.user_info).first()
    if form.validate_on_submit():
        rf = request.form
        if rf.getlist('btn_user_ok'):
            login_user(form.user, remember=False)
            if current_user.is_active():
                g.anonymous = 0
                user_info = db.session.query(rm.UserInfo).filter_by(id=current_user.user_info).first()
        if rf.getlist('btn_ok'):
            label=re.sub(r'(\.)+',r'',rf.getlist('label_id')[0])
            label_id = db.session.query(rm.Label).filter_by(label_id=label).first()
            if label_id == None:
                g.label_id = 'None'
                return render_template('return_label.html', form=form, weather=weather, track=name, user_info=user_info)
            if label_id != None and label_id.user_id == 0:
                g.label_id = 0
                return render_template('return_label.html', form=form, weather=weather, track=name, user_info=user_info)
            if label_id != None and label_id.user_id > 0:
                # g.label_id = label_id.label_id
                db.session.query(rm.Label).filter_by(label_id=label).update({'user_id':0})
                db.session.commit()
                return render_template('return_label.html', form=form, weather=weather, track=name, user_info=user_info)
        if rf.getlist('btn_cancel'):
            return redirect('/admin')
    return render_template('return_label.html', form=form, weather=weather, track=name, user_info=user_info)
Пример #12
0
    def validate(self):

        if current_user.is_anonymous():
            if self.user_phone.data.strip() == '':
                return False

            self.user = find_user(user_phone=self.user_phone.data)

            if self.user is None:
                g.user_unexists = 1
                return False

        if current_user.is_active():
            if self.label_id.data.strip() == '':
                return False

        return True
Пример #13
0
    def before_request(self, name, **kwargs):
        if current_user.is_active():
            g.items = Item.objects(user_ref=current_user.id)

            if g.items and g.items[0].created_today():
                g.grateful_today = True