Ejemplo n.º 1
0
 def get(self):
     template_values = {}
     template_values['paged_member_keys'] = Member.get_paged_member_keys()
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     self.render_template(template_name=None, template_values=template_values)
Ejemplo n.º 2
0
 def post(self):
     errors = []
     username = str(self.get_cookie('username',''))
     userflag = str(self.get_cookie('userflag',''))
     if not username or not userflag:
         self.write('403')
         return
     myfile = self.request.files.get('myfile',[0])[0]
     if myfile:
         im = Image.open(StringIO(myfile['body']))
         max_w = 73
         max_h = 73
         if im.size[0] > max_w or im.size[1] > max_w:
             ss = max(float(im.size[0])/max_w, float(im.size[1])/max_h)
             im = im.resize((int(im.size[0]/ss), int(im.size[1]/ss)), Image.ANTIALIAS)
         
         output = StringIO()
         im.convert('RGB').save(output, 'JPEG', quality = 95)#95
         img_data = output.getvalue()
         output.close()
         
         #self.set_header('Content-Type','image/jpeg')
         #self.write(img_data)
         #return
         
         if IMG_STORAGE=='sae':
             file_path_name = '%s.jpg'% username
             avatar = put_obj2storage(file_name = file_path_name, data = img_data, domain_name = DOMAIN_NAME_AVATAR)
         elif IMG_STORAGE=='upyun':
             u = UpYun(DOMAIN_NAME_AVATAR, UPYUN_USER, UPYUN_PW)
             file_path_name = '/avatar/%s.jpg'% username
             avatar = u.writeFile( file_path_name, img_data, True)
         
         if avatar:
             if username == 'admin':
                 Member.set_flag(username, '99')
             if userflag == '1':
                 if Member.set_flag(username, '2'):
                     self.set_cookie('userflag', '2', path="/", expires_days = 365 )
                     clear_cache_multi(['cur_user:'******'/setavatar')
                     return
                 else:
                     errors.append('服务器暂时出错,请稍后再试')
             else:
                 self.redirect('/setavatar')
                 return
         else:
             errors.append('保存图片出错,请稍后再试')
     else:
         errors.append('图片没有正确上传')
         
     self.echo('setavatar.html', {
         'title': "设置头像",
         'errors':errors,
         'wb_avatar_large': '',
     }, layout='_layout.html')
Ejemplo n.º 3
0
 def post(self):
     if USER_MODEL==2:
         self.redirect('/sigin')
         return
     
     name = str(self.get_argument('name','').lower().encode('utf-8'))
     open_id = str(self.get_cookie('open_id',''))
     access_token = str(self.get_cookie('access_token',''))
     
     errors = []
     if name and open_id and access_token:
         access_token_in_kvdb = kv.get('qq_' +str(open_id))
         if access_token_in_kvdb == access_token:
             pass
         else:
             self.redirect('/sigin')
             return
         
         if len(name)<20:
             if re.search('^[a-zA-Z0-9]+$', name):
                 check_obj = Member.check_user_name(str(name))
                 if check_obj:
                     errors.append('该用户名已被注册,请换一个吧')
                 else:
                     u_flag = Member.add_user(str(name), access_token)
                     if u_flag and kv.set('qq_' +str(open_id), str(name)):
                         #注册成功
                         #set sr_code
                         code_list = [access_token]
                         u_topic_time = kv.get('u_topic_time:'+name)
                         if u_topic_time:
                             code_list.append(u_topic_time)
                         u_comment_time = kv.get('u_comment_time:'+name)
                         if u_comment_time:
                             code_list.append(u_comment_time)
                         #code_md5 = md5(''.join(code_list)).hexdigest()
                         
                         self.set_cookie('username', name, path="/", expires_days = 365 )
                         self.set_cookie('usercode', str(md5(''.join(code_list)).hexdigest()), path="/", expires_days = 365 )
                         self.set_cookie('userflag', str(u_flag), path="/", expires_days = 365 )
                         self.redirect('/setavatar?qq=1')
                         return
                     else:
                         errors.append('服务器出现意外错误,请稍后再试')
             else:
                 errors.append('用户名只能包含字母和数字')
         else:
             errors.append('用户名太长了')
     else:
         errors.append('用户名必填')
         
     self.echo('setname.html', {
         'title': "设置名字",
         'errors':errors,
         'name':name,
     }, layout='_layout.html')        
Ejemplo n.º 4
0
 def get(self):
     template_values = {}
     template_values['paged_member_keys'] = Member.get_paged_member_keys()
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     self.render_template(template_name=None,
                          template_values=template_values)
Ejemplo n.º 5
0
 def post(self, email):
     if not self.session['member'] == email:
         self.response.out.write('access denied')
         return
     image = self.get_uploads("member-image-upload")
     image_key = str(image[0].key()) if image else None
     image_coords = [float(coord) for coord in self['image_coords'].split(',')] if self['image_coords'] else None
     key = email if email else self['email']
     image_url = '/api/members/'+key+'/image' if image_key else None
     Member.create_or_update(key, name=self['name'], organization=self["organization"],
                             designation=self["designation"], image=image_key, website=self["website"],
                             twitter_handle=self["twitter_handle"], facebook_id=self["facebook_id"], bio=self["bio"],
                             password=self['password'], image_coords=image_coords, image_url=image_url)
     self.redirect("/members/profile")
Ejemplo n.º 6
0
 def get(self):
     track = Track.get_by_key_name(self['track_id'])
     program = Program.get_by_key_name(self['program_id'], parent=track)
     modules = ProgramModule.all().ancestor(program).order('name')
     template_values = {'program':program,
                        'track':track,
                        'modules':modules,
                        'listing_heading':program.name}
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         email = self.session['member']
         member = Member.get_by_email(email)
         template_values['member'] = member
         if member.role == MEMBER_ROLE[MANAGER]:
             template_values['is_manager'] = True
         else:
             modules_count = modules.count()*1.0
             completed_modules = []
             for module in modules:
                 if module.completed:
                     completed_modules.append(module)
             completed_modules_count = len(completed_modules)
             score = (completed_modules_count/modules_count)*100.0
             engage_score = round(score*random(),0)
             engage_score = int(engage_score) if engage_score > 1 else 1
             template_values['donuts'] = DonutFactory.get_donuts(100, 0.875, [('Engineer1', [DonutSegment(engage_score, '#1c758a'), DonutSegment(score, '#58c4dd')], '/assets/img/tracks/mobile_dev.png')], 'transparent', '#ddd')
     self.render_template(template_name='program_listing.html', template_values=template_values)
Ejemplo n.º 7
0
 def get(self):
     template_values = {}
     active_track = self['track_id']
     if active_track:
         template_values['active_track'] = active_track
     template_values['page_title_centered'] = get_page_title_centered_contents()
     template_values['tracks'] = [self._make_json(track) for track in Track.all().order('order')]
     template_values['is_member'] = True if 'member' in self.session else False
     template_values['track_donuts'] = {}
     if 'member' in self.session:
         email = self.session['member']
         member = Member.get_by_email(email)
         template_values['member'] = member
         template_values['enrolled_tracks'] = {}
         for track in Tracks.get_tracks():
             template_values['enrolled_tracks'][track.id] = EnrollProgram.is_enrolled_track(email, track.id)
         if member.role == MEMBER_ROLE[MANAGER]:
             template_values['is_manager'] = True
         else:
             for track in Tracks.get_tracks():
                 enrolled_programs_count = float(len(EnrollProgram.get_enrolled_programs(email, track.id)))
                 programs_count = float(Program.all().ancestor(Track.get_by_key_name(track.id)).count())
                 score = round((enrolled_programs_count/programs_count)*100,2)
                 engage_score = round(random()*score,0)
                 engage_score = int(engage_score) if engage_score > 1 else 1
                 template_values['track_donuts'][track.id] = [Donut(100, 0.875, member.name, [DonutSegment(engage_score, '#1c758a'), DonutSegment(score, '#58c4dd')], 'transparent', '#ddd')]
     self.render_template(template_name='tracks.html', template_values=template_values)
Ejemplo n.º 8
0
 def get(self):
     m_name = str(self.get_argument('name',''))
     self.echo('setuserflag.html', {
         'title': "设置用户权限",
         'm_name': m_name,
         'm_obj':Member.get_by_name_for_edit(m_name),
     }, layout='_layout.html')
Ejemplo n.º 9
0
def add_member(title, descrip, picfile):
	"""
	Add a event to the database
	"""
	member = Member(name=title, desc=descrip,image=picfile)
	session.add(member)
	session.commit()
Ejemplo n.º 10
0
 def get(self, name):
     name = name.lower()
     m_obj = Member.get_by_key_name(name)
     if m_obj:
         self.echo(
             'member.html',
             {
                 'title':
                 m_obj.name,
                 'm_obj':
                 m_obj,
                 'mi_obj':
                 MemberInfo.get_by_key_name(name),
                 'newest_node':
                 Node.get_newest(),
                 #'recent_node': Node.get_recent_node(),
                 'hot_node':
                 Node.get_hot_node(),
                 'recent_topic_objs':
                 KeyStrValue.get_topic_key_title('recent-topic-home'),
                 'reply_topic_objs':
                 KeyStrValue.get_topic_key_title('recent-reply-topic'),
             },
             layout='_layout.html')
     else:
         self.error(404)
         self.echo(
             'error.html', {
                 'page': '404',
                 'title': "Can't find out this URL",
                 'h2': 'Oh, my god!',
                 'msg': 'Something seems to be lost...'
             })
         return
Ejemplo n.º 11
0
    def report_task(self):
        diff = datetime.timedelta(days=150)
        cutoff_date = datetime.date.today() - diff

        filename = self.get_filename(self.id())
        member_list = Member.all().fetch(LIMIT_ALL)

        lines = list()
        lines.append("number;name;zip;city;date;bil\n")
        for member in member_list:
            if member.member_since >= cutoff_date and member.status.name == "Medlem":
                cars = member.cars.fetch(1)
                if len(cars) > 0:
                    model = cars[0].model.name
                else:
                    model = ""
                lines.append(
                    '"%s";"%s";"%s";"%s";"%s";"%s"\n'
                    % (
                        unicode(member.number),
                        unicode(member.name),
                        unicode(member.zipcode),
                        unicode(member.city),
                        member.member_since.isoformat(),
                        model,
                    )
                )

        self.write_report(filename, lines)
Ejemplo n.º 12
0
def expire_members():
    types = MemberType.all().fetch(30)
    expired_type = None
    for mt in types:
        if mt.name == MEMBER_TYPE_EXPIRED:
            expired_type = mt
            break
    if not expired_type:
        print 'Could not find member type for expired members'

    members = Member.all().fetch(3000)
    expired_count = 0
    last_year = datetime.datetime.now().year - 1
    for member in members:
        dues = MembershipDues.all().ancestor(member).fetch(30)
        all_paid = False
        for due in dues:
            if due.year >= last_year and due.paid:
                all_paid = True
                break
        if not all_paid and member.membertype.name == DEFAULT_MEMBER_NAME and member.status.name == DEFAULT_MEMBER_STATUS_NAME:
            print 'Member no', member.number, 'has an expired membership'
            member.membertype = expired_type
            member.put()
            expired_count = expired_count + 1

    print expired_count, 'memberships have been ended'
Ejemplo n.º 13
0
    def nonone(self):
        """ Mass update fields set to 'None'. Please don't ask. """
        for member in Member.all().fetch(3000):
            mod = False
            if member.email == 'None':
                member.email = None
                mod = True

            if member.phone == 'None':
                member.phone = None
                mod = True

            if member.phone_work == 'None':
                member.phone_work = None
                mod = True

            if member.phone_home == 'None':
                member.phone_home = None
                mod = True

            if member.address == 'None':
                member.address = None
                mod = True

            if mod:
                member.put()
Ejemplo n.º 14
0
 def post(self):
     key = self['email']
     redirect_url = str(
         self['redirect_url']) if self['redirect_url'] else '/community'
     if self['fb-pic-checkbox']:
         image_url = 'https://graph.facebook.com/' + self[
             "facebook_id"] + '/picture?type=normal&height=300&width=300'
     else:
         image_url = '/assets/img/landing/default_member.png'
     role = int(self['role']) if self['role'] else MEMBER_ROLE[ENGINEER]
     member = Member.create_or_update(key,
                                      name=self['name'],
                                      organization=self["organization"],
                                      designation=self["designation"],
                                      website=self["website"],
                                      twitter_handle=self["twitter_handle"],
                                      facebook_id=self["facebook_id"],
                                      bio=self["bio"],
                                      password=self['password'],
                                      image_url=image_url,
                                      role=role)
     self.session['member'] = key
     redirect_url = '/tracks'
     if role == MEMBER_ROLE[MANAGER]:
         Manager.create(member)
     else:
         managed_by = self['manager']
         ManagedUser.create(member, Manager._for(managed_by))
     self.redirect(redirect_url)
Ejemplo n.º 15
0
    def post(self, member_id):
        import constants
        member = Member.get(member_id)
        if member.status.name == constants.SIGNUP_STATUS_NAME:
            member.status = self.get_status(constants.WELCOME_LETTER_NAME)
            # update the status to paid membership due.
            dues = MembershipDues.all().ancestor(member).fetch(25)

            current_year = datetime.datetime.now().year
            # Set next year if this at the end of the previous.
            if (datetime.datetime.now().month >= 11):
                current_year = current_year + 1

            found = False
            for due in dues:
                if due.year == current_year:
                    due.paid = True
                    found = True
                    print 'Updated existing due'
                    due.put()
            if not found:
                print 'Due not found, created new'
                due = MembershipDues(parent=member, year=current_year, paid=True)
                due.put()
            member.put()
        elif member.status.name == constants.WELCOME_LETTER_NAME:
            member.status = self.get_status(constants.DEFAULT_MEMBER_STATUS_NAME)
            member.put()
        destination = self.request.get('return')
        return self.redirect(destination)
Ejemplo n.º 16
0
 def post(self):
     email = self.session['member']
     track_id = self['track_id']
     program_id = self['program_id']
     program = Program.get_by_key_name(program_id, parent=Track.get_by_key_name(track_id))
     EnrollProgram.create(Member.get_by_email(email), program)
     self.redirect("/tracks/program_listing?program_id=%s&track_id=%s"%(program_id, track_id))
Ejemplo n.º 17
0
    def post(self, member_id):
        import constants
        member = Member.get(member_id)
        if member.status.name == constants.SIGNUP_STATUS_NAME:
            member.status = self.get_status(constants.WELCOME_LETTER_NAME)
            # update the status to paid membership due.
            dues = MembershipDues.all().ancestor(member).fetch(25)

            current_year = datetime.datetime.now().year
            # Set next year if this at the end of the previous.
            if (datetime.datetime.now().month >= 11):
                current_year = current_year + 1

            found = False
            for due in dues:
                if due.year == current_year:
                    due.paid = True
                    found = True
                    print('Updated existing due')
                    due.put()
            if not found:
                print('Due not found, created new')
                due = MembershipDues(parent=member,
                                     year=current_year,
                                     paid=True)
                due.put()
            member.put()
        elif member.status.name == constants.WELCOME_LETTER_NAME:
            member.status = self.get_status(
                constants.DEFAULT_MEMBER_STATUS_NAME)
            member.put()
        destination = self.request.get('return')
        return self.redirect(destination)
Ejemplo n.º 18
0
 def get(self):
     path = 'landing.html'
     template_values = {
         'is_member':
         True if 'member' in self.session else False,
         'headings': [
             'BEAGLES LOFT', 'BEAUTIFUL LOFTS', 'A GLOBAL COMMUNITY',
             'RENOWNED EXPERTS', 'FUN EVENTS'
         ],
         'sub_headings': [
             'DISCOVER YOUR INNER STARTUP', 'TO ELEVATE YOUR WORK',
             'TO TAKE PRIDE IN', 'WHO BELIEVE IN SHARING',
             'THAT MAKE WORK A BREEZE'
         ]
     }
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     template_values['services'] = Services.get_services()
     template_values['memberships'] = Memberships.get_memberships()
     template_values[
         'why_beaglesloft_centered'] = get_why_beaglesloft_centered_contents(
         )
     self.render_template(template_name=path,
                          template_values=template_values)
Ejemplo n.º 19
0
def nonone():
    """ Mass update fields set to 'None'. Please don't ask. """
    for member in Member.all().fetch(10000):
        mod = False
        if member.email == 'None':
            member.email = None
            mod = True

        if member.phone == 'None':
            member.phone = None
            mod = True

        if member.phone_work == 'None':
            member.phone_work = None
            mod = True

        if member.phone_home == 'None':
            member.phone_home = None
            mod = True

        if member.address == 'None':
            member.address = None
            mod = True

        if mod:
            member.put()
Ejemplo n.º 20
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template(
            'templates/members/member_list.html')
        countries = Country.all().order('order').fetch(LIMIT)
        statuses = Status.all().order('order').fetch(LIMIT)
        types = MemberType.all().order('order').fetch(LIMIT)

        # TODO: Make sensible
        query_string = ''
        current_search = self.request.get('search')
        query_string += current_search

        current_status = self.request.get('status')
        if current_status != '':
            if query_string != '':
                query_string += ' AND '
            query_string += 'status:' + current_status

        current_type = self.request.get('type')
        if current_type != '':
            if query_string != '':
                query_string += ' AND '
            query_string += 'type:' + current_type

        current_country = self.request.get('country')
        if current_country and current_country != '':
            if query_string != '':
                query_string += ' AND '
            query_string += 'country:' + current_country

        index = search.Index(name='members')
        result = index.search(query=search.Query(
            query_string, options=search.QueryOptions(limit=LIMIT)))

        members = list()
        for document in result.results:
            members.append(Member.search_member_from_document(document))

        members = sorted(members, key=lambda x: x.number)

        current_status_name = current_status
        current_type_name = current_type

        total = memcache.get('member_count')
        if not total:
            total = 0

        data = {
            'countries': countries,
            'statuses': statuses,
            'types': types,
            'members': members,
            'current_status': current_status,
            'current_type': current_type,
            'current_search': current_search,
            'found': result.number_found,
            'shown': len(members),
            'total': total
        }
        self.response.write(template.render(data))
Ejemplo n.º 21
0
 def post(self):
     members_json = Member.get_members_json()
     self.write(
         json.dumps(
             members_json
         ),200,'application/json'
     )
Ejemplo n.º 22
0
def expire_members():
    types = MemberType.all().fetch(30)
    expired_type = None
    for mt in types:
        if mt.name == MEMBER_TYPE_EXPIRED:
            expired_type = mt
            break
    if not expired_type:
        print 'Could not find member type for expired members'

    members = Member.all().fetch(3000)
    expired_count = 0
    last_year = datetime.datetime.now().year - 1
    for member in members:
        dues = MembershipDues.all().ancestor(member).fetch(30)
        all_paid = False
        for due in dues:
            if due.year >= last_year and due.paid:
                all_paid = True
                break
        if not all_paid and member.membertype.name == DEFAULT_MEMBER_NAME and member.status.name == DEFAULT_MEMBER_STATUS_NAME:
            print 'Member no', member.number, 'has an expired membership'
            member.membertype = expired_type
            member.put()
            expired_count = expired_count + 1

    print expired_count, 'memberships have been ended'
Ejemplo n.º 23
0
 def get(self):
     redirect_url = self['redirect_url'] if self['redirect_url'] else '/community'
     template_values = {}
     template_values['redirect_url'] = redirect_url
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     self.render_template(template_name=None, template_values=template_values)
Ejemplo n.º 24
0
 def cur_user(self):
     user_name_cookie = self.get_cookie('username','')
     user_code_cookie = self.get_cookie('usercode','')
     if user_name_cookie and user_code_cookie:
         from model import Member
         return Member.check_loged_user(user_name_cookie, user_code_cookie)
     else:
         return None
Ejemplo n.º 25
0
 def get(self):
     template_values = {}
     newsletters = Newsletter.get_paged_newsletters()
     template_values['newsletters'] = newsletters
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     self.render_template(template_name='newsletters.html', template_values=template_values)
Ejemplo n.º 26
0
 def get(self):
     m_name = str(self.get_argument('name', ''))
     self.echo('setuserflag.html', {
         'title': "设置用户权限",
         'm_name': m_name,
         'm_obj': Member.get_by_name_for_edit(m_name),
     },
               layout='_layout.html')
Ejemplo n.º 27
0
    def post(self):
        name = str(self.get_argument('name', '').lower().encode('utf-8'))
        pw = self.get_argument('pw', '')

        errors = []
        if name and pw:
            if len(name) < 20 or len(pw) < 20:
                if re.search('^[a-zA-Z0-9]+$', name):
                    check_obj = Member.check_user_name(str(name))
                    if check_obj:
                        errors.append('该用户名已被注册,请换一个吧')
                    else:
                        pwmd5 = md5(pw.encode('utf-8')).hexdigest()
                        u_flag = Member.add_user(str(name), pwmd5)
                        if u_flag:
                            #注册成功
                            self.set_cookie('username',
                                            name,
                                            path="/",
                                            expires_days=365)
                            self.set_cookie('usercode',
                                            md5(pwmd5).hexdigest(),
                                            path="/",
                                            expires_days=365)
                            self.set_cookie('userflag',
                                            str(u_flag),
                                            path="/",
                                            expires_days=365)
                            self.redirect('/setavatar')
                            return
                        else:
                            errors.append('服务器出现意外错误,请稍后再试')
                else:
                    errors.append('用户名只能包含字母和数字')
            else:
                errors.append('用户名或密码太长了')
        else:
            errors.append('用户名和密码必填')

        self.echo('sigin.html', {
            'title': "注册",
            'errors': errors,
            'name': name,
            'newest_node': Node.get_newest(),
        },
                  layout='_layout.html')
Ejemplo n.º 28
0
 def get(self):
     template_values = {}
     experts = [expert._json for expert in Expert.all().fetch(100)]
     template_values['experts'] = experts
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     self.render_template(template_name='experts.html', template_values=template_values)
Ejemplo n.º 29
0
    def members_with_status(self, status_name):
        index = search.Index(name='members')
        results = index.search(query=search.Query('status:' + status_name, options=search.QueryOptions(limit=LIMIT)))

        ret = list()
        for document in results:
            ret.append(Member.search_member_from_document(document))
        return ret
Ejemplo n.º 30
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('templates/members/member_list.html')
        countries = Country.all().order('order').fetch(LIMIT)
        statuses = Status.all().order('order').fetch(LIMIT)
        types = MemberType.all().order('order').fetch(LIMIT)

        # TODO: Make sensible
        query_string = ''
        current_search = self.request.get('search')
        query_string +=  current_search

        current_status = self.request.get('status')
        if current_status != '':
            if query_string != '':
                query_string += ' AND '
            query_string += 'status:' + current_status

        current_type = self.request.get('type')
        if current_type != '':
            if query_string != '':
                query_string += ' AND '
            query_string += 'type:'+ current_type

        current_country = self.request.get('country')
        if current_country and current_country != '':
            if query_string != '':
                query_string += ' AND '
            query_string += 'country:' + current_country

        index = search.Index(name='members')
        result = index.search(query=search.Query(query_string, options=search.QueryOptions(limit=LIMIT)))

        members = list()
        for document in result.results:
            members.append(Member.search_member_from_document(document))

        members = sorted(members, key=lambda x: x.number)

        current_status_name = current_status
        current_type_name = current_type

        total = memcache.get('member_count')
        if not total:
            total = 0

        data = {
            'countries': countries,
            'statuses': statuses,
            'types': types,
            'members': members,
            'current_status': current_status,
            'current_type': current_type,
            'current_search': current_search,
            'found': result.number_found,
            'shown': len(members),
            'total': total
        }
        self.response.write(template.render(data))
Ejemplo n.º 31
0
 def post(self):
     email = self.session['member']
     track_id = self['track_id']
     program_id = self['program_id']
     program = Program.get_by_key_name(
         program_id, parent=Track.get_by_key_name(track_id))
     EnrollProgram.create(Member.get_by_email(email), program)
     self.redirect("/tracks/program_listing?program_id=%s&track_id=%s" %
                   (program_id, track_id))
Ejemplo n.º 32
0
def create_new_member_no():
    """Assign new member no. Not *that* time critical but some form of
    transactions would be nice. Or required. This makes my hair stand up
    but...

    It works."""

    members = Member.all().order('-number').fetch(1)
    return str(int(members[0].number) + 1)
Ejemplo n.º 33
0
 def get(self):
     template_values = {}
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     self.render_template(template_name='subscribe_newsletter.html',
                          template_values=template_values)
Ejemplo n.º 34
0
def do_index_verification():
	member_list = Member.all().fetch(LIMIT_ALL)
	index = search.Index(name='members')
	for member in member_list:
		query =

		result = index.search(query=search.Query('number:' + member.number, options=search.QueryOptions(limit=10)))
		logging.debug('Found ' + str(len(result))) + ' members with number ' + member.number
		
Ejemplo n.º 35
0
def create_new_member_no():
    """Assign new member no. Not *that* time critical but some form of
    transactions would be nice. Or required. This makes my hair stand up
    but...

    It works."""

    members = Member.all().order('-number').fetch(1)
    return str(int(members[0].number) + 1)
Ejemplo n.º 36
0
 def get(self):
     path = 'create_newsletter.html'
     template_values = {}
     form_url = blobstore.create_upload_url('/api/common/save_newsletter')
     template_values['form_url'] = form_url
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     self.write(self.get_rendered_html(path, template_values), 200)
Ejemplo n.º 37
0
 def get(self):
     template_values = {}
     upcoming_events, past_events = Event.get_paged_events()
     template_values['past_events'] = past_events
     template_values['upcoming_events'] = upcoming_events
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     self.render_template(template_name='events.html', template_values=template_values)
Ejemplo n.º 38
0
 def post(self):
     req_user = self.request.user
     gu_obj = GoogleUser.get_or_insert(req_user.user_id())
     if gu_obj.name:
         self.redirect('/')
         return
     
     errors = []
     name = self.POST['name'].strip().lower()
     if name:
         if len(name)<20:
             if re.search('^[a-zA-Z0-9]+$', name):
                 check_obj = Member.get_by_key_name(str(name))
                 if check_obj:
                     errors.append('该用户名已被注册,请换一个吧')
                 else:
                     #get member id
                     mid_obj = Counter.get_or_insert('member_auto_increment',name = 'member_auto_increment', value = 1)
                     nuser_obj = Member(key_name=name, id = mid_obj.value, flag = 1, add = int(time()))
                     nuser_obj.put()
                     if nuser_obj.is_saved():
                         #set google user
                         gu_obj.name = name
                         db.run_in_transaction(obj_runput,gu_obj)
                         #all member num +1
                         mid_obj.value += 1
                         db.run_in_transaction(obj_runput,mid_obj)
                         self.redirect('/setavatar')
                         return
                     else:
                         errors.append('服务器出现意外错误,请稍后再试')
             else:
                 errors.append('用户名只能包含字母和数字')
         else:
             errors.append('用户名太长了')
     else:
         errors.append('用户名必填')
     
     self.echo('setname.html', {
         'title': "设置名字",
         'errors':errors,
         'name':name,
         'newest_node': Node.get_newest(),
     }, layout='_layout.html')
Ejemplo n.º 39
0
 def get(self):
     path = 'member_profile.html'
     email = self.session['member']
     member = Member.get_by_email(email)
     form_url = '/api/members/' + email + '/update'
     template_values = {'member': member, 'form_url': form_url}
     template_values['is_member'] = True if 'member' in self.session else False
     #if 'member' in self.session:
     #    template_values['member'] = Member.get_member_json(self.session['member'])
     self.write(self.get_rendered_html(path, template_values), 200)
Ejemplo n.º 40
0
 def get(self):
     path = 'member_profile_image.html'
     email = self.session['member']
     member = Member.get_by_email(email)
     image_upload_url = blobstore.create_upload_url('/api/members/' + email + '/update')
     template_values = {'member': member, 'image_upload_url': image_upload_url}
     template_values['is_member'] = True if 'member' in self.session else False
     #if 'member' in self.session:
     #    template_values['member'] = Member.get_member_json(self.session['member'])
     self.write(self.get_rendered_html(path, template_values), 200)
Ejemplo n.º 41
0
 def get(self):
     redirect_url = self['redirect_url'] if self['redirect_url'] else '/community'
     path = 'member_registration.html'
     template_values = {}
     template_values['redirect_url'] = redirect_url
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     template_values['managers'] = Manager.get_managers()
     self.write(self.get_rendered_html(path, template_values), 200)
Ejemplo n.º 42
0
 def get(self):
     redirect_url = self['redirect_url'] if self['redirect_url'] else '/experts/list'
     path = 'list_experts.html'
     template_values = {}
     template_values['redirect_url'] = redirect_url
     template_values['is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     template_values['experts'] = Expert.all().fetch(100)
     self.write(self.get_rendered_html(path, template_values), 200)
Ejemplo n.º 43
0
 def cur_user(self):
     if self.request.user:
         from model import Member, GoogleUser
         req_user = self.request.user
         gu_obj = GoogleUser.get_or_insert(req_user.user_id())
         if gu_obj.name:
             return Member.get_by_key_name(gu_obj.name)
         return None
     else:
         return None
Ejemplo n.º 44
0
 def cur_user(self):
     if self.request.user:
         from model import Member, GoogleUser
         req_user = self.request.user
         gu_obj = GoogleUser.get_or_insert(req_user.email())
         if gu_obj.name:
             return Member.get_by_key_name(gu_obj.name)
         return None
     else:
         return None
Ejemplo n.º 45
0
 def get(self):
     template_values = {}
     newsletters = Newsletter.get_paged_newsletters()
     template_values['newsletters'] = newsletters
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     self.render_template(template_name='newsletters.html',
                          template_values=template_values)
Ejemplo n.º 46
0
 def get(self):
     path = 'create_newsletter.html'
     template_values = {}
     form_url = blobstore.create_upload_url('/api/common/save_newsletter')
     template_values['form_url'] = form_url
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     self.write(self.get_rendered_html(path, template_values), 200)
Ejemplo n.º 47
0
 def get(self):
     path = 'landing.html'
     template_values = {'is_member': True if 'member' in self.session else False,
                        'headings':['BEAGLES LOFT', 'BEAUTIFUL LOFTS', 'A GLOBAL COMMUNITY', 'RENOWNED EXPERTS', 'FUN EVENTS'],
                        'sub_headings':['DISCOVER YOUR INNER STARTUP', 'TO ELEVATE YOUR WORK', 'TO TAKE PRIDE IN', 'WHO BELIEVE IN SHARING', 'THAT MAKE WORK A BREEZE']}
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(self.session['member'])
     template_values['services'] = Services.get_services()
     template_values['memberships'] = Memberships.get_memberships()
     template_values['why_beaglesloft_centered'] = get_why_beaglesloft_centered_contents()
     self.render_template(template_name=path, template_values=template_values)
Ejemplo n.º 48
0
 def get(self):
     template_values = {}
     experts = [expert._json for expert in Expert.all().fetch(100)]
     template_values['experts'] = experts
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     self.render_template(template_name='experts.html',
                          template_values=template_values)
Ejemplo n.º 49
0
 def create_index(self):
     print 'Creating member index'
     members = Member.all().fetch(10000)
     docs = []
     for member in members:
         print 'Indexing member', member.number
         docs.append(member.create_document())
         if len(docs) > 100:
             index = search.Index(name='members')
             index.put(docs)
             docs = []
Ejemplo n.º 50
0
    def post(self):
        m_name = str(self.get_argument('name', ''))
        flag = self.get_argument('flag', '')

        if m_name and flag:
            if Member.set_flag(m_name, flag):
                clear_cache_multi(['cur_user:'******'/set-user-flag?name=%s' % m_name)
                return

        self.redirect('/set-user-flag?name=%s' % m_name)
Ejemplo n.º 51
0
 def get(self):
     path = 'member_profile.html'
     email = self.session['member']
     member = Member.get_by_email(email)
     form_url = '/api/members/' + email + '/update'
     template_values = {'member': member, 'form_url': form_url}
     template_values[
         'is_member'] = True if 'member' in self.session else False
     #if 'member' in self.session:
     #    template_values['member'] = Member.get_member_json(self.session['member'])
     self.write(self.get_rendered_html(path, template_values), 200)
Ejemplo n.º 52
0
    def get_member_set(self, condition = "is_traced = 1"):
        if condition:
            sql = "SELECT id, account, name, is_followed, is_traced, last_trace_time, favor from member where %s" % condition
        else:
            sql = "SELECT id, account, name, is_followed, is_traced, last_trace_time, favor from member"

        result = self.select(sql)
        member_set = []
        for item in result:
            member_set.append(Member(id = item[0], account = item[1], name = item[2], is_followed = item[3], is_traced = item[4], last_trace_time = item[5], favor = item[6]))

        return member_set
Ejemplo n.º 53
0
 def get(self):
     redirect_url = self['redirect_url'] if self[
         'redirect_url'] else '/community'
     template_values = {}
     template_values['redirect_url'] = redirect_url
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     self.render_template(template_name=None,
                          template_values=template_values)
Ejemplo n.º 54
0
 def get(self):
     redirect_url = self['redirect_url'] if self[
         'redirect_url'] else '/community'
     path = 'member_registration.html'
     template_values = {}
     template_values['redirect_url'] = redirect_url
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     template_values['managers'] = Manager.get_managers()
     self.write(self.get_rendered_html(path, template_values), 200)
Ejemplo n.º 55
0
 def get(self):
     redirect_url = self['redirect_url'] if self[
         'redirect_url'] else '/experts/list'
     path = 'list_experts.html'
     template_values = {}
     template_values['redirect_url'] = redirect_url
     template_values[
         'is_member'] = True if 'member' in self.session else False
     if 'member' in self.session:
         template_values['member'] = Member.get_member_json(
             self.session['member'])
     template_values['experts'] = Expert.all().fetch(100)
     self.write(self.get_rendered_html(path, template_values), 200)
Ejemplo n.º 56
0
def set_mentions(topic_key, allmember):
    for m in allmember.split(','):
        m_obj = Member.get_by_key_name(m)
        if m_obj:
            if m_obj.notic:
                t_list = m_obj.notic.split(',')
                if topic_key not in t_list:
                    t_list.insert(0, topic_key)
                    m_obj.notic = ','.join(t_list[:NOTIFY_NUM])
                    m_obj.put()
            else:
                m_obj.notic = topic_key
                m_obj.put()
Ejemplo n.º 57
0
    def get_member(self, member_no):
        (memberno, access_code) = self.get_cookie()

        member = Member.get(member_no)
        if not member:
            self.abort(400)

        if not member.number == memberno:
            self.abort(400)

        if member.edit_access_code.lower().strip() != access_code:
            self.abort(400)

        return member