Forum attachments¶
The forum_attachments
application handles all the attachments that can be associated with forum
posts.
Abstract models¶
Forum attachments abstract models¶
This module defines abstract models provided by the forum_attachments
application.
-
class
machina.apps.forum_conversation.forum_attachments.abstract_models.
AbstractAttachment
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Represents a post attachment. An attachment is always linked to a post.
-
property
filename
¶ Returns the filename of the considered attachment.
-
get_file_upload_to
(filename)¶ Returns the path to upload the associated file to.
-
property
-
machina.apps.forum_conversation.forum_attachments.abstract_models.
get_attachment_file_upload_to
(instance, filename)¶ Returns a valid upload path for the file of an attachment.
Cache¶
Forum attachments cache¶
This module defines an abstraction allowing to put forum attachments into cache when users are creating forum posts and topics.
-
class
machina.apps.forum_conversation.forum_attachments.cache.
AttachmentCache
¶ Bases:
object
The attachments cache.
This one should be used with a FileBasedCache backend. But this can be overriden. The attachments cache acts as a wrapper and ensure that the states (name, size, content type, charset and content) of all files from any request.FILES dict are saved inside the considered backend when calling the ‘set’ method. Conversely, the ‘get’ method will populate a dictionary of InMemoryUploadedFile instances or TemporaryUploadedFile instancesby using these states.
-
delete
(key)¶ Deletes a file associated with a specific key.
-
get
(key)¶ Regenerates a MultiValueDict instance containing the files related to all file states stored for the given key.
-
get_backend
()¶ Returns the associated cache backend.
-
set
(key, files)¶ Stores the state of each file embedded in the request.FILES MultiValueDict instance.
This instance is assumed to be passed as the ‘files’ argument. Each state stored in the cache is a dictionary containing the following values:
- name
The name of the uploaded file.
- size
The size of the uploaded file.
- content_type
The content type of the uploaded file.
- content_length
The content length of the uploaded file.
- charset
The charset of the uploaded file.
- content
The content of the uploaded file.
-
Views¶
Forum attachments views¶
This module defines views provided by the forum_attachments
application.
-
class
machina.apps.forum_conversation.forum_attachments.views.
AttachmentView
(**kwargs)¶ Bases:
machina.apps.forum_permission.viewmixins.PermissionRequiredMixin
,django.views.generic.detail.DetailView
Allows to retrieve a forum attachment.
-
get_controlled_object
()¶ Returns the controlled object.
-
model
¶ alias of
machina.core.db.models.Attachment
-
perform_permissions_check
(user, obj, perms)¶ Performs the permission check.
-
render_to_response
(context, **response_kwargs)¶ Generates the appropriate response.
-