blob: 83d7e1ced17b23a4f51c35c4c5f724c8c39fc876 [file] [log] [blame]
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is govered by a BSD-style
# license that can be found in the LICENSE file or at
"""This is a starring servlet for users and projects."""
import logging
from framework import jsonfeed
from framework import monorailrequest
class SetStarsFeed(jsonfeed.JsonFeed):
"""Process an AJAX request to (un)set a star on a project or user."""
def HandleRequest(self, mr):
"""Retrieves the star persistence object and sets a star."""
starrer_id = mr.auth.user_id
item = mr.GetParam('item') # a project name or a user ID number
scope = mr.GetParam('scope')
starred = bool(mr.GetIntParam('starred'))'Handling user set star request: %r %r %r %r',
starrer_id, item, scope, starred)
project =, item)
mr.cnxn, project.project_id, starrer_id, starred)
elif scope == USER_STARS_SCOPE:
user_id = int(item), user_id, starrer_id, starred)
raise monorailrequest.InputException('unexpected star scope: %s' % scope)
return {
'starred': starred,