evennia.web.website.views.help

Views to manipulate help entries.

Multi entry object type supported added by DaveWithTheNiceHat 2021

Pull Request #2429

evennia.web.website.views.help.get_help_category(help_entry, slugify_cat=True)[source]

Returns help category.

Parameters
  • help_entry (HelpEntry, FileHelpEntry or Command) – Help entry instance.

  • slugify_cat (bool) – If true the return string is slugified. Default is True.

Notes

If an entry does not have a help_category attribute, DEFAULT_HELP_CATEGORY from the settings file is used. If the entry does not have attribute ‘web_help_entries’. One is created with a slugified copy of the attribute help_category. This attribute is used for sorting the entries for the help index (ListView) page.

Returns

help_category (str) – The category for the help entry.

evennia.web.website.views.help.get_help_topic(help_entry)[source]

Get the topic of the help entry.

Parameters

help_entry (HelpEntry, FileHelpEntry or Command) – Help entry instance.

Returns

help_topic (str) – The topic of the help entry. Default is ‘unknown_topic’.

evennia.web.website.views.help.can_read_topic(cmd_or_topic, account)[source]

Check if an account or puppet has read access to a help entry.

Parameters
Returns

bool – If command can be viewed or not.

Notes

This uses the ‘read’ lock. If no ‘read’ lock is defined, the topic is assumed readable by all. Even if this returns False, the entry will still be visible in the help index unless can_list_topic is also returning False.

evennia.web.website.views.help.collect_topics(account)[source]

Collect help topics from all sources (cmd/db/file).

Parameters

account (Character or Account) – Account or Character to collect help topics from.

Returns

cmd_help_topics (dict) – contains Command instances. db_help_topics (dict): contains HelpEntry instances. file_help_topics (dict): contains FileHelpEntry instances

class evennia.web.website.views.help.HelpMixin[source]

Bases: object

This is a “mixin”, a modifier of sorts.

Any view class with this in its inheritance list will be modified to work with HelpEntry objects instead of generic Objects or otherwise.

page_title = 'Help'
get_queryset()[source]

Django hook; here we want to return a list of only those HelpEntries and other documentation that the current user is allowed to see.

Returns

queryset (list) – List of Help entries available to the user.

class evennia.web.website.views.help.HelpListView(**kwargs)[source]

Bases: evennia.web.website.views.help.HelpMixin, django.views.generic.list.ListView

Returns a list of help entries that can be viewed by a user, authenticated or not.

paginate_by = 500
template_name = 'website/help_list.html'
page_title = 'Help Index'
class evennia.web.website.views.help.HelpDetailView(**kwargs)[source]

Bases: evennia.web.website.views.help.HelpMixin, django.views.generic.detail.DetailView

Returns the detail page for a given help entry.

template_name = 'website/help_detail.html'
property page_title

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

get_context_data(**kwargs)[source]

Adds navigational data to the template to let browsers go to the next or previous entry in the help list.

Returns

context (dict) – Django context object

get_object(queryset=None)[source]

Override of Django hook that retrieves an object by category and topic instead of pk and slug.

Parameters

queryset (list) – A list of help entry objects.

Returns

entry (HelpEntry, FileHelpEntry or Command) – HelpEntry requested in the URL.