<s> from django . conf import settings <EOL> from django . core . urlresolvers import reverse <EOL> from django . db . models import get_model <EOL> from django import template <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . utils . translation import ugettext_noop as _ <EOL> Project = get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> Resource = get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> TranslationWatch = get_model ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> register = template . Library ( ) <EOL> @ register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) <EOL> def watch_toggle ( context , obj , language = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( obj , Project ) : <EOL> obj . toggle_watch_url = reverse ( '<STR_LIT>' , <EOL> args = ( obj . slug , ) ) <EOL> obj . is_project = True <EOL> elif isinstance ( obj , Resource ) and language : <EOL> obj = TranslationWatch . objects . get_or_create ( resource = obj , <EOL> language = language ) [ <NUM_LIT:0> ] <EOL> obj . toggle_watch_url = reverse ( '<STR_LIT>' , <EOL> args = ( obj . resource . project . slug , obj . resource . slug , language . code , ) ) <EOL> obj . is_resource = True <EOL> user = context [ '<STR_LIT>' ] . user <EOL> obj . is_watched = obj . is_watched ( user ) <EOL> context [ '<STR_LIT>' ] = obj <EOL> context [ '<STR_LIT>' ] = settings . ENABLE_NOTICES <EOL> return context </s>
