Ejemplo n.º 1
0
 def _get_user_profile(self):
     try:        
         profile = self.request.user.userprofile
     except UserProfile.DoesNotExist: 
         profile = UserProfile(user=self.request.user)
         profile.setup_user()
         profile.save() 
     return profile
Ejemplo n.º 2
0
 def get_context_data(self, **kwargs):
     context = super(AnalysisView, self).get_context_data(**kwargs)
     try:        
         profile = self.request.user.userprofile
     except UserProfile.DoesNotExist: 
         profile = UserProfile(user=self.request.user)
         profile.setup_user()
         profile.save() 
     secret = settings.OPENACCESS_GATEONE_SECRET
     auth_obj = {
         'api_key': settings.OPENACCESS_GATEONE_KEY,
         'upn': profile.username,
         'timestamp': str(int(time.time() * 1000)),
         'signature_method': 'HMAC-SHA1',
         'api_version': '1.0',
     }
     hash = hmac.new(secret, digestmod=sha1)
     hash.update(auth_obj['api_key'] + auth_obj['upn'] + auth_obj['timestamp'])
     auth_obj['signature'] = hash.hexdigest()
     context['gateone_auth_obj'] = json.dumps(auth_obj)
     context['gateone_connect_url'] = 'ssh://%s@%s' % (profile.username,
                                                       settings.OPENACCESS_ANALYSIS_SSH_HOST)
     context['gateone_url'] = settings.OPENACCESS_GATEONE_URL
     return context