def post(self): form = ProfileForm(data=self.request.POST) if form.is_valid(): user = users.get_current_user() username = self.request.get('username') #profile = Profile.all().filter('user !=', user).filter('username ='******'username ='******'username_exists': ['%s is already exists'] } profile = { 'username': username } template_vars = { 'errors': errors, 'profile': profile } self.render_response('profile/profile_edit.html', template_vars) else: profile = Profile.all().filter('user ='******'/profile') else: template_vars = { 'form': form } self.render_response('profile/profile_edit.html', template_vars)
def get(self): user = users.get_current_user() if user: profile = Profile.all().filter('user ='******'profile': profile } self.render_response('profile/profile_detail.html', template_vars) else: self.redirect('/')
def get(self): self.validate() profiles_query = Profile.all() profiles_query.order('last_name') self.values['profiles'] = profiles_query.fetch(100) # TODO: Figure out paging self.output('user_list.html')
def post(self, *args): name = self.request.get('name') prof = Profile.all().filter('user = '******'avatar') avatar = images.resize(avatar,32,32) prof.avatar = db.Blob(avatar) prof.put() self.redirect('/')
def GET(self, name=None): if auth.is_admin(): found_name = False if name: q = Profile.all().filter('uid =', name).get() if q: found_name = True return self.individual_profile(q) if not found_name: results = dict() for profile in db.GqlQuery("SELECT * FROM Profile"): results[profile.uid] = profile for l in db.GqlQuery("SELECT * FROM LastOnline"): if l.uid in results: results[l.uid].last_online = l.last_online return super(self.__class__, self).GET({'students' : results}) else: return "Access Denied!"
def prompt(): sent_count = 0 for profile in Profile.all(): try: if profile.prompt_now: mail.send_mail(sender=ADMIN_EMAIL, to=profile.user.email(), subject="[workjournal] Daily prompt", body=""" Hello! Take a moment to visit this URL and jot down what you did today: {0}?edit Thanks, have a good day! """.format(request.url_root)) sent_count += 1 except Exception, e: logging.error(str(e))
def get(self): user = users.get_current_user() profile = Profile.all().filter('owner = ', user).get() td = default_template_data() td["credentials_selected"] = True td["consumer_key"] = settings.CONSUMER_KEY td["consumer_secret"] = settings.CONSUMER_SECRET if os.environ['SERVER_SOFTWARE'].startswith('Development'): td["authorized"] = True td["oauth_token"] = "ACCESS_TOKEN" td["oauth_token_secret"] = "ACCESS_TOKEN_SECRET" elif profile: td["authorized"] = True td["oauth_token"] = profile.token td["oauth_token_secret"] = profile.secret else: td["authorized"] = False self.render(td, 'admin/credentials.html') return
def get(self): user = users.get_current_user() profile = Profile.all().filter('owner = ', user).get() td = default_template_data() td["credentials_selected"] = True td["consumer_key"] = settings.CONSUMER_KEY td["consumer_secret"] = settings.CONSUMER_SECRET if os.environ['SERVER_SOFTWARE'].startswith('Development'): td["authorized"] = True td["oauth_token"] = "ACCESS_TOKEN" td["oauth_token_secret"] = "ACCESS_TOKEN_SECRET" elif profile: td["authorized"] = True td["oauth_token"] = profile.token td["oauth_token_secret"] = profile.secret else: td["authorized"] = False self.render(td, 'admin/credentials.html') return
def digest(): sent_count = 0 for profile in Profile.all(): try: if profile.digest_now: send_digest = False body = "Hello! Here's what your team is up to:\n\n" for p in profile.following: entry = p.entry_yesterday if entry: send_digest = True body += "## {0}\n\n{1}\n\n".format( p.username, entry.summary) if entry.details: body += "More details: {0}{1}\n\n".format( request.url_root, p.username) if send_digest: mail.send_mail(sender=ADMIN_EMAIL, to=profile.user.email(), subject="[workjournal] Daily digest", body=body) sent_count += 1 except Exception, e: logging.error(str(e))
def get(self): consumer_key = 'anonymous' consumer_secret = 'anonymous' td = default_template_data() td["logged_in"] = False td["credentials_selected"] = True td["consumer_key"] = consumer_key user = users.get_current_user() if user: td["logged_in"] = users.is_current_user_admin() profile = Profile.all().filter('owner = ', user).get() if profile: td["user_is_authorized"] = True td["profile"] = profile else: host = self.request.headers.get('host', 'nohost') callback = 'http://%s/documentation/verify' % host request_token_url = 'https://%s/_ah/OAuthGetRequestToken?oauth_callback=%s' % (host, callback) authorize_url = 'https://%s/_ah/OAuthAuthorizeToken' % host consumer = oauth.Consumer(consumer_key, consumer_secret) client = oauth.Client(consumer) # Step 1: Get a request token. This is a temporary token that is used for # having the user authorize an access token and to sign the request to obtain # said access token. td["user_is_authorized"] = False if "localhost" not in host: resp, content = client.request(request_token_url, "GET") if resp['status'] == '200': request_token = dict(cgi.parse_qsl(content)) authr = AuthRequest.all().filter("owner =", user).get() if authr: authr.request_secret = request_token['oauth_token_secret'] else: authr = AuthRequest(owner=user, request_secret=request_token['oauth_token_secret']) authr.put() td["oauth_url"] = "%s?oauth_token=%s" % (authorize_url, request_token['oauth_token']) self.render(td, 'credentials.html')
def get(self): """Simply returns a Response object with an enigmatic salutation.""" c = Profile.all().count() return self.render_response('index.html', form=self.form, c=c)
def getProfile(self, user): return Profile.all().filter('user = ', user).get()
def getCurrentUserName(self): user = users.get_current_user() prof = Profile.all().filter('user = ', user).get() if prof: return prof.name return None
def getUserNameAndID(self,user): prof = Profile.all().filter('user = ', user).get() if prof: return prof.name, prof.key() return None, None
def get(self): prof = Profile.all().filter('user = '******'profile':prof }) self.render_to_response('edit_profile.html',self.templ_vals)