コード例 #1
0
ファイル: app.py プロジェクト: xinghun61/infra
 def get(self, badge_name, *args):
     logging.info('badge_name = %r', badge_name)
     badge_def = Badge.get_by_id(badge_name)
     if not badge_def:
         logging.info('badge def was %r', badge_def)
         self.abort(404)
     awarded_count = UserData.query(
         UserData.badge_name == badge_name,
         UserData.value >= badge_def.level_1 or 0).count()
     l1_count = UserData.query(
         UserData.badge_name == badge_name,
         UserData.value >= badge_def.level_1 or 0,
         UserData.value < badge_def.level_2 or sys.maxint).count()
     l2_count = UserData.query(
         UserData.badge_name == badge_name,
         UserData.value >= badge_def.level_2 or 0,
         UserData.value < badge_def.level_3 or sys.maxint).count()
     l3_count = UserData.query(UserData.badge_name == badge_name,
                               UserData.value >= badge_def.level_3
                               or 0).count()
     context = {
         'badge_def': badge_def,
         'awarded_count': awarded_count,
         'l1_count': l1_count,
         'l2_count': l2_count,
         'l3_count': l3_count
     }
     self.render_response('badge.html', **context)
コード例 #2
0
 def post(self):
     if session:
         args = UserData_obj.parse_args()
         user_id = session['username']
         # print
         UserData.insertuserdata(self, args.id, args.name, args.dob,
                                 args.mobile, args.address, user_id)
         return 200
     else:
         return 500
コード例 #3
0
 def post(self):
     login_template = the_jinja_env.get_template('templates/login2.html')
     if self.request.get('first_name') != "":
         first_name = self.request.get('first_name')
         last_name = self.request.get('last_name')
         username = self.request.get('username')
         password = self.request.get('password')
         secure_data = UserData(first_name=first_name,
                                last_name=last_name,
                                username=username,
                                password=password,
                                loggedin=False)
         secure_data.put()
     self.response.write(login_template.render())
コード例 #4
0
 def post(self):
     home_template = the_jinja_env.get_template('templates/home.html')
     redirect_template = the_jinja_env.get_template(
         'templates/redirect.html')
     username_attempt = self.request.get('usernameAttempt')
     password_attempt = self.request.get('passwordAttempt')
     check_cred = UserData.query().filter(
         UserData.username == username_attempt,
         UserData.password == password_attempt).fetch()
     if len(check_cred) == 0:
         self.response.write(redirect_template.render())
     else:
         user = check_cred[0].key.get()
         userInfo = check_cred[0]
         user.loggedin = True
         user.put()
         # self.response.set_cookie("userkey", userInfo.key)
         print(userInfo.key)
         self.response.set_cookie("userKey", str(userInfo.key))
         self.response.set_cookie("loggedin", userInfo.username)
         self.response.set_cookie("firstname", userInfo.first_name)
         self.response.set_cookie("lastname", userInfo.last_name)
         user_dict = {
             "firstname": userInfo.first_name,
             "lastname": userInfo.last_name,
         }
         self.response.write(home_template.render(user_dict))
コード例 #5
0
ファイル: main.py プロジェクト: cmartinez143/group-3
def get_user_data(email):
    p =UserData.query().filter(UserData.email==email)
    user=p.get()
    if user:
        return True
    else:
        return False
コード例 #6
0
def register():
    form = UserRegForm()
    if form.validate_on_submit():
        user = UserData(email=form.email.data,
                        f_name=form.f_name.data,
                        l_name=form.l_name.data,
                        phone=form.phone_no.data,
                        country=form.country.data,
                        password=form.password.data)
        db.session.add(user)
        db.session.commit()
        token = user.generate_confirmation()
        send_email(user.email, 'Confirm Your account', 'confirm', user=user, token=token)
        flash('A confirmation has been sent to your mail')
        return redirect(url_for('login'))
    return render_template('registeration.html', form=form)
コード例 #7
0
ファイル: main.py プロジェクト: ngs/hackathon-jp
  def get(self):


    self.response.headers['Content-Type'] = 'text/html'
    self.response.out.write('Hello, webapp World!<br>')
    self.response.out.write('------------------------------------------<br>')
    self.response.out.write('UserData.all().count() -> %i <br>' % UserData.all().count())
    self.response.out.write('------------------------------------------<br>')
コード例 #8
0
ファイル: app.py プロジェクト: xinghun61/infra
 def update_user_data(badge, b):
     data = badge.get('data', [])
     # There might be a max batch size? We'll find out.
     to_put = []
     for item in data:
         email = item['email']
         value = int(item['value'])  # JSON might turn it into a float.
         uid = '%s:%s' % (b.badge_name, email)
         d = UserData.get_by_id(id=uid)
         if d and not d.visible:
             continue
         d = UserData(badge_name=b.badge_name,
                      email=email,
                      value=value,
                      visible=True,
                      id=uid)
         to_put.append(d)
     ndb.put_multi(to_put)
コード例 #9
0
 def get(self):
   # add if does not exist entry else remove
   series = self.request.get('series')
   typ = self.request.get('typ')
   q = db.Query(UserData)
   q.filter("user ="******"http://SeriesWala.appspot.com/g?"  #FIX THIS URL FORMATION !!!
       paramsHD = {'s': series, 't': 'HD', 'e': added_series.latest_episode_HD}
       tmpsHD = urllib.urlencode(paramsHD)
       paramsSD = {'s': series, 't': 'SD', 'e': added_series.latest_episode_SD}
       tmpsSD = urllib.urlencode(paramsSD)
       linkHD = baseurl + tmpsHD
       linkSD = baseurl + tmpsSD
       if added_series.latest_episode_HD is not None:
         xmpp.send_message(users.get_current_user().email(), series + " HD " + added_series.latest_episode_HD + " " + linkHD)
       if added_series.latest_episode_SD is not None:
         xmpp.send_message(users.get_current_user().email(), series + " SD " + added_series.latest_episode_SD + " " + linkSD)
     db.put(ud)
     self.response.out.write('DONE')
   else:
     udo = UserData()
     udo.im_handle = users.get_current_user().nickname()
     udo.user = users.get_current_user().user_id()
     udo.series_subscribed = [series]
     db.put(udo)
     taskqueue.add(url='/invite', params={'email': users.get_current_user().email()})
     newq = db.Query(SeriesLatest)
     newq.filter('series_name = ', series)
     added_series = newq.get()
     # FIX: User may not have received invite yet
     if added_series.latest_episode_HD is not None:
       xmpp.send_message(users.get_current_user().email(), series + " HD " + added_series.latest_episode_HD)
     if added_series.latest_episode_SD is not None:
       xmpp.send_message(users.get_current_user().email(), series + " SD " + added_series.latest_episode_SD)
コード例 #10
0
ファイル: main.py プロジェクト: Snd18/GENBOT_public
def dbName_intent(req):
    global persistData
    # create model
    db = database.DataBase(req.dbname, None)
    data = userdata.UserData(req.user, db, None)
    # save data
    save_data(data)
    # create response
    text = "Saved!\nNow tell me the name of the table you want add to the database."
    r = response.Response(text, None, [], [], None)
    res = r.response
    return res
コード例 #11
0
ファイル: main.py プロジェクト: cmartinez143/group-3
 def post(self): ## here's the new POST method in the MainHandler
     results_template = env.get_template('newr.html')
     error_template = env.get_template('error.html')
     # the variables that are sent to results.html are user_answer_1 and user_answer_2
     # they contain the input values from the main.html form with names answer1 and answer2
     template_variables = {
         'noun1':self.request.get("noun1"),
         'email':self.request.get("email"),
         #"birthday":self.request.get("birthday")
        
         }
     
     u = UserData(name =template_variables['noun1'], email = template_variables['email'])
     #birthday = template_variables['birthday']
     
     exclusive = UserData.query().filter(UserData.name==template_variables['noun1'])
     only_one=exclusive.fetch()
     if len(only_one)>=1:
         self.response.out.write(error_template.render())
     else:
         self.response.out.write(results_template.render(template_variables))
         u.put()
コード例 #12
0
ファイル: app.py プロジェクト: xinghun61/infra
 def get(self, viewed_user_email, *args):
     if '@' not in viewed_user_email:
         viewed_user_email += '@chromium.org'
     user_data_list = UserData.query(
         UserData.email == viewed_user_email).fetch()
     badge_def_list = Badge.query().fetch()
     badge_def_dict = {b.badge_name: b for b in badge_def_list}
     badge_views = [BadgeView(ud, badge_def_dict) for ud in user_data_list]
     context = {
         'viewed_user_email': viewed_user_email,
         'badges': badge_views,
     }
     self.render_response('user.html', **context)
コード例 #13
0
def rest_email_password(token):
    if current_user.is_authenticated:
        return redirect(url_for('login'))
    user = UserData.verify_reset_password(token)
    if not user:
        return redirect(url_for('login'))
    form = ResetPasswordForm2()
    if form.validate_on_submit():
        user.password = form.password.data
        db.session.commit()
        flash('Your Password has been rest')
        return redirect(url_for('login'))
    return render_template('password_rest_change.html', form=form)
コード例 #14
0
ファイル: main.py プロジェクト: cmartinez143/group-3
 def post(self):
     form_results_template = env.get_template('form_results.html')
     user = users.get_current_user()
     user_email = user.email()
     logging.info (user_email)
     user_q = UserData.query().filter(UserData.email == user_email)
     user_l = user_q.fetch()
     logging.info(user_l)
     curr_u = user_l[0]
     u_key = curr_u.key
     logging.info(u_key)
     e = Events(event = self.request.get('bucketListItem'), user =u_key) 
     e.put()
     self.get()
コード例 #15
0
ファイル: utilities.py プロジェクト: akivab/curator
def add_music(link=None, title=None, artist=None):
  cover_art = get_cover_art(title, artist)
  music = get_music_file(link, True)
  music_content = music[0] if music else None
  type = music[1] if music else None
    
  content_key = Content.add_music(origin=link,
                                  artist=artist,
                                  title=title,
                                  data=music_content,
                                  image=cover_art,
                                  user=UserData.add_or_get_user(),
                                  type=type if type else 'music')
  return content_key
コード例 #16
0
ファイル: main.py プロジェクト: cmartinez143/group-3
 def get(self):
     bucket_temp = env.get_template("form_results.html")
     user = users.get_current_user()
     user_email = user.email()
     logging.info (user_email)
     user_q = UserData.query().filter(UserData.email == user_email)
     user_l = user_q.fetch()
     logging.info(user_l)
     curr_u = user_l[0]
     u_key = curr_u.key
     logging.info(u_key)
     event_list_q = Events.query().filter(Events.user == u_key )
     event_list = event_list_q.fetch()
     logging.info(event_list)
     variables = {
         'user': curr_u.name,
         'events': event_list
         }
     self.response.write(bucket_temp.render(variables))
コード例 #17
0
ファイル: utilities.py プロジェクト: akivab/curator
def add_image(link=None, data=None):
  if not link and not data:
    raise FieldNotFoundException('no link or data found when adding image')
  image_content = None
  if not data:
    result = urlfetch.fetch(link)
    if result.status_code != 200:
      raise ImageNotFoundException('image %s not found' % str(link))
    image_content = result.content
    image_type = get_image_type(link)
  else:
    image_content = decode_base64_image(data)
    image_type = get_image_type(data)
    link = 'binary data'
    
  if image_content:
    content_key = Content.add_image(origin=link,
                                    data=image_content,
                                    type=image_type,
                                    user=UserData.add_or_get_user())
    return content_key
  return None
コード例 #18
0
  def get(self):
    standard = self.request.get('sd')
    # check if user signed-in or not
    user = users.get_current_user()
    logged = False
    udata = {}
    if user:
      logged = True
      udata['buttontext'] = user.nickname()
      udata['url'] = '#'
      if standard == 'true':
        udata['logout'] = users.create_logout_url("/?sd=true")
      else:
        udata['logout'] = users.create_logout_url("/")
    else:
      udata['buttontext'] = "Sign in with Google"
      if standard == 'true':
        udata['url'] = users.create_login_url("/?sd=true")
      else:
        udata['url'] = users.create_login_url("/")

    if standard == 'true':
      d = memcache.get('sdata')
      if d is None:
        try:
          d = process_and_return(hd=False)
          taskqueue.add(url='/updateseries?sd=true', method='GET')
        except:
          self.response.out.write('Oops seems like our source ThePirateBay is down.')
          return
        memcache.set('sdata', d)
      c = ['active', '', '']
    else:
      d = memcache.get('data')
      if d is None:
        try:
          d = process_and_return()
          taskqueue.add(url='/updateseries?sd=false', method='GET')
        except:
          self.response.out.write('Oops seems like our source ThePirateBay is down.')
          return
        memcache.set('data', d)
      c = ['', 'active', '']

    if d.has_key(''):
      d.pop('')
    subscribed = None
    if users.get_current_user() is not None:
      q = db.Query(UserData)
      q.filter("user =", users.get_current_user().user_id())
      ud = q.get()
      subscribed = []
      if ud is None:
        udo = UserData()
        udo.im_handle = users.get_current_user().nickname()
        udo.user = users.get_current_user().user_id()
        udo.series_subscribed = []
        db.put(udo)
        taskqueue.add(url='/invite', params={'email': users.get_current_user().email()})
      else:
        subscribed = ud.series_subscribed

    messages = []
    if users.get_current_user() is not None:
      q = db.Query(Messages)
      q.filter('user_email = ', users.get_current_user().email())
      msg_data = q.fetch(10)
      for m in msg_data:
        messages.append(m.message)

    template_values = {
            'messages': messages,
            'subscribed': subscribed,
            'logged': logged,
            'udata': udata,
            'data': OrderedDict(sorted(d.items())),
            'standard': c[0],
            'highdef': c[1],
            'about': c[2]
        }

    template = jinja_environment.get_template('index.html')
    self.response.out.write(template.render(template_values))
コード例 #19
0
 def get(self):
     if session:
         id = session['username']
         print(id)
         userdata = UserData.getsingledata(self, id)
         return userdata
コード例 #20
0
 def get(self, id):
     print(id)
     # args = Userbyadmin_obj.parse_args()
     # print(args)
     userdata = UserData.getuserbydata(self, id)
     return userdata