@must_be_valid_project
@must_be_contributor_or_public
@must_not_be_registration
def togglewatch_post(auth, node, **kwargs):
 user = auth.user
 watch_config = WatchConfig(node=node, digest=request.json.get('digest', False), immediate=request.json.get('immediate', False))
 try:
  if user.is_watching(node):
   user.unwatch(watch_config)
  else:
   user.watch(watch_config)
 except ValueError:
  raise HTTPError(http.BAD_REQUEST)
 user.save()
 return {'status': 'success', 'watchCount': node.watches.count(), 'watched': user.is_watching(node)}

@ must_be_valid_project @ must_be_contributor_or_public @ must_not_be_registration def togglewatch_post ( auth , node , ** kwargs ) : user = auth . user watch_config = WatchConfig ( node = node , digest = request . json . get ( 'digest' , False ) , immediate = request . json . get ( 'immediate' , False ) ) try : if user . is_watching ( node ) : user . unwatch ( watch_config ) else : user . watch ( watch_config ) except ValueError : raise HTTPError ( http . BAD_REQUEST ) user . save ( ) return { 'status' : 'success' , 'watchCount' : node . watches . count ( ) , 'watched' : user . is_watching ( node ) }
view for toggling watch mode for a node .