Admin Controllers¶
Dashboard¶
- class mediacore.controllers.admin.index.IndexController(*args, **kwargs)¶
Admin dashboard actions
- index(*args, **kwargs)¶
List recent and important items that deserve admin attention.
We do not use the mediacore.lib.helpers.paginate() decorator because its somewhat incompatible with the way we handle ajax fetching with video_table(). This should be refactored and fixed at a later date.
Return type: Dict
Returns: - review_page
A webhelpers.paginate.Page instance containing unreviewed Media.
- encode_page
A webhelpers.paginate.Page instance containing unencoded Media.
- publish_page
A webhelpers.paginate.Page instance containing draft Media.
- recent_media
A list of recently published Media.
- comment_count
Total num comments
- comment_count_published
Total approved comments
- comment_count_unreviewed
Total unreviewed comments
- comment_count_trash
Total deleted comments
Renders: admin/index.html
- media_table(*args, **kwargs)¶
Fetch XHTML to inject when the ‘showmore’ ajax action is clicked.
Parameters: - table (unicode) – awaiting_review, awaiting_encoding, or awaiting_publishing.
- page (int) – Page number, defaults to 1.
Return type: dict
Returns: - media
A list of Media instances.
Renders: admin/media/dash-table.html
Media¶
Media Admin Controller
- class mediacore.controllers.admin.media.MediaController(*args, **kwargs)¶
- add_file(*args, **kwargs)¶
Save action for the AddFileForm.
Creates a new MediaFile from the uploaded file or the local or remote URL.
Parameters: Return type: JSON dict
Returns: - success
bool
- message
Error message, if unsuccessful
- media_id
The id which is important if new media has just been created.
- file_id
The id for the newly created file.
- edit_form
The rendered XHTML EditFileForm for this file.
- status_form
The rendered XHTML UpdateStatusForm
Renders: json
- edit(*args, **kwargs)¶
Display the media forms for editing or adding.
This page serves as the error_handler for every kind of edit action, if anything goes wrong with them they’ll be redirected here.
Parameters: - id (int or "new") – Media ID
- **kwargs – Extra args populate the form for "new" media
Returns: - media
Media instance
- media_form
The MediaForm instance
- media_action
str form submit url
- media_values
dict form values
- file_add_form
The AddFileForm instance
- file_add_action
str form submit url
- file_edit_form
The EditFileForm instance
- file_edit_action
str form submit url
- thumb_form
The ThumbForm instance
- thumb_action
str form submit url
- update_status_form
The UpdateStatusForm instance
- update_status_action
str form submit url
Renders: admin/media/edit.html
- edit_file(*args, **kwargs)¶
Save action for the EditFileForm.
Changes or delets a MediaFile.
- TODO: Use the form validators to validate this form. We only
- POST one field at a time, so the validate decorator doesn’t work, because it doesn’t work for partial validation, because none of the kwargs are updated if an Invalid exception is raised by any validator.
Parameter: id (int) – Media ID
Return type: JSON dict
Returns: - success
bool
- message
Error message, if unsuccessful
- status_form
Rendered XHTML for the status form, updated to reflect the changes made.
Renders: json
- index(*args, **kwargs)¶
List media with pagination and filtering.
Parameters: - page (int) – Page number, defaults to 1.
- search (unicode or None) – Optional search term to filter by
- podcast_filter (int or None) – Optional podcast to filter by
Return type: dict
Returns: - media
The list of Media instances for this page.
- search
The given search term, if any
- search_form
The SearchForm instance
- podcast_filter
The given podcast ID to filter by, if any
- podcast_filter_title
The podcast name for rendering if a podcast_filter was specified.
- podcast_filter_form
The PodcastFilterForm instance.
Renders: admin/media/index-table.html
- merge_stubs(orig_id, input_id)¶
Merge in a newly created media item.
- This is merges media that has just been created. It must have:
- a non-default thumbnail, or
- a file, or
- a title, description, etc
Parameters: - orig_id (int) – Media ID to copy data to
- input_id (int) – Media ID to source files, thumbs, etc from
Returns: JSON dict
Renders: json
- save(*args, **kwargs)¶
Save changes or create a new Media instance.
Form handler the edit() action and the MediaForm.
Redirects back to edit() after successful editing and index() after successful deletion.
Renders: json
- save_thumb(*args, **kwargs)¶
Save a thumbnail uploaded with ThumbForm.
Parameters: - id (int or "new") – Media ID. If "new" a new Media stub is created.
- file (cgi.FieldStorage or None) – The uploaded file
Return type: JSON dict
Returns: - success
bool
- message
Error message, if unsuccessful
- id
The id which is important if a new media has just been created.
Renders: json
- update_status(*args, **kwargs)¶
Update the publish status for the given media.
Parameters: - id (int) – Media ID
- update_status (unicode or None) – The text of the submit button which indicates that the status should change.
- publish_on (datetime.datetime or None) – A date to set to publish_on
Return type: JSON dict
Returns: - success
bool
- message
Error message, if unsuccessful
- status_form
Rendered XHTML for the status form, updated to reflect the changes made.
Renders: json
Podcasts¶
- class mediacore.controllers.admin.podcasts.PodcastsController(*args, **kwargs)¶
- edit(*args, **kwargs)¶
Display the podcast forms for editing or adding.
This page serves as the error_handler for every kind of edit action, if anything goes wrong with them they’ll be redirected here.
Parameters: - id (int or "new") – Podcast ID
- **kwargs – Extra args populate the form for "new" podcasts
Returns: - podcast
Podcast instance
- form
PodcastForm instance
- form_action
str form submit url
- form_values
dict form values
- thumb_form
ThumbForm instance
- thumb_action
str form submit url
Renders: admin/podcasts/edit.html
- index(*args, **kwargs)¶
List podcasts with pagination.
Parameter: page (int) – Page number, defaults to 1.
Return type: Dict
Returns: - podcasts
The list of Podcast instances for this page.
Renders: admin/podcasts/index-table.html
- save(*args, **kwargs)¶
Save changes or create a new Podcast instance.
Form handler the edit() action and the PodcastForm.
Redirects back to edit() after successful editing and index() after successful deletion.
Renders: string
- save_thumb(*args, **kwargs)¶
Save a thumbnail uploaded with ThumbForm.
Parameters: - id (int or "new") – Media ID. If "new" a new Podcast stub is created.
- file (cgi.FieldStorage or None) – The uploaded file
Return type: JSON dict
Returns: - success
bool
- message
Error message, if unsuccessful
- id
The id which is important if a new podcast has just been created.
Renders: json
Comments¶
Comment Moderation Controller
- class mediacore.controllers.admin.comments.CommentsController(*args, **kwargs)¶
- index(*args, **kwargs)¶
List comments with pagination and filtering.
Parameters: - page (int) – Page number, defaults to 1.
- search (unicode or None) – Optional search term to filter by
- media_filter (int or None) – Optional media ID to filter by
Return type: dict
Returns: - comments
The list of Comment instances for this page.
- edit_form
The mediacore.forms.admin.comments.EditCommentForm instance, to be rendered for each instance in comments.
- search
The given search term, if any
- search_form
The SearchForm instance
- media_filter
The given podcast ID to filter by, if any
- media_filter_title
The media title for rendering if a media_filter was specified.
Renders: admin/comments/index-table.html
- save_edit(id, body, **kwargs)¶
Save an edit from EditCommentForm.
Parameter: id (int) – Comment ID
Return type: JSON dict
Returns: - success
bool
- body
The edited comment body after validation/filtering
Renders: json
- save_status(id, status, ids=None, **kwargs)¶
Approve or delete a comment or comments.
Parameters: - id (int or "bulk") – A id if we are acting on a single comment, or "bulk" if we should refer to ids.
- ids (unicode or None) – An optional string of IDs separated by commas.
- status – "approve" or "trash" depending on what action the user requests.
Return type: JSON dict
Returns: - success
bool
- ids
A list of id that have changed.
Renders: json
Settings¶
- class mediacore.controllers.admin.settings.SettingsController(*args, **kwargs)¶
Dumb controller for display and saving basic settings forms
This maps forms from mediacore.forms.admin.settings to our model Setting. This controller doesn’t care what settings are used, the form dictates everything. The form field names should exactly match the name in the model, regardless of it’s nesting in the form.
If and when setting values need to be altered for display purposes, or before it is saved to the database, it should be done with a field validator instead of adding complexity here.
- analytics(*args, **kwargs)¶
- comments(*args, **kwargs)¶
- display(*args, **kwargs)¶
- index(**kwargs)¶
- notifications(*args, **kwargs)¶
- popularity(*args, **kwargs)¶
- save_analytics(*args, **kwargs)¶
- save_comments(*args, **kwargs)¶
- save_display(*args, **kwargs)¶
- save_notifications(*args, **kwargs)¶
- save_popularity(*args, **kwargs)¶
- save_upload(*args, **kwargs)¶
- upload(*args, **kwargs)¶
User Management¶
- class mediacore.controllers.admin.users.UsersController(*args, **kwargs)¶
Admin user actions
- delete(*args, **kwargs)¶
- edit(*args, **kwargs)¶
Display the UserForm for editing or adding.
Parameter: id (int or "new") – User ID
Return type: dict
Returns: - user
The User instance we’re editing.
- user_form
The UserForm instance.
- user_action
str form submit url
- user_values
dict form values
Renders: admin/users/edit.html
- index(*args, **kwargs)¶
List users with pagination.
Parameter: page (int) – Page number, defaults to 1.
Return type: Dict
Returns: - users
The list of User instances for this page.
Renders: json
- save(*args, **kwargs)¶
Category Management¶
- class mediacore.controllers.admin.categories.CategoriesController(*args, **kwargs)¶
- edit(*args, **kwargs)¶
Edit a single category.
Parameter: id – Category ID
Return type: Dict
Returns: - categories
The list of Category instances for this page.
- category_form
The CategoryForm instance.
Renders: admin/categories/edit.html