<commit_before># -*- coding: utf-8 -*-
"""
    pyClanSphere.plugins.war_module
    ~~~~~~~~~~~~~~~~~~~~~~~

    Plugin implementation description goes here.

    :copyright: (c) 2009 by the pyClanSphere Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""

from os.path import join, dirname, exists
from os import makedirs

from pyClanSphere.api import url_for, _

from pyClanSphere.plugins.war import views
from pyClanSphere.plugins.war.database import init_database
from pyClanSphere.plugins.war.privileges import PLUGIN_PRIVILEGES, WAR_MANAGE

TEMPLATE_FILES = join(dirname(__file__), 'templates')

def add_admin_links(request, navigation_bar):
    """Add our views to the admin interface"""

    priv_check = request.user.has_privilege

    if not priv_check(WAR_MANAGE):
        return

    entries = [('wars', url_for('admin/war_list'), _(u'Wars')),
               ('maps', url_for('admin/warmap_list'), _(u'Maps')),
               ('modes', url_for('admin/warmode_list'), _(u'Modes'))]

    navigation_bar.insert(-3, ('war', url_for('admin/war_list'), _(u'War Management'), entries))

def setup(app, plugin):

    # Setup tables
    init_database()

    # Add our privileges
    for priv in PLUGIN_PRIVILEGES.values():
        app.add_privilege(priv)

    # Add our template path
    app.add_template_searchpath(TEMPLATE_FILES)

    # war related pages
    app.add_url_rule('/wars/', endpoint='wars/index', defaults={'page': 1},
                     view=views.war_index)
    app.add_url_rule('/wars/page/<int:page>', endpoint='wars/index')
    app.add_url_rule('/wars/<int:war_id>', endpoint='wars/detail',
                     view=views.war_detail)
    app.add_url_rule('/wars/fightus', endpoint='wars/fightus',
                     view=views.war_fightus)

    # Admin views
    app.add_url_rule('/wars/', prefix='admin', defaults={'page': 1}, endpoint='admin/war_list',
                     view=views.war_list)
    app.add_url_rule('/wars/page/<int:page>', prefix='admin', endpoint='admin/war_list')
    app.add_url_rule('/wars/new', prefix='admin', endpoint='admin/war_create',
                     view=views.war_edit)
    app.add_url_rule('/wars/<int:war_id>', prefix='admin', endpoint='admin/war_edit',
                     view=views.war_edit)
    app.add_url_rule('/wars/<int:war_id>/delete', prefix='admin', endpoint='admin/war_delete',<commit_msg>This breaks non-sysadmins backend design<commit_after># -*- coding: utf-8 -*-
"""
    pyClanSphere.plugins.war_module
    ~~~~~~~~~~~~~~~~~~~~~~~

    Plugin implementation description goes here.

    :copyright: (c) 2009 by the pyClanSphere Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""

from os.path import join, dirname, exists
from os import makedirs

from pyClanSphere.api import url_for, _

from pyClanSphere.plugins.war import views
from pyClanSphere.plugins.war.database import init_database
from pyClanSphere.plugins.war.privileges import PLUGIN_PRIVILEGES, WAR_MANAGE

TEMPLATE_FILES = join(dirname(__file__), 'templates')

def add_admin_links(request, navigation_bar):
    """Add our views to the admin interface"""

    priv_check = request.user.has_privilege

    if not priv_check(WAR_MANAGE):
        return

    entries = [('wars', url_for('admin/war_list'), _(u'Wars')),
               ('maps', url_for('admin/warmap_list'), _(u'Maps')),
               ('modes', url_for('admin/warmode_list'), _(u'Modes'))]

    navigation_bar.insert(1, ('war', url_for('admin/war_list'), _(u'War Management'), entries))

def setup(app, plugin):

    # Setup tables
    init_database()

    # Add our privileges
    for priv in PLUGIN_PRIVILEGES.values():
        app.add_privilege(priv)

    # Add our template path
    app.add_template_searchpath(TEMPLATE_FILES)

    # war related pages
    app.add_url_rule('/wars/', endpoint='wars/index', defaults={'page': 1},
                     view=views.war_index)
    app.add_url_rule('/wars/page/<int:page>', endpoint='wars/index')
    app.add_url_rule('/wars/<int:war_id>', endpoint='wars/detail',
                     view=views.war_detail)
    app.add_url_rule('/wars/fightus', endpoint='wars/fightus',
                     view=views.war_fightus)

    # Admin views
    app.add_url_rule('/wars/', prefix='admin', defaults={'page': 1}, endpoint='admin/war_list',
                     view=views.war_list)
    app.add_url_rule('/wars/page/<int:page>', prefix='admin', endpoint='admin/war_list')
    app.add_url_rule('/wars/new', prefix='admin', endpoint='admin/war_create',
                     view=views.war_edit)
    app.add_url_rule('/wars/<int:war_id>', prefix='admin', endpoint='admin/war_edit',
                     view=views.war_edit)
    app.add_url_rule('/wars/<int:war_id>/delete', prefix='admin', endpoint='admin/war_delete',
{'fraction_non_alphanumeric': 0.14977244517997518, 'fraction_numerical': 0.0033098882912701694, 'mean_word_length': 3.514472455648926, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1349527', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1572, 'n_words': 297}