scripts/stats.py
changeset 2090 a07ff1e1bd1f
parent 2089 b8a9691da6e7
child 2148 0345046ed7a5
equal deleted inserted replaced
2089:b8a9691da6e7 2090:a07ff1e1bd1f
   172     db.run_in_transaction_custom_retries(10, txn, key, value)
   172     db.run_in_transaction_custom_retries(10, txn, key, value)
   173 
   173 
   174   print "done"
   174   print "done"
   175 
   175 
   176 
   176 
       
   177 def addFollower(follower, proposals, add_public=True, add_private=True):
       
   178   """Adds a user as follower to the specified proposals.
       
   179 
       
   180   Args:
       
   181     follower: the User to add as follower
       
   182     proposals: a list with the StudnetProposals that should be subscribed to
       
   183     add_public: whether the user is subscribed to public updates
       
   184     add_private: whether the user should be subscribed to private updates
       
   185   """
       
   186 
       
   187   from soc.models.review_follower import ReviewFollower
       
   188 
       
   189   result = []
       
   190 
       
   191   for i in proposals:
       
   192      properties = {
       
   193        'user': follower,
       
   194        'link_id': follower.link_id,
       
   195        'scope': i,
       
   196        'scope_path': i.key().name(),
       
   197        'key_name': '%s/%s' % (i.key().name(), follower.link_id),
       
   198        'subscribed_public': add_public,
       
   199        'subscribed_private': add_private,
       
   200      }
       
   201 
       
   202      entity = ReviewFollower(**properties)
       
   203      result.append(entity)
       
   204 
       
   205   return result
       
   206 
       
   207 
   177 def loadPickle(name):
   208 def loadPickle(name):
   178   """Loads a pickle.
   209   """Loads a pickle.
   179   """
   210   """
   180 
   211 
   181   f = open(name + '.dat')
   212   f = open(name + '.dat')
   213       'getStudents': getEntities(Student),
   244       'getStudents': getEntities(Student),
   214       'getMentors': getEntities(Mentor),
   245       'getMentors': getEntities(Mentor),
   215       'getOrgAdmins': getEntities(OrgAdmin),
   246       'getOrgAdmins': getEntities(OrgAdmin),
   216       'getProps': getProps,
   247       'getProps': getProps,
   217       'countStudentsWithProposals': countStudentsWithProposals,
   248       'countStudentsWithProposals': countStudentsWithProposals,
       
   249       'addFollower': addFollower,
   218       'Organization': Organization,
   250       'Organization': Organization,
   219       'User': User,
   251       'User': User,
   220       'Student': Student,
   252       'Student': Student,
   221       'Mentor': Mentor,
   253       'Mentor': Mentor,
   222       'OrgAdmin': OrgAdmin,
   254       'OrgAdmin': OrgAdmin,