Example #1
0
from pyClanSphere.api import _, url_for, signals, signal, db
from pyClanSphere.utils.account import add_account_urls
from pyClanSphere.utils.admin import add_admin_urls

from pyClanSphere.plugins.gamesquad.database import init_database
from pyClanSphere.plugins.gamesquad.models import SquadMember
from pyClanSphere.plugins.gamesquad.privileges import PLUGIN_PRIVILEGES, GAME_MANAGE, LEVEL_MANAGE
from pyClanSphere.plugins.gamesquad import views

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

# Register our used signals
signal('before_game_deleted', """\
Plugins can use this to react to game deletes.  They can't stop
the deleting of the game but they can delete information in
their own tables so that the database is consistent afterwards.

:keyword game: the game to be deleted
:keyword formdata: data of the submitted form
""")
signal('before_squad_deleted', """\
Plugins can use this to react to squad deletes.  They can't stop
the deleting of the squad but they can delete information in
their own tables so that the database is consistent afterwards.

:keyword squad: the squad to be deleted
:keyword formdata: data of the submitted form
""")
signal('before_level_deleted', """\
Plugins can use this to react to level deletes.  They can't stop
the deleting of the level but they can delete information in
their own tables so that the database is consistent afterwards.
Example #2
0
from os.path import join, dirname

from pyClanSphere.api import _, url_for, signal, signals
from pyClanSphere.utils.admin import add_admin_urls

from pyClanSphere.plugins.news.database import init_database
from pyClanSphere.plugins.news.models import News
from pyClanSphere.plugins.news.privileges import PLUGIN_PRIVILEGES, NEWS_CREATE, NEWS_EDIT, NEWS_DELETE
from pyClanSphere.plugins.news import views

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

signal('before_news_entry_rendered', """\
Sent before a news entry is rendered

:keyword entry: the news entry to be rendered
""")
signal('after_news_entry_rendered', """\
Sent after a news entry was rendered

:keyword entry: the news entry which was just rendered
""")

def add_frontpage_contents(sender, **kwds):
    """Add newsitems to frontpage"""

    context = kwds['context']
    if 'newsitems' not in context:
        context['newsitems'] = News.query.latest().limit(5).all()
    return context