<s> from django . conf import settings <EOL> from django . contrib . auth import BACKEND_SESSION_KEY , logout <EOL> from django . contrib . auth . models import AnonymousUser <EOL> from django . http import HttpResponse <EOL> from django . shortcuts import redirect <EOL> from django . views . generic . base import TemplateView <EOL> from social_auth . views import complete <EOL> SANDBOX_URL = '<STR_LIT>' <EOL> class OdnoklassnikiInfo ( TemplateView ) : <EOL> template_name = '<STR_LIT>' <EOL> def get ( self , * args , ** kwargs ) : <EOL> if hasattr ( settings , '<STR_LIT>' ) : <EOL> return redirect ( SANDBOX_URL . format ( settings . ODNOKLASSNIKI_APP_ID ) ) <EOL> else : <EOL> return super ( OdnoklassnikiInfo , self ) . get ( * args , ** kwargs ) <EOL> ok_app_info = OdnoklassnikiInfo . as_view ( ) <EOL> class OdnoklassnikiApp ( TemplateView ) : <EOL> template_name = '<STR_LIT>' <EOL> def get ( self , request , * args , ** kwargs ) : <EOL> result = None <EOL> if request . GET . get ( '<STR_LIT>' , None ) : <EOL> if request . user . is_authenticated ( ) and '<STR_LIT>' not in request . session . get ( BACKEND_SESSION_KEY , '<STR_LIT>' ) : <EOL> logout ( request ) <EOL> result = complete ( request , '<STR_LIT>' ) <EOL> if isinstance ( result , HttpResponse ) : <EOL> return result <EOL> else : <EOL> if not request . user . is_authenticated ( ) or '<STR_LIT>' not in request . session . get ( BACKEND_SESSION_KEY , '<STR_LIT>' ) : <EOL> request . user = AnonymousUser ( ) <EOL> context = self . get_context_data ( params = kwargs ) <EOL> return self . render_to_response ( context ) <EOL> ok_app = OdnoklassnikiApp . as_view ( ) </s>
