evennia.web.website.views¶
This file contains the generic, assorted views that don’t fall under one of the other applications. Views are django’s way of processing e.g. html templates on the fly.
-
evennia.web.website.views.
to_be_implemented
(request)[source]¶ A notice letting the user know that this particular feature hasn’t been implemented yet.
-
evennia.web.website.views.
admin_wrapper
(request)[source]¶ Wrapper that allows us to properly use the base Django admin site, if needed.
-
class
evennia.web.website.views.
EvenniaIndexView
(**kwargs)[source]¶ Bases:
django.views.generic.base.TemplateView
This is a basic example of a Django class-based view, which are functionally very similar to Evennia Commands but differ in structure. Commands are used to interface with users using a terminal client. Views are used to interface with users using a web browser.
To use a class-based view, you need to have written a template in HTML, and then you write a view like this to tell Django what values to display on it.
While there are simpler ways of writing views using plain functions (and Evennia currently contains a few examples of them), just like Commands, writing views as classes provides you with more flexibility– you can extend classes and change things to suit your needs rather than having to copy and paste entire code blocks over and over. Django also comes with many default views for displaying things, all of them implemented as classes.
This particular example displays the index page.
-
template_name
= 'website/index.html'¶
-
get_context_data
(**kwargs)[source]¶ This is a common Django method. Think of this as the website equivalent of the Evennia Command.func() method.
If you just want to display a static page with no customization, you don’t need to define this method– just create a view, define template_name and you’re done.
The only catch here is that if you extend or overwrite this method, you’ll always want to make sure you call the parent method to get a context object. It’s just a dict, but it comes prepopulated with all sorts of background data intended for display on the page.
You can do whatever you want to it, but it must be returned at the end of this method.
- Keyword Arguments
any (any) – Passed through.
- Returns
context (dict) – Dictionary of data you want to display on the page.
-
-
class
evennia.web.website.views.
TypeclassMixin
[source]¶ Bases:
object
This is a “mixin”, a modifier of sorts.
Django views typically work with classes called “models.” Evennia objects are an enhancement upon these Django models and are called “typeclasses.” But Django itself has no idea what a “typeclass” is.
For the sake of mitigating confusion, any view class with this in its inheritance list will be modified to work with Evennia Typeclass objects or Django models interchangeably.
-
property
typeclass
¶
-
property
-
class
evennia.web.website.views.
EvenniaCreateView
(**kwargs)[source]¶ Bases:
django.views.generic.edit.CreateView
,evennia.web.website.views.TypeclassMixin
This view extends Django’s default CreateView.
CreateView is used for creating new objects, be they Accounts, Characters or otherwise.
-
property
page_title
¶
-
property
-
class
evennia.web.website.views.
EvenniaDetailView
(**kwargs)[source]¶ Bases:
django.views.generic.detail.DetailView
,evennia.web.website.views.TypeclassMixin
This view extends Django’s default DetailView.
DetailView is used for displaying objects, be they Accounts, Characters or otherwise.
-
property
page_title
¶
-
property
-
class
evennia.web.website.views.
EvenniaUpdateView
(**kwargs)[source]¶ Bases:
django.views.generic.edit.UpdateView
,evennia.web.website.views.TypeclassMixin
This view extends Django’s default UpdateView.
UpdateView is used for updating objects, be they Accounts, Characters or otherwise.
-
property
page_title
¶
-
property
-
class
evennia.web.website.views.
EvenniaDeleteView
(*args, **kwargs)[source]¶ Bases:
django.views.generic.edit.DeleteView
,evennia.web.website.views.TypeclassMixin
This view extends Django’s default DeleteView.
DeleteView is used for deleting objects, be they Accounts, Characters or otherwise.
-
property
page_title
¶
-
property
-
class
evennia.web.website.views.
ObjectDetailView
(**kwargs)[source]¶ Bases:
evennia.web.website.views.EvenniaDetailView
This is an important view.
Any view you write that deals with displaying, updating or deleting a specific object will want to inherit from this. It provides the mechanisms by which to retrieve the object and make sure the user requesting it has permissions to actually do things to it.
-
model
¶
-
template_name
= 'website/object_detail.html'¶
-
access_type
= 'view'¶
-
attributes
= ['name', 'desc']¶
-
get_context_data
(**kwargs)[source]¶ Adds an ‘attributes’ list to the request context consisting of the attributes specified at the class level, and in the order provided.
Django views do not provide a way to reference dynamic attributes, so we have to grab them all before we render the template.
- Returns
context (dict) – Django context object
-
get_object
(queryset=None)[source]¶ Override of Django hook that provides some important Evennia-specific functionality.
Evennia does not natively store slugs, so where a slug is provided, calculate the same for the object and make sure it matches.
This also checks to make sure the user has access to view/edit/delete this object!
-
-
class
evennia.web.website.views.
ObjectCreateView
(**kwargs)[source]¶ Bases:
django.contrib.auth.mixins.LoginRequiredMixin
,evennia.web.website.views.EvenniaCreateView
This is an important view.
Any view you write that deals with creating a specific object will want to inherit from this. It provides the mechanisms by which to make sure the user requesting creation of an object is authenticated, and provides a sane default title for the page.
-
model
¶
-
-
class
evennia.web.website.views.
ObjectDeleteView
(*args, **kwargs)[source]¶ Bases:
django.contrib.auth.mixins.LoginRequiredMixin
,evennia.web.website.views.ObjectDetailView
,evennia.web.website.views.EvenniaDeleteView
This is an important view for obvious reasons!
Any view you write that deals with deleting a specific object will want to inherit from this. It provides the mechanisms by which to make sure the user requesting deletion of an object is authenticated, and that they have permissions to delete the requested object.
-
model
¶
-
template_name
= 'website/object_confirm_delete.html'¶
-
access_type
= 'delete'¶
-
-
class
evennia.web.website.views.
ObjectUpdateView
(**kwargs)[source]¶ Bases:
django.contrib.auth.mixins.LoginRequiredMixin
,evennia.web.website.views.ObjectDetailView
,evennia.web.website.views.EvenniaUpdateView
This is an important view.
Any view you write that deals with updating a specific object will want to inherit from this. It provides the mechanisms by which to make sure the user requesting editing of an object is authenticated, and that they have permissions to edit the requested object.
This functions slightly different from default Django UpdateViews in that it does not update core model fields, only object attributes!
-
model
¶
-
access_type
= 'edit'¶
-
get_success_url
()[source]¶ Django hook.
Can be overridden to return any URL you want to redirect the user to after the object is successfully updated, but by default it goes to the object detail page so the user can see their changes reflected.
-
get_initial
()[source]¶ Django hook, modified for Evennia.
Prepopulates the update form field values based on object db attributes.
- Returns
data (dict) –
- Dictionary of key:value pairs containing initial form
data.
-
form_valid
(form)[source]¶ Override of Django hook.
Updates object attributes based on values submitted.
This is run when the form is submitted and the data on it is deemed valid– all values are within expected ranges, all strings contain valid characters and lengths, etc.
This method is only called if all values for the fields submitted passed form validation, so at this point we can assume the data is validated and sanitized.
-
-
class
evennia.web.website.views.
AccountMixin
[source]¶ Bases:
evennia.web.website.views.TypeclassMixin
This is a “mixin”, a modifier of sorts.
Any view class with this in its inheritance list will be modified to work with Account objects instead of generic Objects or otherwise.
-
model
¶
-
form_class
¶
-
-
class
evennia.web.website.views.
AccountCreateView
(**kwargs)[source]¶ Bases:
evennia.web.website.views.AccountMixin
,evennia.web.website.views.EvenniaCreateView
Account creation view.
-
template_name
= 'website/registration/register.html'¶
-
success_url
¶
-
-
class
evennia.web.website.views.
CharacterMixin
[source]¶ Bases:
evennia.web.website.views.TypeclassMixin
This is a “mixin”, a modifier of sorts.
Any view class with this in its inheritance list will be modified to work with Character objects instead of generic Objects or otherwise.
-
model
¶
-
form_class
¶
-
success_url
¶
-
-
class
evennia.web.website.views.
CharacterListView
(**kwargs)[source]¶ Bases:
django.contrib.auth.mixins.LoginRequiredMixin
,evennia.web.website.views.CharacterMixin
,django.views.generic.list.ListView
This view provides a mechanism by which a logged-in player can view a list of all other characters.
This view requires authentication by default as a nominal effort to prevent human stalkers and automated bots/scrapers from harvesting data on your users.
-
template_name
= 'website/character_list.html'¶
-
paginate_by
= 100¶
-
page_title
= 'Character List'¶
-
access_type
= 'view'¶
-
-
class
evennia.web.website.views.
CharacterPuppetView
(**kwargs)[source]¶ Bases:
django.contrib.auth.mixins.LoginRequiredMixin
,evennia.web.website.views.CharacterMixin
,django.views.generic.base.RedirectView
,evennia.web.website.views.ObjectDetailView
This view provides a mechanism by which a logged-in player can “puppet” one of their characters within the context of the website.
It also ensures that any user attempting to puppet something is logged in, and that their intended puppet is one that they own.
-
class
evennia.web.website.views.
CharacterManageView
(**kwargs)[source]¶ Bases:
django.contrib.auth.mixins.LoginRequiredMixin
,evennia.web.website.views.CharacterMixin
,django.views.generic.list.ListView
This view provides a mechanism by which a logged-in player can browse, edit, or delete their own characters.
-
paginate_by
= 10¶
-
template_name
= 'website/character_manage_list.html'¶
-
page_title
= 'Manage Characters'¶
-
-
class
evennia.web.website.views.
CharacterUpdateView
(**kwargs)[source]¶ Bases:
evennia.web.website.views.CharacterMixin
,evennia.web.website.views.ObjectUpdateView
This view provides a mechanism by which a logged-in player (enforced by ObjectUpdateView) can edit the attributes of a character they own.
-
form_class
¶
-
template_name
= 'website/character_form.html'¶
-
-
class
evennia.web.website.views.
CharacterDetailView
(**kwargs)[source]¶ Bases:
evennia.web.website.views.CharacterMixin
,evennia.web.website.views.ObjectDetailView
This view provides a mechanism by which a user can view the attributes of a character, owned by them or not.
-
template_name
= 'website/object_detail.html'¶
-
attributes
= ['name', 'desc']¶
-
access_type
= 'view'¶
-
-
class
evennia.web.website.views.
CharacterDeleteView
(*args, **kwargs)[source]¶ Bases:
evennia.web.website.views.CharacterMixin
,evennia.web.website.views.ObjectDeleteView
This view provides a mechanism by which a logged-in player (enforced by ObjectDeleteView) can delete a character they own.
-
class
evennia.web.website.views.
CharacterCreateView
(**kwargs)[source]¶ Bases:
evennia.web.website.views.CharacterMixin
,evennia.web.website.views.ObjectCreateView
This view provides a mechanism by which a logged-in player (enforced by ObjectCreateView) can create a new character.
-
template_name
= 'website/character_form.html'¶
-
-
class
evennia.web.website.views.
ChannelMixin
[source]¶ Bases:
evennia.web.website.views.TypeclassMixin
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.
-
model
¶ alias of
evennia.comms.comms.DefaultChannel
-
page_title
= 'Channels'¶
-
access_type
= 'listen'¶
-
-
class
evennia.web.website.views.
ChannelListView
(**kwargs)[source]¶ Bases:
evennia.web.website.views.ChannelMixin
,django.views.generic.list.ListView
Returns a list of channels that can be viewed by a user, authenticated or not.
-
paginate_by
= 100¶
-
template_name
= 'website/channel_list.html'¶
-
page_title
= 'Channel Index'¶
-
max_popular
= 10¶
-
-
class
evennia.web.website.views.
ChannelDetailView
(**kwargs)[source]¶ Bases:
evennia.web.website.views.ChannelMixin
,evennia.web.website.views.ObjectDetailView
Returns the log entries for a given channel.
-
template_name
= 'website/channel_detail.html'¶
-
attributes
= ['name']¶
-
max_num_lines
= 1000¶
-
-
class
evennia.web.website.views.
HelpMixin
[source]¶ Bases:
evennia.web.website.views.TypeclassMixin
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.
-
model
¶ alias of
evennia.help.models.HelpEntry
-
page_title
= 'Help'¶
-
-
class
evennia.web.website.views.
HelpListView
(**kwargs)[source]¶ Bases:
evennia.web.website.views.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.
HelpDetailView
(**kwargs)[source]¶ Bases:
evennia.web.website.views.HelpMixin
,evennia.web.website.views.EvenniaDetailView
Returns the detail page for a given help entry.
-
template_name
= 'website/help_detail.html'¶
-