Exemple #1
0
def add_admin_links(sender, **kwds):
    """Add our views to the admin interface"""

    priv_check = kwds['request'].user.has_privilege

    entries = [('list', url_for('admin/news'), _(u'Overview'))]

    if priv_check(NEWS_CREATE) or priv_check(NEWS_EDIT):
        entries.append(('edit', url_for('admin/news/new'), _(u'Write')))

    kwds['navbar'].insert(1,(('news', url_for('admin/news'), _(u'News'), entries)))
Exemple #2
0
def add_admin_links(sender, **kwds):
    """Add our views to the admin interface"""

    priv_check = kwds['request'].user.has_privilege

    if not priv_check(WAR_MANAGE):
        return

    entries = [('wars', url_for('admin/wars'), _(u'Wars')),
               ('maps', url_for('admin/warmaps'), _(u'Maps')),
               ('modes', url_for('admin/warmodes'), _(u'Modes'))]

    kwds['navbar'].insert(1, ('war', url_for('admin/wars'), _(u'War Management'), entries))
Exemple #3
0
def add_admin_links(sender, **kwds):
    """Add our views to the admin interface"""

    priv_check = kwds['request'].user.has_privilege

    entries = [('squads', url_for('admin/squads'), _(u'Squads'))]

    if priv_check(GAME_MANAGE):
        entries.insert(0,('games', url_for('admin/games'), _(u'Games')))

    if priv_check(LEVEL_MANAGE):
        entries.append(('levels', url_for('admin/levels'), _(u'Levels')))

    kwds['navbar'].insert(1, ('gamesquad', url_for('admin/squads'), _(u'Games and Squads'), entries))
Exemple #4
0
def forum_edit(request, forum_id=None):
    """Edit an existing forum or create a new one."""

    forum = None
    if forum_id is not None:
        forum = Forum.query.get(forum_id)
        if forum is None:
            raise NotFound()
    form = ForumForm(forum)

    if request.method == 'POST':
        if 'cancel' in request.form:
            return form.redirect(forum_endpoints['list'])
        elif 'delete' in request.form and forum:
            return redirect_to(forum_endpoints['delete'], forum_id=forum_id)
        elif form.validate(request.form):
            if forum is None:
                forum = form.create_forum()
                msg = _('The forum %s was created successfully.')
                icon = 'add'
            else:
                form.save_changes(forum)
                msg = _('The forum %s was updated successfully.')
                icon = 'info'

            admin_flash(msg % ('<a href="%s">%s</a>' % (url_for(forum_endpoints['edit'], forum_id=forum.id),
                               escape(forum.name))), icon)

            if 'save_and_continue' in request.form:
                return redirect_to(forum_endpoints['edit'], forum_id=forum_id)
            elif 'save_and_new' in request.form:
                return redirect_to(forum_endpoints['edit'])
            return redirect_to(forum_endpoints['list'])
    return render_admin_response('admin/board_base_edit.html', 'board.forums',
                                 form=form.as_widget(), itemname=_('Forum'))
Exemple #5
0
def category_edit(request, category_id=None):
    """Edit an existing category or create a new one."""

    category = None
    if category_id is not None:
        category = Category.query.get(category_id)
        if category is None:
            raise NotFound()
    form = CategoryForm(category)

    if request.method == 'POST':
        if 'cancel' in request.form:
            return form.redirect(cat_endpoints['list'])
        elif 'delete' in request.form and category:
            return redirect_to(cat_endpoints['delete'], category_id=category_id)
        elif form.validate(request.form):
            if category is None:
                category = form.create_category()
                msg = _('Category %s was created successfully.')
                icon = 'add'
            else:
                form.save_changes(category)
                msg = _('Category %s was updated successfully.')
                icon = 'info'

            admin_flash(msg % ('<a href="%s">%s</a>' % (url_for(cat_endpoints['edit'], category_id=category.id),
                               escape(category.name))), icon)

            if 'save_and_continue' in request.form:
                return redirect_to(cat_endpoints['edit'], category_id=category_id)
            elif 'save_and_new' in request.form:
                return redirect_to(cat_endpoints['edit'])
            return redirect_to(cat_endpoints['list'])
    return render_admin_response('admin/board_base_edit.html', 'board.categories',
                                 form=form.as_widget(), itemname=_('Category'))
Exemple #6
0
 def __init__(self, show_title=True, title=u'Shoutbox', entrycount=10, hide_form=False):
     super(ShoutboxWidget, self).__init__()
     self.title = title
     self.show_title = show_title
     self.hide_form = hide_form
     self.entries = ShoutboxEntry.query.order_by(ShoutboxEntry.postdate.desc()) \
                                 .limit(entrycount).all()
     self.newposturl = escape(url_for('shoutbox/post', next=get_request().path))
Exemple #7
0
    def url(self):
        """Return a default pic link, the magic gravatar url or
           a link to the uploaded picture, if any
        """

        from pyClanSphere.api import get_application, url_for
        app = get_application()
        size = app.theme.settings['avatar.size']
        pictype = self.user.userpictype
        if not pictype or pictype == u'None':
            return app.cfg['avatar_default'] if app.cfg['avatar_default'] \
                else url_for('core/shared', filename='nopicture.jpg')
        if self.user.userpictype == u'Gravatar':
            gravatar_url = "http://www.gravatar.com/avatar/"
            gravatar_url += md5(self.user.email).hexdigest() + "?"
            gravatar_url += urlencode({'size':str(size)})
            return gravatar_url
        else:
            return url_for('userpics/shared', filename=self.filename)
Exemple #8
0
 def get_url_values(self):
     from pyClanSphere.api import url_for
     return url_for('core/profile', user_id=self.id)
Exemple #9
0
def add_account_links(sender, **kwds):
    """Add our views to the account interface"""

    kwds['navbar'].insert(2, ('gameaccounts', url_for('account/gameaccounts'), _(u'Gameaccounts'),[]))