Interface

Interface - wouso.interface module

Generic functionality

The interface module should be aware of:

  • the current theme
  • game config
  • God exposed config

Applications (games) should use interface specific methods of displaying content in the base template/context, controlling sidebar, putting game specific boxes in sidebar, header, footer, or any other zone defined by the interface module.

Static pages

Static pages include: Game Story, Manual and Credits. This should be stored externally as plain-text/markdown files and served by a interface view.

Needs design: storage, visibility (menus?) - adding links to pages to site_base footer.

Activity

A wall page that displays actions made on the site. For example: “Bob challenged Alice and lost”.

The module should register for events send by different other modules and log the data (in the database) that would be displayed on the wall.

wouso.interface.activity.models

class wouso.interface.activity.models.Activity(*args, **kwargs)

Activity(id, timestamp, user_from_id, user_to_id, message_string, arguments, game_id)

classmethod delete(game, user_from, user_to, message, arguments)

Note: must be called with the _same_ arguments as the original to work

game_name

Returns the game name

get_game_absolute_url(*args, **kwargs)

Returns the game url

classmethod get_global_activity(exclude_others=True, wouso_only=True)

Return all game activity, ordered by timestamp, newest first

classmethod get_group_activiy(group, **kwargs)

Return all group activity

classmethod get_player_activity(player, **kwargs)

Return an user’s activity.

classmethod get_race_activiy(race, **kwargs)

Return all group activity

wouso.interface.activity.models.addActivity_handler(sender, **kwargs)

Callback function for addActivity signal

wouso.interface.activity.signals

Usage examples

Sending events from games:

from wouso.interface.activity import signals

# games/quest/models.py
signal_msg = u"%s has finished quest %s" % (self, self.current_quest.title)
signals.addActivity.send(sender=None, user_from=self, user_to=self, \
                         message=signal_msg, game=QuestGame.get_instance())

# games/qotd/views.py
if qotd.answers[choice].correct:
    signal_msg = '%s has given a correct answer to %s'
else:
    signal_msg = '%s has given a wrong answer to %s'
signal_msg = signal_msg % (request.user.get_profile(), \
                           QotdGame.get_instance()._meta.verbose_name)
signals.addActivity.send(sender=None, user_from=request.user.get_profile(), \
                         user_to=request.user.get_profile(), \
                         message=signal_msg, game=QotdGame.get_instance())

Top

wouso.interface

wouso.interface.get_apps()

Returns a list of apps defined inside the wouso.interface module.

wouso.interface.get_static_pages()

Return a list of static pages ordered by position, for rendering in footer

wouso.interface.render_string(template, data=None)

Provide game context render_to_string, used by widget generators

wouso.interface.context_processors

wouso.interface.context_processors.context(request)

Make all configuration settings available as config_name and also define some game context

Generate header and footer bar contents.

wouso.interface.context_processors.sidebar(request)

For each registered game, get a widget to be displayed in sidebar @remark This design needs to be analysed. @todo ordering, using config

Returns a ‘sidebar’ list containing html boxes.

wouso.interface.views

wouso.interface.views.get_wall(page=u'1')

Returns activity for main wall, paginated.

wouso.interface.views.homepage(request, page=u'1')

First page shown

wouso.interface.views.instantsearch(request)

Perform instant search

wouso.interface.views.search(*args, **kwargs)

Perform regular search by either first or last name

wouso.interface.views.searchone(request)

Get one user, based on his/her name

wouso.interface.views.ui(request)

Show the UI template. The rest is Javascript