def _createReviewFor(self, entity, comment, score=0, is_public=True): """Creates a review for the given proposal and sends out a message to all followers. Args: entity: Student Proposal entity for which the review should be created comment: The textual contents of the review score: The score of the review (only used if the review is not public) is_public: Determines if the review is a public review """ from soc.logic.helper import notifications as notifications_helper from soc.modules.gsoc.logic.models.review import logic as review_logic from soc.modules.gsoc.logic.models.review_follower import logic as \ review_follower_logic # create the fields for the review entity fields = { 'link_id': 't%i' % (int(time.time() * 100)), 'scope': entity, 'scope_path': entity.key().id_or_name(), 'author': user_logic.logic.getForCurrentAccount(), 'content': comment, 'is_public': is_public, } # add the given score if the review is not public if not is_public: fields['score'] = score # create a new Review key_name = review_logic.getKeyNameFromFields(fields) review_entity = review_logic.updateOrCreateFromKeyName( fields, key_name) # get all followers fields = {'scope': entity} if is_public: fields['subscribed_public'] = True else: fields['subscribed_private'] = True followers = review_follower_logic.getForFields(fields) if is_public: # redirect to public page redirect_url = redirects.getPublicRedirect(entity, self._params) else: # redirect to review page redirect_url = redirects.getReviewRedirect(entity, self._params) for follower in followers: # sent to every follower except the reviewer if follower.user.key() != review_entity.author.key(): notifications_helper.sendNewReviewNotification( follower.user, review_entity, entity.title, redirect_url)
def _createReviewFor(self, entity, reviewer, comment, score=0, is_public=True): """Creates a review for the given proposal and sends out a message to all followers. Args: entity: Student Proposal entity for which the review should be created reviewer: A role entity of the reviewer (if possible, else None) comment: The textual contents of the review score: The score of the review (only used if the review is not public) is_public: Determines if the review is a public review """ from soc.logic.helper import notifications as notifications_helper from soc.logic.models.review import logic as review_logic from soc.logic.models.review_follower import logic as review_follower_logic # create the fields for the review entity fields = {'link_id': 't%i' % (int(time.time()*100)), 'scope': entity, 'scope_path': entity.key().id_or_name(), 'author': user_logic.logic.getForCurrentAccount(), 'content': comment, 'is_public': is_public, 'reviewer': reviewer } # add the given score if the review is not public if not is_public: fields['score'] = score # create a new Review key_name = review_logic.getKeyNameFromFields(fields) review_entity = review_logic.updateOrCreateFromKeyName(fields, key_name) # get all followers fields = {'scope': entity} if is_public: fields['subscribed_public'] = True else: fields['subscribed_private'] = True followers = review_follower_logic.getForFields(fields) if is_public: # redirect to public page redirect_url = redirects.getPublicRedirect(entity, self._params) else: # redirect to review page redirect_url = redirects.getReviewRedirect(entity, self._params) for follower in followers: # sent to every follower except the reviewer if follower.user.key() != review_entity.author.key(): notifications_helper.sendNewReviewNotification(follower.user, review_entity, entity.title, redirect_url)
def createReviewFor(self, view, entity, user, comment, score=0, is_public=True): """Creates a review of the user for the given proposal and sends out a message to all followers. Args: view: student proposal view entity: Student Proposal entity for which the review should be created user: the user who is leaving the review comment: The textual contents of the review score: The score of the review (only used if the review is not public) is_public: Determines if the review is a public review """ from soc.logic.helper import notifications as notifications_helper from soc.views.helper import redirects from soc.modules.gsoc.logic.models.review import logic as review_logic from soc.modules.gsoc.logic.models.review_follower import logic as \ review_follower_logic # create the fields for the review entity fields = {'link_id': 't%i' % (int(time.time()*100)), 'scope': entity, 'scope_path': entity.key().id_or_name(), 'author': user, 'content': comment if comment else '', 'is_public': is_public, } # add the given score if the review is not public if not is_public: fields['score'] = score # create a new Review key_name = review_logic.getKeyNameFromFields(fields) review_entity = review_logic.updateOrCreateFromKeyName(fields, key_name) # get all followers fields = {'scope': entity} if is_public: fields['subscribed_public'] = True else: fields['subscribed_private'] = True followers = review_follower_logic.getForFields(fields) # retrieve the redirects for the student and one for the org members private_redirect_url = redirects.getStudentPrivateRedirect(entity, view._params) review_redirect_url = redirects.getReviewRedirect(entity, view._params) student_id = entity.scope.link_id for follower in followers: # sent to every follower except the reviewer if follower.user.key() != review_entity.author.key(): if follower.user.link_id == student_id: redirect_url = private_redirect_url else: redirect_url = review_redirect_url notifications_helper.sendNewReviewNotification(follower.user, review_entity, entity.title, redirect_url)
def createReviewFor(self, view, entity, user, comment, score=0, is_public=True): """Creates a review of the user for the given proposal and sends out a message to all followers. Args: view: student proposal view entity: Student Proposal entity for which the review should be created user: the user who is leaving the review comment: The textual contents of the review score: The score of the review (only used if the review is not public) is_public: Determines if the review is a public review """ from soc.logic.helper import notifications as notifications_helper from soc.views.helper import redirects from soc.modules.gsoc.logic.models.review import logic as review_logic from soc.modules.gsoc.logic.models.review_follower import logic as \ review_follower_logic # create the fields for the review entity fields = { 'link_id': 't%i' % (int(time.time() * 100)), 'scope': entity, 'scope_path': entity.key().id_or_name(), 'author': user, 'content': comment if comment else '', 'is_public': is_public, } # add the given score if the review is not public if not is_public: fields['score'] = score # create a new Review key_name = review_logic.getKeyNameFromFields(fields) review_entity = review_logic.updateOrCreateFromKeyName( fields, key_name) # get all followers fields = {'scope': entity} if is_public: fields['subscribed_public'] = True else: fields['subscribed_private'] = True followers = review_follower_logic.getForFields(fields) # retrieve the redirects for the student and one for the org members private_redirect_url = redirects.getStudentPrivateRedirect( entity, view._params) review_redirect_url = redirects.getReviewRedirect(entity, view._params) student_id = entity.scope.link_id for follower in followers: # sent to every follower except the reviewer if follower.user.key() != review_entity.author.key(): if follower.user.link_id == student_id: redirect_url = private_redirect_url else: redirect_url = review_redirect_url notifications_helper.sendNewReviewNotification( follower.user, review_entity, entity.title, redirect_url)