From b694c3de348ab34e98ecc1cf060f5e631f912c05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Odin=20H=C3=B8rthe=20Omdal?= Date: Sun, 17 Aug 2014 22:22:00 +0200 Subject: [PATCH] Add new hook 'collection_add_media' --- mediagoblin/user_pages/lib.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mediagoblin/user_pages/lib.py b/mediagoblin/user_pages/lib.py index e5c8defc..5b411a82 100644 --- a/mediagoblin/user_pages/lib.py +++ b/mediagoblin/user_pages/lib.py @@ -14,14 +14,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from mediagoblin.tools.mail import send_email -from mediagoblin.tools.template import render_template -from mediagoblin.tools.translate import pass_to_ugettext as _ from mediagoblin import mg_globals from mediagoblin.db.base import Session from mediagoblin.db.models import (CollectionItem, MediaReport, CommentReport, - MediaComment, MediaEntry) -from mediagoblin.user_pages import forms as user_forms + MediaComment, MediaEntry) +from mediagoblin.tools.mail import send_email +from mediagoblin.tools.pluginapi import hook_runall +from mediagoblin.tools.template import render_template +from mediagoblin.tools.translate import pass_to_ugettext as _ def send_comment_email(user, comment, media, request): @@ -73,9 +73,12 @@ def add_media_to_collection(collection, media, note=None, commit=True): Session.add(collection) Session.add(media) + hook_runall('collection_add_media', collection_item=collection_item) + if commit: Session.commit() + def build_report_object(report_form, media_entry=None, comment=None): """ This function is used to convert a form object (from a User filing a @@ -86,7 +89,7 @@ def build_report_object(report_form, media_entry=None, comment=None): :param media_entry A MediaEntry object. The MediaEntry being repo- -rted by a MediaReport. In a CommentReport, this will be None. - :param comment A MediaComment object. The MediaComment being + :param comment A MediaComment object. The MediaComment being reported by a CommentReport. In a MediaReport this will be None. @@ -115,4 +118,3 @@ def build_report_object(report_form, media_entry=None, comment=None): report_object.report_content = report_form.report_reason.data report_object.reporter_id = report_form.reporter_id.data return report_object - -- 2.25.1