evennia.web.website.views.objects

Views for managing a specific object)

class evennia.web.website.views.objects.ObjectDetailView(**kwargs)[source]

Bases: evennia.web.website.views.mixins.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

alias of evennia.objects.objects.DefaultObject

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.objects.ObjectCreateView(**kwargs)[source]

Bases: django.contrib.auth.mixins.LoginRequiredMixin, evennia.web.website.views.mixins.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

alias of evennia.objects.objects.DefaultObject

class evennia.web.website.views.objects.ObjectDeleteView(*args, **kwargs)[source]

Bases: django.contrib.auth.mixins.LoginRequiredMixin, evennia.web.website.views.objects.ObjectDetailView, evennia.web.website.views.mixins.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

alias of evennia.objects.objects.DefaultObject

template_name = 'website/object_confirm_delete.html'
access_type = 'delete'
class evennia.web.website.views.objects.ObjectUpdateView(**kwargs)[source]

Bases: django.contrib.auth.mixins.LoginRequiredMixin, evennia.web.website.views.objects.ObjectDetailView, evennia.web.website.views.mixins.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

alias of evennia.objects.objects.DefaultObject

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.