flask.ext.login.current_user.id

Here are the examples of the python api flask.ext.login.current_user.id taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

96 Examples 7

Page 1 Selected Page 2

Example 1

Project: JARR Source File: article.py
@article_bp.route('/redirect/<int:article_id>', methods=['GET'])
@login_required
def redirect_to_article(article_id):
    contr = ArticleController(current_user.id)
    article = contr.get(id=article_id)
    if not article.readed:
        contr.update({'id': article.id}, {'readed': True})
    return redirect(article.link)

Example 2

Project: JARR Source File: home.py
@current_app.route('/middle_panel')
@login_required
@etag_match
def get_middle_panel():
    filters = _get_filters(request.args)
    art_contr = ArticleController(current_user.id)
    articles = art_contr.read_light(**filters)
    return _articles_to_json(articles)

Example 3

Project: open-event-orga-server Source File: data_getter.py
    @staticmethod
    def get_sessions_of_user(upcoming_events=True):
        """
        :return: Return all Sessions objects with the current user as a speaker
        """
        if upcoming_events:
            return Session.query.filter(Session.speakers.any(Speaker.user_id == login.current_user.id)).filter(
                Session.start_time >= datetime.datetime.now())
        else:
            return Session.query.filter(Session.speakers.any(Speaker.user_id == login.current_user.id)).filter(
                Session.start_time < datetime.datetime.now())

Example 4

Project: open-event-orga-server Source File: settings.py
    @expose('/contact-info/', methods=('POST', 'GET'))
    def contact_info_view(self):
        user_id = login.current_user.id
        if request.method == 'POST':
            url = ""
            DataManager.update_user(request.form, int(user_id), url, contacts_only_update=True)
            flash("Your contact info has been updated.", "success")
            return redirect(url_for('.contact_info_view'))
        profile = DataGetter.get_user(int(user_id))

        return self.render('/gentelella/admin/settings/pages/contact_info.html', user=login.current_user)

Example 5

Project: open-event-orga-server Source File: data_getter.py
    @staticmethod
    def get_past_events():
        events = Event.query.join(Event.roles, aliased=True).filter_by(user_id=login.current_user.id) \
            .filter(Event.end_time <= datetime.datetime.now()).filter(
            or_(Event.state == 'Completed', Event.state == 'Published')).filter(Event.in_trash is not True)
        return DataGetter.trim_attendee_events(events)

Example 6

Project: cloud-asr Source File: run.py
@identity_loaded.connect_via(app)
def on_identity_loaded(sender, identity):
    identity.user = current_user

    if hasattr(current_user, 'id'):
        identity.provides.add(UserNeed(current_user.id))

    if hasattr(current_user, 'admin') and current_user.admin:
        identity.provides.add(RoleNeed('admin'))

Example 7

Project: JARR Source File: feed.py
@feeds_bp.route('/inactives', methods=['GET'])
@login_required
def inactives():
    """
    List of inactive feeds.
    """
    nb_days = int(request.args.get('nb_days', 365))
    inactives = FeedController(current_user.id).get_inactives(nb_days)
    return render_template('inactives.html',
                           inactives=inactives, nb_days=nb_days)

Example 8

Project: JARR Source File: home.py
@jsonify
def _articles_to_json(articles):
    now, locale = datetime.now(), get_locale()
    fd_hash = {feed.id: {'title': feed.title,
                         'icon_url': url_for('icon.icon', url=feed.icon_url)
                                     if feed.icon_url else None}
               for feed in FeedController(current_user.id).read()}

    return {'articles': [{'title': art.title, 'liked': art.like,
            'read': art.readed, 'article_id': art.id, 'selected': False,
            'feed_id': art.feed_id, 'category_id': art.category_id or 0,
            'feed_title': fd_hash[art.feed_id]['title'],
            'icon_url': fd_hash[art.feed_id]['icon_url'],
            'date': format_datetime(localize(art.date), locale=locale),
            'rel_date': format_timedelta(art.date - now,
                    threshold=1.1, add_direction=True,
                    locale=locale)}
            for art in articles.limit(1000)]}

Example 9

Project: flask-basic-registration Source File: test_models.py
Function: test_get_by_id
    def test_get_by_id(self):
        # Ensure id is correct for the current/logged in user
        with self.client:
            self.client.post('/login', data=dict(
                email='[email protected]', password='admin_user'
            ), follow_redirects=True)
            self.assertTrue(current_user.id == 1)

Example 10

Project: rootio_web Source File: views.py
@content.route('/medias/')
@login_required
def content_medias():
    content_type = ContentType.query.filter(ContentType.name=='Media').first()
    medias = ContentUploads.query.join(ContentTrack).filter(ContentUploads.uploaded_by==current_user.id).filter(ContentTrack.type_id==content_type.id).order_by(ContentUploads.order).all()
    return render_template('content/content_medias.html', medias=medias)

Example 11

Project: open-event-orga-server Source File: settings.py
def get_or_create_notification_settings(event_id):
    email_notification = DataGetter \
        .get_email_notification_settings_by_event_id(login.current_user.id, event_id)
    if email_notification:
        return email_notification
    else:
        email_notification = EmailNotification(next_event=1,
                                               new_paper=1,
                                               session_schedule=1,
                                               session_accept_reject=1,
                                               user_id=login.current_user.id,
                                               event_id=event_id)
        return email_notification

Example 12

Project: open-event-orga-server Source File: event.py
Function: has_staff_access
    def has_staff_access(self):
        """does user have role other than attendee"""
        access = False
        for _ in self.roles:
            if _.user_id == login.current_user.id:
                if _.role.name != ATTENDEE:
                    access = True
        return access

Example 13

Project: pybossa Source File: admin.py
Function: index
@blueprint.route('/')
@login_required
@admin_required
def index():
    """List admin actions."""
    key = NOTIFY_ADMIN + str(current_user.id)
    sentinel.master.delete(key)
    return render_template('/admin/index.html')

Example 14

Project: total-impact-webapp Source File: views.py
def current_user_owns_tiid(tiid):
    try:
        profile_for_current_user = db.session.query(Profile).get(int(current_user.id))
        db.session.expunge(profile_for_current_user)
        return tiid in profile_for_current_user.tiids
    except AttributeError:  #Anonymous
        return False

Example 15

Project: rootio_web Source File: views.py
@content.route('/ads/')
@login_required
def content_ads():
    content_type = ContentType.query.filter(ContentType.name=='Advertisements').first()
    ads = ContentUploads.query.join(ContentTrack).filter(ContentUploads.uploaded_by==current_user.id).filter(ContentTrack.type_id==content_type.id).all()
    return render_template('content/content_ads.html', ads=ads)  

Example 16

Project: JARR Source File: article.py
Function: history
@articles_bp.route('/history', methods=['GET'])
@articles_bp.route('/history/<int:year>', methods=['GET'])
@articles_bp.route('/history/<int:year>/<int:month>', methods=['GET'])
@login_required
def history(year=None, month=None):
    cntr, artcles = ArticleController(current_user.id).get_history(year, month)
    return render_template('history.html', articles_counter=cntr,
                           articles=artcles, year=year, month=month)

Example 17

Project: online-ratings Source File: views.py
Function: create_p_layer
@ratings.route('/players', methods=['POST'])
@login_required
def create_player():
    form = AddPlayerForm()
    form.server.choices = [(server.id, server.name) for server in GoServer.query.all()]
    if form.validate_on_submit():
        server_id = form.server.data
        name = form.name.data
        db.session.add(Player(name=name, server_id=server_id, user_id=current_user.id, token=generate_token()))
        db.session.commit()

    return redirect(url_for('ratings.profile'))

Example 18

Project: JARR Source File: home.py
@current_app.route('/')
@login_required
@etag_match
def home():
    UserController(current_user.id).update({'id': current_user.id},
            {'last_connection': datetime.utcnow()})
    return render_template('home.html')

Example 19

Project: JARR Source File: feed.py
@feed_bp.route('/duplicates/<int:feed_id>', methods=['GET'])
@login_required
def duplicates(feed_id):
    """
    Return duplicates article for a feed.
    """
    feed, duplicates = FeedController(current_user.id).get_duplicates(feed_id)
    if len(duplicates) == 0:
        flash(gettext('No duplicates in the feed "{}".').format(feed.title),
                'info')
        return redirect(url_for('home'))
    return render_template('duplicates.html', duplicates=duplicates, feed=feed)

Example 20

Project: JARR Source File: user.py
@user_bp.route('/opml/export', methods=['GET'])
@login_required
def opml_export():
    user = UserController(current_user.id).get(id=current_user.id)
    categories = {cat.id: cat
            for cat in CategoryController(current_user.id).read()}
    response = make_response(render_template('opml.xml', user=user,
           categories=categories, feeds=FeedController(current_user.id).read(),
           now=datetime.now()))
    response.headers['Content-Type'] = 'application/xml'
    response.headers['Content-Disposition'] = 'attachment; filename=feeds.opml'
    return response

Example 21

Project: open-event-orga-server Source File: data_getter.py
    @staticmethod
    def get_all_owner_files():
        """
        :return: All owner files
        """
        files = File.query.filter_by(owner_id=login.current_user.id)
        return files

Example 22

Project: open-event-orga-server Source File: data_getter.py
    @staticmethod
    def get_live_events():
        events = Event.query.join(Event.roles, aliased=True).filter_by(user_id=login.current_user.id) \
            .filter(Event.end_time >= datetime.datetime.now()) \
            .filter(Event.state == 'Published').filter(Event.in_trash is not True)
        return DataGetter.trim_attendee_events(events)

Example 23

Project: open-event-orga-server Source File: data_getter.py
    @staticmethod
    def get_all_files_tuple():
        """
        :return All files filtered by owner, Format [(test.png, test1.png)...]:
        """
        files = File.query.filter_by(owner_id=login.current_user.id)
        return [(file_obj.name, file_obj.name) for file_obj in files]

Example 24

Project: open-event-orga-server Source File: ticketing.py
    @staticmethod
    def get_orders_of_user(user_id=None, upcoming_events=True):
        """
        :return: Return all order objects with the current user
        """
        if not user_id:
            user_id = login.current_user.id
        query = Order.query.join(Order.event) \
            .filter(Order.user_id == user_id) \
            .filter(or_(Order.status == 'completed', Order.status == 'placed'))
        if upcoming_events:
            return query.filter(Event.start_time >= datetime.now())
        else:
            return query.filter(Event.end_time < datetime.now())

Example 25

Project: rootio_web Source File: views.py
Function: index
@radio.route('/', methods=['GET'])
def index():
    #get the stations in networks that I am associated with
    stations = Station.query.join(Network).join(User, Network.networkusers).filter(User.id == current_user.id).all()
    #stations = Station.query.join(Network).join(User).filter(User.id == current_user.id).all()
    return render_template('radio/index.html',stations=stations, userid=current_user.id)

Example 26

Project: open-event-orga-server Source File: profile.py
Function: edit_view
    @expose('/edit/', methods=('GET', 'POST'))
    @expose('/edit/<user_id>', methods=('GET', 'POST'))
    def edit_view(self, user_id=None):
        admin = None
        if not user_id:
            user_id = login.current_user.id
        else:
            admin = True
        if request.method == 'POST':
            url = ""
            DataManager.update_user(request.form, int(user_id), url)
            if admin:
                return redirect(url_for('sadmin_users.details_view', user_id=user_id))
            return redirect(url_for('.index_view'))
        profile = DataGetter.get_user(int(user_id))
        return self.render('/gentelella/admin/profile/edit.html', profile=profile)

Example 27

Project: open-event-orga-server Source File: home.py
    @expose('/resend_email/')
    def resend_email_confirmation(self):
        user = DataGetter.get_user(login.current_user.id)
        s = get_serializer()
        data = [user.email, str_generator()]
        form_hash = s.dumps(data)
        link = url_for('.create_account_after_confirmation_view', hash=form_hash, _external=True)
        form = {"email": user.email, "password": user.password}
        form = ImmutableMultiDict(form)
        send_email_confirmation(form, link)
        return redirect(url_for('events.index_view'))

Example 28

Project: pybossa Source File: util.py
def get_user_id_or_ip():
    """Return the id of the current user if is authenticated.
    Otherwise returns its IP address (defaults to 127.0.0.1).
    """
    user_id = current_user.id if current_user.is_authenticated() else None
    user_ip = request.remote_addr or "127.0.0.1" \
        if current_user.is_anonymous() else None
    return dict(user_id=user_id, user_ip=user_ip)

Example 29

Project: open-event-orga-server Source File: settings.py
    @expose('/email-preferences/')
    def email_preferences_view(self):
        events = DataGetter.get_all_events()
        message_settings = DataGetter.get_all_message_setting()
        settings = DataGetter.get_email_notification_settings(login.current_user.id)
        return self.render('/gentelella/admin/settings/pages/email_preferences.html',
                           settings=settings, events=events, message_settings=message_settings)

Example 30

Project: rootio_web Source File: views.py
@content.route('/tracks/add/', methods=['GET', 'POST'])
@login_required
def track_add():
    form = ContentTrackForm(request.form)
    tracks = None
    if form.validate_on_submit():

        cleaned_data = form.data #make a copy
        cleaned_data['uploaded_by'] = current_user.id
        cleaned_data.pop('submit',None) #remove submit field from list
        tracks = ContentTrack(**cleaned_data) #create new object from data
        db.session.add(tracks)
        db.session.commit()
        flash(_('Track added.'), 'success') 
    elif request.method == "POST":
        flash(_('Validation error'),'error')
    return render_template('content/track.html', tracks=tracks, form=form)

Example 31

Project: total-impact-webapp Source File: views.py
def abort_if_user_not_logged_in(profile):
    allowed = True
    try:
        if current_user.id != profile.id:
            abort_json(401, "You can't do this because it's not your profile.")
    except AttributeError:
        abort_json(405, "You can't do this because you're not logged in.")

Example 32

Project: WAPT Source File: core.py
def _on_identity_loaded(sender, identity):
    if hasattr(current_user, 'id'):
        identity.provides.add(UserNeed(current_user.id))

    for role in current_user.roles:
        identity.provides.add(RoleNeed(role.name))

    identity.user = current_user

Example 33

Project: total-impact-webapp Source File: views.py
@app.before_request
def load_globals():
    g.user = current_user
    try:
        g.user_id = current_user.id
    except AttributeError:
        g.user_id = None

    g.api_key = os.getenv("API_KEY")
    g.webapp_root = os.getenv("WEBAPP_ROOT_PRETTY", os.getenv("WEBAPP_ROOT"))

Example 34

Project: Flask-Fragment Source File: ssiblog.py
@app.route('/new/post', methods=['GET', 'POST'])
@login_required
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        form.post.author_id = current_user.id
        db.session.add(form.post)
        db.session.commit()
        fragment.reset(posts_list)
        fragment.reset(user_info, current_user.id)
        flash('Your post has saved successfully.', 'info')
        return redirect(url_for('index'))
    return render_template('newpost.html', form=form)

Example 35

Project: JARR Source File: article.py
def delete(article_id=None):
    "Delete an article from the database."
    article = ArticleController(current_user.id).delete(article_id)
    flash(gettext('Article %(article_title)s deleted',
                  article_title=article.title), 'success')
    return redirect(url_for('home'))

Example 36

Project: online-ratings Source File: views.py
@ratings.route('/profile')
@login_required
def profile():
    form = AddPlayerForm()
    form.server.choices = [(server.id, server.name) for server in GoServer.query.all()]
    players = Player.query.filter(Player.user_id == current_user.id).order_by(Player.name.asc()).all()
    if current_user.is_ratings_admin():
        games = Game.query.limit(30).all()
    else:
        games = itertools.chain(*(Game.query.filter(or_(Game.white_id == player.id, Game.black_id == player.id)) for player in players))
    return render_template('profile.html', user=current_user, games=games, players=players, form=form)

Example 37

Project: JARR Source File: feed.py
@feeds_bp.route('/', methods=['GET'])
@login_required
@etag_match
def feeds():
    "Lists the subscribed  feeds in a table."
    art_contr = ArticleController(current_user.id)
    return render_template('feeds.html',
            feeds=FeedController(current_user.id).read(),
            unread_article_count=art_contr.count_by_feed(readed=False),
            article_count=art_contr.count_by_feed())

Example 38

Project: rootio_web Source File: views.py
@content.route('/news/')
@login_required
def content_news():
    name_content = 'News'
    content_type = ContentType.query.filter(ContentType.name=='News').first()
    content_news = ContentUploads.query.join(ContentTrack).filter(ContentUploads.uploaded_by==current_user.id).filter(ContentTrack.type_id==content_type.id).all()
    return render_template('content/content_news.html', content_news=content_news)

Example 39

Project: JARR Source File: home.py
@current_app.route('/mark_all_as_read', methods=['PUT'])
@login_required
def mark_all_as_read():
    filters = _get_filters(request.json)
    acontr = ArticleController(current_user.id)
    processed_articles = _articles_to_json(acontr.read_light(**filters))
    acontr.update(filters, {'readed': True})
    return processed_articles

Example 40

Project: rootio_web Source File: views.py
@content.route('/streams/')
@login_required
def content_streams():
    content_type = ContentType.query.filter(ContentType.name=='Streams').first()
    content_streams = ContentUploads.query.join(ContentTrack).filter(ContentUploads.uploaded_by==current_user.id).filter(ContentTrack.type_id==content_type.id).all()
    return render_template('content/content_streams.html', content_streams=content_streams) 

Example 41

Project: rootio_web Source File: views.py
Function: schedule
@radio.route('/schedule/', methods=['GET'])
def schedule():
    #TODO, if user is authorized to view only one station, redirect them there
    stations = Station.query.join(Network).join(User, Network.networkusers).filter(User.id == current_user.id).all()
    #stations = Station.query.order_by('name').all()

    return render_template('radio/schedules.html',
        stations=stations, active='schedule')

Example 42

Project: open-event-orga-server Source File: profile.py
Function: index_view
    @expose('/')
    def index_view(self):
        if not is_verified_user():
            flash("Your account is unverified. "
                  "Please verify by clicking on the confirmation link that has been emailed to you.")
        profile = DataGetter.get_user(login.current_user.id)
        return self.render('/gentelella/admin/profile/index.html',
                           profile=profile)

Example 43

Project: rootio_web Source File: forms.py
def streams_tracks():
    content_type = ContentType.query.filter(ContentType.name=='Stream').first()
    return ContentTrack.query.filter_by(uploaded_by=current_user.id).filter(ContentTrack.type_id==content_type.id).all() 

Example 44

Project: rootio_web Source File: views.py
@content.route('/uploads/')
@login_required
def content_uploads():
    content_uploads = ContentUploads.query.filter_by(uploaded_by=current_user.id).all()
    return render_template('content/content_uploads.html', content_uploads=content_uploads)

Example 45

Project: rootio_web Source File: forms.py
def news_tracks():
    content_type = ContentType.query.filter(ContentType.name=='News').first()
    return ContentTrack.query.filter_by(uploaded_by=current_user.id).filter(ContentTrack.type_id==content_type.id).all() 

Example 46

Project: rootio_web Source File: forms.py
def musics_tracks():
    content_type = ContentType.query.filter(ContentType.name=='Media').first()
    return ContentTrack.query.filter_by(uploaded_by=current_user.id).filter(ContentTrack.type_id==content_type.id).all()  

Example 47

Project: rootio_web Source File: forms.py
Function: stations
def stations():
    return Station.query.join(Network).join(User).filter(User.id==current_user.id).all()

Example 48

Project: rootio_web Source File: forms.py
def all_tracks():
    return ContentTrack.query.filter_by(uploaded_by=current_user.id).all()

Example 49

Project: rootio_web Source File: forms.py
def adds_tracks():
    content_type = ContentType.query.filter(ContentType.name=='Advertisements').first()
    return ContentTrack.query.filter_by(uploaded_by=current_user.id).filter(ContentTrack.type_id==content_type.id).all()    

Example 50

Project: rootio_web Source File: views.py
Function: tracks
@content.route('/tracks/')
@login_required
def tracks():
    tracks = ContentTrack.query.filter_by(uploaded_by=current_user.id).all()
    return render_template('content/tracks.html', tracks=tracks, active='tracks')
See More Examples - Go to Next Page
Page 1 Selected Page 2