コード例 #1
0
ファイル: routes.py プロジェクト: bbenne10/atlsinfonia
def add_user():
    # dummy user and dummy member are created on first request.
    # user is responsible for creating dummy events.
    Event.create_table(fail_silently=True)
    Member.create_table(fail_silently=True)
    Minute.create_table(fail_silently=True)
    Picture.create_table(fail_silently=True)
    User.create_table(fail_silently=True)
#
#     # create a dummy member
#     try:
#         member = Member(first_name="Bryan",
#                         last_name="Bennett",
#                         collegiate_chapter="Zeta Omicron "
#                                            "(Georgia Southern University)",
#                         initiation_date=datetime.date(2006, 04, 06),
#                         office="Secretary, Warden",
#                         image_path="Bryan_Bennett.jpg")
#         member.save()
#     except IntegrityError as e:
#         print e
#
    # create a dummy user
    try:
        admin = User(username='******', email='*****@*****.**',
                     admin=True, active=True)
        admin.set_password("password")
        admin.save()
    except IntegrityError as e:
        print e
コード例 #2
0
ファイル: member.py プロジェクト: eugeneai/ZCA
 def get(self):
     db = getUtility(IRelationalDatabase)
     cr = db.cursor()
     number = self.member.number
     if number:
         cr.execute("""SELECT
                         id,
                         number,
                         name
                       FROM members
                       WHERE number = ?""",
                    (number,))
     else:
         cr.execute("""SELECT
                         id,
                         number,
                         name
                       FROM members""")
     rst = cr.fetchall()
     cr.close()
     members = []
     for record in rst:
         id = record['id']
         number = record['number']
         name = record['name']
         member = Member()
         member.id = id
         member.number = number
         member.name = name
         members.append(member)
     return members
コード例 #3
0
ファイル: views.py プロジェクト: nmyers322/BandManager
def json_add_member(request, band_id):
    if isInBand(request.user, band_id):
        #current user is in this band
        if isManager(request.user, band_id):
            #current user is a manager
            if request.method == 'POST':
                #load data
                data = json.loads(request.body)
                #add an invitation to the email provided
                band = Band.objects.get(id=band_id)
                if "email" in data:
                    email = data["email"]
                else:
                    email = None
                newInv = Invitation(band=band, email=email, active=True)
                newInv.save()
                #add the member to the band regardless
                name = data["name"]
                role = data["role"]
                if "phone" in data:
                    phone = data["phone"]
                else:
                    phone = None
                status = data["status"]
                newMem = Member(band=band, name=name, role=role, phone=phone, status=status, email=email)
                newMem.save()
                return HttpResponse("success")
    return HttpResponse("failure")
コード例 #4
0
ファイル: handlers.py プロジェクト: Man-UP/website
 def get(self, key):
     edit = self.request.get('edit')
     template_dict = {'key': key, 'show_form' : True,'members': Member.all(),
                      'edit':edit,'thing' : self.thing_descriptors.get(edit),'images':Image.all().filter('name != ', "no-name") }
     if key == 'new':
         template_dict['form_data'] = {
             'author': Member.get_current_member().handle,
             'date': unicode(datetime.date.today())}
     else:
         try:
             if(edit=='news'):
                thing = NewsArticleNew.get(Key(key))
                form_data={'title':thing.title,'author':thing.author,'date':unicode(thing.date),'body':thing.body,'picture':thing.picture}
             elif(edit=='talk'):
                thing = TalkNew.get(Key(key))
                form_data={'title':thing.title,'author':thing.author,'date':unicode(thing.date),'body':thing.body,'video':thing.video}
             elif(edit=='hack'):
                thing = Hack.get(Key(key))
                form_data={'title':thing.title,'date':unicode(thing.date),'body':thing.body,'picture':thing.picture}
             template_dict['form_data']=form_data
         except BadKeyError:
             template_dict['message'] = \
                 'Could not find %s with key %r.' %  (self.thing_descriptors.get(edit), key)
             template_dict['show_form'] = False
     self.render_template('edit', template_dict)
コード例 #5
0
ファイル: members.py プロジェクト: zmyaro/star-site
	def get(self, args):
		if not require_admin(self):
			return
		
		template_vals = generate_base_template_vals(self)
		template_vals['title'] = 'Edit Member'
		template_vals['page'] = 'members'
		
		req_id = self.request.get('id')
		
		if not req_id:
			while True:
				# Create a new ID and verify it is unique.
				new_id = uuid4().hex
				if not Member.query(Member.id == new_id).get():
					new_member = Member()
					new_member.id = new_id
					new_member.name = 'New Member'
					template_vals['member'] = new_member
					break
		else:
			member = Member.query(Member.id == req_id).get()
			if member:
				template_vals['member'] = member
			else:
				self.error(404)
				return
		
		template_vals['semesters'] = get_all_semesters()
		
		template = JINJA_ENVIRONMENT.get_template('member_edit.html')
		self.response.write(template.render(template_vals))
コード例 #6
0
ファイル: handlers.py プロジェクト: Man-UP/website
    def post(self):
        if len(self.request.POST) == 4 and 'handle' in self.request.POST \
                and 'real_name' in self.request.POST \
                and 'email' in self.request.POST \
                and 'bio' in self.request.POST:

            handle = self.request.POST.getall('handle')[0]
            template_dict = {}
            member = Member.get_current_member()
            other = Member.gql('WHERE handle = :1', handle).get()

            if (not handle or len(handle) > 12 or
                any(l not in self.valid_letters for l in handle)):
                template_dict['error'] = 'Pick something sensible, you moron.'

            elif other and other.user_id != member.user_id:
                template_dict['error'] = 'Sorry, already taken.'

            elif handle.lower() in self.banned_names:
                template_dict['error'] = self.banned_names[handle]

            else:
                real_name = self.request.POST.getall('real_name')[0]
                if real_name:
                    member.real_name = real_name
                email = self.request.POST.getall('email')[0]
                if email:
                    member.email = email
                bio = self.request.POST.getall('bio')[0]
                if bio:
                    member.bio = bio
                member.handle = handle
                member.save()
                template_dict['error'] = 'Profile updated'
            self.render_template('account', template_dict)
コード例 #7
0
ファイル: member.py プロジェクト: cnspica/Joyaay
 def get(self, member_id=""):
     if member_id:
         self.member_allowd(member_id)
         members = Member.get_by_id(member_id)
     else:
         members = Member.get_by_uid(self.current_user)
     result = {"data": members}
     self.finish(result)
コード例 #8
0
ファイル: vc.py プロジェクト: eugeneai/ZCA
 def on_add_clicked(self, *args):
     number = self.ui.number.get_text()
     name = self.ui.name.get_text()
     member = Member()
     member.number = number
     member.name = name
     self.add(member)
     self.ui.list_store.append((member, number, name,))
コード例 #9
0
ファイル: signals.py プロジェクト: jackschultz/streakflow
def create_callback(sender, *args, **kwargs):
  user = kwargs['user']
  member = Member()
  member.user = user
  member.save()
  #now we want to create a goal for this member,
  #so they have something and get goals
  goal = Goal(goal_name="Create more goals!",num_per_frame=1,time_frame_len='d')
  goal.member = member
  goal.save()
コード例 #10
0
 def create(self):
     """Creates and returns a new member"""
     member = MemberModel()
     name = input("Name: ")
     personal_number = self._read_personal_number("Pesonal Number:")
     member.name = name
     member.personal_number = personal_number
     self.display(member)
     if not self._read_binary("Is this correct?"):
         self.edit(member)
     return member
コード例 #11
0
def member(request):
    response = {}

    if request.method == "POST":
        user = request.data["userId"]
        password = request.data["password"]

        if user is None or password is None:
            response["STS"] = ERR_USER_PARAM
            response["MSG"] = MSG[ERR_USER_PARAM]

            return Response(response)

        member = Member(user=user, password=password)
        member.save()

        response["STS"] = SUCCESS
        response["MSG"] = MSG[SUCCESS]
        response["DAT"] = member.id

        return Response(response)

    if request.method == "GET":
        user = request.query_params["userId"]
        password = request.query_params["password"]

        if user is None or password is None:
            response["STS"] = ERR_USER_PARAM
            response["MSG"] = MSG[ERR_USER_PARAM]

            return Response(response)

        member = Member.objects.filter(user=user, password=password)

        if not member:
            response["STS"] = ERR_DB_SELECT
            response["MSG"] = "Login Fail. Check user id and password"
        else:
            resData = {}
            resData["id"] = member[0].id
            resData["user"] = member[0].user

            request.session["login"] = True
            request.session["member_id"] = member[0].id
            request.session["member_user"] = member[0].user

            response["STS"] = SUCCESS
            response["MSG"] = MSG[SUCCESS]
            response["DAT"] = resData

            return Response(response)
コード例 #12
0
ファイル: base.py プロジェクト: ergatea/gitpub2
 def get_current_user(self):
     mid = self.session.get("mid")
     logined = self.session.get("logined")
     if mid and logined:
         member = Member.getObjectByObjectId(mid)
         return member
     else:
         member_cookie = self.get_secure_cookie(self.settings["cookie_name"])
         if member_cookie:
             member_json = self.parseJson(member_cookie)
             if member_json.get("mid") and member_json.get("logined"):
                 member = Member.getObjectByObjectId(mid)
                 return member
     return None
コード例 #13
0
ファイル: test_query.py プロジェクト: FrViPofm/macaron
    def testLimitOffset(self):
        team = Team.create(name="Houkago Tea Time")
        for name in self.names:
            team.members.append(first_name=name[0], last_name=name[1], part=name[2], age=name[3])

        # OFFSET 2
        qs = Member.all().offset(2).order_by("id")
        self.assertEqual(qs[0].first_name, "Yui")
        self.assertEqual(qs[1].first_name, "Tsumugi")
        self.assertEqual(qs.count(), 3)

        # LIMIT 1 OFFSET 2
        qs = Member.all().offset(2).limit(1).order_by("id")
        self.assertEqual(qs[0].first_name, "Yui")
        self.assertEqual(qs.count(), 1)
コード例 #14
0
ファイル: handlers.py プロジェクト: eldog/man-up-website
    def render_template(self, template_name, template_dict=None):
        tag_line = 'Next meeting coming soon'

        if template_dict is None:
            template_dict = {}

        user = Member.get_current_member()

        if user:
            if self.login_required:
                redirect_target = '/'
            else:
                redirect_target = self.request.path
            url_creator = users.create_logout_url
        else:
            redirect_target = '/login?url=%s' % self.request.path
            url_creator = users.create_login_url

        defaults = {
            'user': user,
            'is_admin': users.is_current_user_admin(),
            'log_url': url_creator(redirect_target),
            'tag_line': tag_line,
            'title': self.title
        }

        for key in defaults:
            if key not in template_dict:
                template_dict[key] = defaults[key]

        template_path = get_path(
            os.path.join('templates', '%s.html' % template_name)
        )
        self.response.out.write(template.render(template_path, template_dict))
コード例 #15
0
ファイル: reminder.py プロジェクト: ergatea/gitpub2
def create_mention(**kwargs):
    receiver = Member.getMemberByUsername(kwargs['username'])
    if receiver:
        kwargs.update(receiver=receiver)
        reminder = Reminder.create(**kwargs)
    else:
        logging.error("no member found")
コード例 #16
0
ファイル: excel_import.py プロジェクト: elshobaky/MeX-LMS
def add_members_to_db(fin=members_json):
    from PyQt4 import QtCore
    from models import Member
    from assets.validators import valid_email, valid_phone
    with open(fin, 'r') as members_file:
        data = members_file.read()
        data = json.loads(data)
    sheets = data.keys()
    for s in sheets:
        print s
        for member in data[s]:
            if len(member) != 5:
                print 'invalid member'
                return
            mob = member[0]
            mob = mob if valid_phone(mob) else None
            email = member[1]
            email = email if valid_email(email) else None
            grade = member[2]
            name = member[3]
            num = member[4]
            if name and num.isdigit():
                m = Member.add(name=name, mob=mob, email=email, note=grade)
                if type(m) in [str, QtCore.QString]:
                    print m, name, num
コード例 #17
0
ファイル: vc.py プロジェクト: eugeneai/ZCA
    def book_issue(self, member_number, book_barcode):
        member = Member()
        member.number = member_number
        memberdboperation = getAdapter(member, IDbOperation)
        member = memberdboperation.get()[0]

        book = Book()
        book.number = book_barcode
        bookdboperation = getAdapter(book, IDbOperation)
        book = bookdboperation.get()[0]

        circulation = Circulation()
        circulation.member = member
        circulation.book = book
        circulationdboperation = getAdapter(circulation, IDbOperation)
        circulationdboperation.add()
コード例 #18
0
ファイル: member.py プロジェクト: cnspica/Joyaay
 def put(self, member_id):
     self.member_allowd(member_id)
     nickname = utf8(self.get_argument("nickname", ""))
     if nickname:
         birthday = self.get_argument("birthday", '2010-01-01')
         sex = self.get_argument("sex", 'M')
         if self.request.files and 'gravatar' in self.request.files:
             file_metas = self.request.files['gravatar'][0]
             filename = "%s.jpg" % rand_name(file_metas['filename'])
             save(filename, file_metas['body'])
             filename = "http://dstore-dstor.stor.sinaapp.com/%s" % filename
         else:
             filename = ''
         Member.modify(member_id, nickname, birthday, sex, filename)
         self.finish()
     else:
         raise HTTPAPIError(400)
コード例 #19
0
ファイル: handlers.py プロジェクト: Man-UP/website
 def get(self, handle):
     query = Member.gql('WHERE handle = :1', urllib.unquote(handle))
     member = iter(query).next() if query.count() else None
     member_talks = TalkNew.all().filter('member = ', member)
     self.render_template('member', {
         'member': member,
         'member_talks' : member_talks
     })
コード例 #20
0
ファイル: views.py プロジェクト: timp21337/ucl
def _members(request, db=None, ctx={}):
    t = loader.get_template('members.html')
    try:
        status = request.REQUEST['status']
    except StandardError:
        status = 'Elfin'
    ctx['status'] = status
    ctx['members'] = Member.members_with_status(status)
    return HttpResponse(t.render(RequestContext(request, ctx)))
コード例 #21
0
ファイル: api.py プロジェクト: zmyaro/star-site
	def get(self):
		if not check_authentication(self):
			return
		
		# Get all users from the given semester
		selected_semester = self.request.get('semester')
		
		if selected_semester:
			members = Member.query(Member.show == True, Member.semesters_paid == selected_semester).order(Member.name).fetch(limit=None)
		else:
			members = Member.query(Member.show == True, Member.never_paid == False).order(Member.name).fetch(limit=None)
		
		output = []
		for member in members:
			output.append(format_member(member))
		
		self.response.headers['Content-Type'] = 'application/json'
		self.response.write(json.dumps(output))
コード例 #22
0
ファイル: handlers.py プロジェクト: Man-UP/website
 def get(self):
     if 'url' in self.request.GET:
         member = Member.get_current_member()
         if member.handle.isdigit() and len(member.handle) == 21:
             self.redirect('/account')
         else:
             self.redirect(self.request.GET.getall('url')[0])
     else:
         self.redirect('/')
コード例 #23
0
ファイル: logics.py プロジェクト: Jack1007/clubot
    def add(cls, jid, nick = None, show = None):
        """ 添加一个成员
        Arguments:
            `jid`   -   成员jid
            `nick`  -   昵称
            `show`  -   stanze.show
        """
        if cls.get_one(jid):
            return
        m = Member(jid, nick)
        m.status = [Status(show, jid.resource)]
        try:
            session.add(m)
            session.commit()
        except:
            session.rollback()

        return m
コード例 #24
0
ファイル: members.py プロジェクト: zmyaro/star-site
	def get(self, args):
		template_vals = generate_base_template_vals(self)
		template_vals['title'] = 'Members'
		template_vals['page'] = 'members'
		
		# Check for a search query.
		search_query = self.request.get('q')
		
		# If there was no search or semester specified, default to the current semester.
		if not search_query:
			search_query = 'semester:' + str(get_current_semester())
		
		# Run the search.
		search_results = search.Index(MEMBER_SEARCH_INDEX_NAME).search(search.Query(
				query_string=search_query,
				options=search.QueryOptions(
					limit=999,
					ids_only=True,
					sort_options=search.SortOptions(
						expressions=[
							search.SortExpression(
								expression='name',
								direction=search.SortExpression.ASCENDING, 
								default_value='')
						]))))
		
		# Fetch the members.
		show_private = users.is_current_user_admin()
		members = []
		for result in search_results.results:
			member = Member.query(Member.id == result._doc_id).get()
			if member and (member.show or show_private):
				members.append(member)
		
		template_vals['members'] = members
		
		# Get all possible semesters to put in the menu.
		selected_semester = get_semester_from_query(search_query)
		
		semesters = []
		for semester in get_all_semesters():
			semesters.append({
				'id': semester,
				'pretty': semester_pretty(semester),
				'selected': semester == selected_semester
			})
		template_vals['semesters'] = semesters
		if selected_semester and selected_semester > FIRST_SEMESTER:
			template_vals['prev_semester'] = prev_semester(selected_semester)
		if selected_semester and selected_semester < get_current_semester():
			template_vals['next_semester'] = next_semester(selected_semester)
		if selected_semester and selected_semester >= FIRST_SEMESTER and selected_semester <= get_current_semester():
			template_vals['selected_semester'] = selected_semester
		
		template = JINJA_ENVIRONMENT.get_template('members_list.html')
		self.response.write(template.render(template_vals))
コード例 #25
0
ファイル: vc.py プロジェクト: eugeneai/ZCA
    def initialize_lists(self):
        cm=Gtk.ListStore(object, str, str, str)
        self.ui.catalog=cm
        self.ui.catalog_view.set_model(cm)
        for _ in range(3):
            b=Book()
            b.title="Brotherhood of the ring"
            b.author="J.R.R.Tolkien"
            b.barcode="123-1232"
            self.append_book(b)

        mm=Gtk.ListStore(object, int, str)
        self.ui.members=mm
        self.ui.member_view.set_model(mm)
        for _ in range(3):
            m=Member()
            m.name="Jim Carry"
            m.number=123
            self.append_member(m)
コード例 #26
0
ファイル: handlers.py プロジェクト: eldog/man-up-website
 def post(self):
     post = self.request.POST
     if post['kind'] == 'badge':
         badge = Badge(
             name=post['name'],
             description=post['description'],
             category=post['category'],
             image=post['image'],
             value=int(post['value'])
         )
         badge.save()
     elif post['kind'] == 'article':
         date = datetime.datetime.strptime(post['date'], '%Y-%m-%d').date()
         article = NewsArticle(
             title=post['title'],
             author=post['author'],
             body=post['body'],
             date=date
         )
         article.save()
     elif post['kind'] == 'award':
         badge = Badge.get_by_id(int(post['badge']))
         for member in post.getall('members'):
             member = Member.get_by_id(int(member))
             award = Award(
                 member=member,
                 badge=badge,
                 date=datetime.date.today(),
                 proof=post['proof']
             )
             award.save()
             member.score_cache = member.score + badge.value
             member.save()
     elif post['kind'] == 'talk':
         talk = Talk(
             title=post['title'],
             date=datetime.datetime.strptime(post['date'], '%Y-%m-%d').date(),
             description=post['description'],
             member=Member.get_by_id(int(post['member'])),
             video=post['video']
         )
         talk.put()
     self.get()
コード例 #27
0
ファイル: handlers.py プロジェクト: eldog/man-up
 def post(self):
     post = self.request.POST
     if post['kind'] == 'badge':
         badge = Badge(
             name=post['name'],
             description=post['description'],
             category=post['category'],
             image=post['image'],
             value=int(post['value'])
         )
         badge.save()
     elif post['kind'] == 'award':
         badge = Badge.get_by_id(int(post['badge']))
         for member in post.getall('members'):
             member = Member.get_by_id(int(member))
             award = Award(
                 member=member,
                 badge=badge,
                 date=datetime.date.today(),
                 proof=post['proof']
             )
             award.save()
             member.score += badge.value
             member.save()
     elif post['kind'] == 'talk':
         talk = Talk(
             title=post['title'],
             date=utils.parse_date(post['date']),
             description=post['description'],
             member=Member.get_by_id(int(post['member'])),
             video=post['video']
         )
         talk.put()
     elif post['kind'] == 'taglineform':
         properties = GeneralSiteProperties.all().get()
         if properties == None:
             properties = GeneralSiteProperties(tag_line=post['tagline'])
             properties.put()
         else:
             properties.tag_line = post['tagline']
             properties.put()
     self.get()
コード例 #28
0
ファイル: test_query.py プロジェクト: FrViPofm/macaron
    def testManyToManyOperation(self):
        team = Team.create(name="Houkago Tea Time")
        for name in self.names:
            team.members.append(first_name=name[0], last_name=name[1], part=name[2], age=name[3])
        song1 = Song.create(name="Utauyo!! MIRACLE")
        song2 = Song.create(name="Tenshi ni Fureta yo!")

        for m in Member.all(): song1.members.append(m)
        for m in Member.select(age=17): song2.members.append(m)

        members = song1.members
        self.assertEqual(members.count(), 5)

        members = song2.members
        self.assertEqual(members.count(), 4)

        azusa = Member.get(first_name="Azusa")
        songs = azusa.songs
        self.assertEqual(songs.count(), 1)
        self.assertEqual(songs[0].name, "Utauyo!! MIRACLE")
コード例 #29
0
ファイル: views.py プロジェクト: ParkerPo/ntusbleague
def register(request):
	if request.method != 'POST' :  #第一次進來
		teams = Team.objects.order_by("current")
		context={'teams':teams,'thirty':range(30)}
		return render(request,"sbleague/register.html",context)

	else :
		team_n = request.POST.get("team","")
		team = Team.objects.get(teamID=int(team_n))
		for i in range(30) : 
			name = request.POST.get("name_"+str(i),"")
			number = request.POST.get("number_"+str(i),"")
			stu_id = request.POST.get("id_"+str(i),"") 
			old_id = request.POST.get("old_id"+str(i),"")

			if len(name)>0:
				try:
					player=Member.objects.get(studentID = stu_id)
				except ObjectDoesNotExist:
					#找不到,先看看是不換學號
					try:
						player = Member.objects.get(studentID = old_id)
					except ObjectDoesNotExist:
						#又找不到,是新的人
						member = Member(name=name,number=number,studentID=stu_id,current=1,team=team)
						member.save()

						continue
						
					player.studentID = stu_id
					player.team = team

				#找到了
				player.save()
				
			else:
				break

		teams = Team.objects.order_by("current")
		context={'teams':teams,'thirty':range(30),'alert':team.name}
		return render(request,"sbleague/register.html",context)
コード例 #30
0
ファイル: member.py プロジェクト: cnspica/Joyaay
 def post(self):
     nickname = utf8(self.get_argument("nickname", ""))
     #self.finish({'nickname': nickname.encode('utf8')})
     if nickname:
         member = Member.get_by_name(self.current_user, nickname)
         if member:
             raise HTTPAPIError(407)
         else:
             birthday = self.get_argument("birthday", '2010-01-01')
             sex = self.get_argument("sex", 'M')
             if self.request.files and 'gravatar' in self.request.files:
                 file_metas = self.request.files['gravatar'][0]
                 filename = "%s.jpg" % rand_name(file_metas['filename'])
                 save(filename, file_metas['body'])
                 filename = "http://dstore-dstor.stor.sinaapp.com/%s" % filename
             else:
                 filename = ''
             result = {'member_id': Member.creat(self.current_user, nickname, birthday, sex, filename)}
             self.finish(result)
     else:
         raise HTTPAPIError(400) 
コード例 #31
0
ファイル: views.py プロジェクト: timp21337/ucl
def counts(members):
    return [len(Member.boys(members)), len(Member.girls(members)), len(members)]
コード例 #32
0
from models import Member, Post
from stores import MemberStore, PostStore

member1 = Member(1, "tourad", 15)
member2 = Member(2, "Mohamedou", 20)
member3 = Member(3, "cheikh", 25)

post1 = Post(1, "Post1", "Content1")
post2 = Post(2, "Post2", "Content2")
post3 = Post(3, "Post3", "Content3")

# Store of members
member_store = MemberStore()
post_sotre = PostStore()

member_store.add(member1)
member_store.add(member2)
member_store.add(member3)

#list = member_store.get_all()
print(" ")
print("***members get_All***")
for me in member_store.get_all():
    print(me)

print(" ")
print("****get_by_id member1*****")
print(member_store.get_by_id(1))

print(" ")
print("update member1")
コード例 #33
0
def add_game(request):

    league_list = League.objects.all()
    member_list = Member.objects.all()
    game = Game()
    batting_list = []
    pitching_list = []

    if request.method != "POST":
        game.date = None
        game.location = ""
        game.away_name = ""
        game.away_scores = [0] * 7
        game.home_name = ""
        game.home_scores = [0] * 7
        game.record = ""
        message = ""
        warning = ""

        context = {
            'league_list': league_list,
            'game': game,
            'warning': warning,
            'message': message
        }

        return render(request, 'team/add_game.html', context)

    else:

        league_id = request.POST["league_id"]
        game.league = League.objects.get(id=league_id)
        game.date = request.POST["date"]
        game.location = request.POST["location"]
        game.record = request.POST["record_text"]
        game.away_name = request.POST["away_name"]
        game.home_name = request.POST["home_name"]
        game.away_scores = gather_team_scores_from_web(request, 'away')
        game.home_scores = gather_team_scores_from_web(request, 'home')

        message = ""
        warning = ""
        game_record = None
        team = None

        if 'add-new-league-btn' in request.POST:
            print("add new league!")
            league_name = request.POST["new-league-name"]

            if league_name != None and league_name != "":

                league = League.objects.filter(name=league_name)
                if (league.exists()):
                    warning = "League name %s already exists." % league_name
                else:
                    league = League(name=league_name)
                    league.save()
                    message = 'Add new league: %s' % league_name

            league_list = League.objects.all()

        if 'add-new-member-btn' in request.POST:
            print("add new member!")
            member_name = request.POST["new-member-name"]
            member_number = int(request.POST["new-member-number"])

            if member_name != None:

                member = Member.objects.filter(name=member_name)
                if (member.exists()):
                    warning = "Member %s already exists." % member_name
                else:
                    member = Member(name=member_name, number=member_number)
                    member.save()
                    message = 'Add new member: %s(%d)' % (member_name,
                                                          member_number)

            member_list = Member.objects.all()

        if ('preview-btn' in request.POST) or ('save-game-btn'
                                               in request.POST):

            game.league = League.objects.get(id=league_id)
            record_table = text_to_table(game.record.encode('utf8'))

            away_name = game.away_name.encode('utf8')
            home_name = game.home_name.encode('utf8')

            if (away_name.upper() == 'RB'):
                away_table = record_table
                home_table = []
            else:
                away_table = []
                home_table = record_table

            game_record, warning = parse_game_record(away_name, game.away_scores, away_table, \
                                                      home_name, game.home_scores, home_table)

            game.away_R = game_record.away.R
            game.away_H = game_record.away.H
            game.away_E = game_record.away.E
            game.home_R = game_record.home.R
            game.home_H = game_record.home.H
            game.home_E = game_record.home.E

            if (warning == ""):
                message = "Preview record table!"

                game_record, team = extract_single_team_data(game_record, 'RB')

                # create and save new Batting object
                nBatter = len(team.batters)
                batting_list = []

                for i in range(nBatter):
                    batting = Batting()
                    batting.game = game
                    batting.order = team.batters[i].order
                    batting.pa = team.batters[i].PA
                    batting.single = team.batters[i].B1
                    batting.double = team.batters[i].B2
                    batting.triple = team.batters[i].B3
                    batting.hr = team.batters[i].HR
                    batting.rbi = team.batters[i].RBI
                    batting.run = team.batters[i].RUN
                    batting.bb = team.batters[i].BB
                    batting.k = team.batters[i].K
                    batting.sf = team.batters[i].SF
                    batting.field = team.batters[i].pos
                    try:
                        batting.member = Member.objects.get(
                            name=team.batters[i].name.decode('utf8'))
                    except Member.DoesNotExist:
                        warning = "member name %s does not exist." % team.batters[
                            i].name
                        break

                    batting_list.append(batting)

                # create and save new Batting object
                nPitcher = len(team.pitchers)
                pitching_list = []

                for i in range(nPitcher):
                    pitching = Pitching()
                    pitching.game = game
                    pitching.order = i
                    pitching.outs = team.pitchers[i].OUT
                    pitching.pa = team.pitchers[i].TBF
                    pitching.hit = team.pitchers[i].H
                    pitching.hr = team.pitchers[i].HR
                    pitching.bb = team.pitchers[i].BB
                    pitching.k = team.pitchers[i].K
                    pitching.run = team.pitchers[i].RUN
                    pitching.er = team.pitchers[i].ER
                    pitching.go = team.pitchers[i].GO
                    pitching.fo = team.pitchers[i].FO
                    pitching.win = team.pitchers[i].WIN
                    pitching.lose = team.pitchers[i].LOSE
                    try:
                        pitching.member = Member.objects.get(
                            name=team.pitchers[i].name.decode('utf8'))
                    except Member.DoesNotExist:
                        warning = "member name %s does not exist." % team.pitchers[
                            i].name
                        break

                    pitching_list.append(pitching)

                # add rows for changing pitchers
                N = len(pitching_list)
                for i in range(5 - N):
                    pitching_list.append(Pitching())

                if 'save-game-btn' in request.POST:

                    # create and save new Game object
                    game.away_scores = IntegerArray_to_CommaSeparatedString(
                        game.away_scores)
                    game.home_scores = IntegerArray_to_CommaSeparatedString(
                        game.home_scores)
                    game.save()

                    nBatter = len(batting_list)
                    for i in range(nBatter):
                        batting = batting_list[i]
                        member_id = int(
                            request.POST.get("batting_%d_id" % (i + 1), ""))

                        if (member_id != 0):
                            batting.member = Member.objects.get(id=member_id)
                            batting.game = game
                            batting.save()

                    nPitcher = len(pitching_list)
                    for i in range(nPitcher):
                        pitching = pitching_list[i]
                        member_id = int(
                            request.POST.get("pitching_%d_id" % (i + 1), ""))

                        if (member_id != 0):
                            pitching.member = Member.objects.get(id=member_id)
                            pitching.game = game
                            pitching.outs = int(
                                request.POST.get("pitching_%d_outs" % (i + 1),
                                                 ""))
                            pitching.pa = int(
                                request.POST.get("pitching_%d_pa" % (i + 1),
                                                 ""))
                            pitching.hit = int(
                                request.POST.get("pitching_%d_hit" % (i + 1),
                                                 ""))
                            pitching.hr = int(
                                request.POST.get("pitching_%d_hr" % (i + 1),
                                                 ""))
                            pitching.bb = int(
                                request.POST.get("pitching_%d_bb" % (i + 1),
                                                 ""))
                            pitching.k = int(
                                request.POST.get("pitching_%d_k" % (i + 1),
                                                 ""))
                            pitching.run = int(
                                request.POST.get("pitching_%d_run" % (i + 1),
                                                 ""))
                            pitching.er = int(
                                request.POST.get("pitching_%d_er" % (i + 1),
                                                 ""))
                            pitching.go = int(
                                request.POST.get("pitching_%d_go" % (i + 1),
                                                 ""))
                            pitching.fo = int(
                                request.POST.get("pitching_%d_fo" % (i + 1),
                                                 ""))

                            win = request.POST.get("pitching_%d_win" % (i + 1),
                                                   "")
                            lose = request.POST.get(
                                "pitching_%d_lose" % (i + 1), "")

                            if (win != ''):
                                pitching.win = 1
                            else:
                                pitching.win = 0

                            if (lose != ''):
                                pitching.lose = 1
                            else:
                                pitching.lose = 0

                            pitching.save()

                    return redirect("/game/" + str(game.id))
                # end of add-game-btn
            # end of preview

        context = {
            'league_list': league_list,
            'game': game,
            'warning': warning,
            'message': message,
            'game_record': game_record,
            'team': team,
            'member_list': member_list,
            'batting_list': batting_list,
            'pitching_list': pitching_list
        }

        return render(request, 'team/add_game.html', context)
コード例 #34
0
with open('design2.json', 'r') as file:
    data_str = file.read().replace('\n', '').replace(' ', '')

structur = json.loads(data_str)

#=================INIT

nodes = []
members = []
forces = []
heigth = 0
widht = 0
for n in structur["nodes"]:  #Load nodes
    nodes.append(Node(n))
for m in structur["members"]:  #Load Members
    members.append(Member(m))
for f in structur["forces"]:  #Load Forces
    forces.append(Force(f))

for n in nodes:
    if (n.x > widht):
        widht = n.x
    if (n.y > heigth):
        heigth = n.y

heigth += 200
widht += 200

pl = plot(heigth, widht)
pl.nodes(nodes)
pl.members(members, nodes)
コード例 #35
0
async def handler_add_members(message: types.Message):
    await check_access(message, Grant.WRITE_ACCESS)
    match = constraints.REGEX_CMD_GROUP_MEMBERS.search(message.text)
    if not match:
        return await message.reply(md.text(
            md_style.bold("Пример вызова:"),
            md_style.code("/add_members group username1 username2"),
            " ",
            md_style.bold("Ограничения:"),
            md.text("group:", constraints.MESSAGE_FOR_GROUP),
            md.text("username:"******"members: {all_members}")

    if len(all_members) < 1:
        return await message.reply('Нужно указать хотя бы одного пользователя!'
                                   )

    with db.get_connection() as conn:
        db.select_chat_for_update(conn, chat_id=message.chat.id)

        group = db.select_group_by_alias_name(conn,
                                              chat_id=message.chat.id,
                                              alias_name=group_name)
        if not group:
            return await message.reply(md.text('Группа',
                                               md_style.code(group_name),
                                               'не найдена!'),
                                       parse_mode=ParseMode.MARKDOWN)
        logging.info(f"group: {group}")

        existing_members: List[Member] = db.select_members(
            conn, group_id=group.group_id)

        if len(existing_members) + len(
                all_members) > constraints.MAX_MEMBERS_PER_GROUP:
            return await message.reply(
                f'Слишком много пользователей уже добавлено в группу!'
                f' Текущее ограничение для одной группы: {constraints.MAX_MEMBERS_PER_GROUP}'
            )

        for member in all_members:
            db.insert_member(conn, group_id=group.group_id, member=member)

    await message.reply(md.text(
        md.text(
            "Пользователи добавленные в группу",
            md_style.code(group_name),
        ),
        md_style.code("\n".join(
            [f"- {x}" for x in convert_members_to_names(all_members)])),
        sep='\n'),
                        parse_mode=ParseMode.MARKDOWN)
コード例 #36
0
def edit_game(request, game_id):

    game = Game.objects.get(id=game_id)
    league_list = League.objects.all()
    member_list = Member.objects.all()
    batting_query = Batting.objects.filter(game=game)
    pitching_query = Pitching.objects.filter(game=game)

    if request.method != "POST":
        game.date = unicode(game.date)
        away_name = game.away_name.encode('utf8')
        home_name = game.home_name.encode('utf8')
        game.away_scores = CommaSeparatedString_to_IntegerArray(
            game.away_scores)
        game.home_scores = CommaSeparatedString_to_IntegerArray(
            game.home_scores)
        message = ""
        warning = ""

        record_table = text_to_table(game.record.encode('utf8'))

        if (away_name.upper() == 'RB'):
            away_table = record_table
            home_table = []
        else:
            away_table = []
            home_table = record_table

        game_record, warning = parse_game_record(away_name, game.away_scores, away_table, \
                                                  home_name, game.home_scores, home_table)

        if (away_name.upper() == 'RB'):
            team = game_record.away
        else:
            team = game_record.home

        batting_list = []
        for batting in batting_query:
            batting_list.append(batting)

        pitching_list = []
        for pitching in pitching_query:
            pitching_list.append(pitching)

        # add rows for changing pitchers
        N = len(pitching_list)
        for i in range(5 - N):
            pitching_list.append(Pitching())

        context = {
            'league_list': league_list,
            'game': game,
            'warning': warning,
            'message': message,
            'game_record': game_record,
            'team': team,
            'member_list': member_list,
            'batting_list': batting_list,
            'pitching_list': pitching_list
        }

        return render(request, 'team/edit_game.html', context)

    else:
        # POST

        league_id = request.POST["league_id"]
        game.league = League.objects.get(id=league_id)
        game.date = request.POST["date"]
        game.location = request.POST["location"]
        game.record = request.POST["record_text"]
        game.away_name = request.POST["away_name"]
        game.home_name = request.POST["home_name"]
        game.away_scores = gather_team_scores_from_web(request, 'away')
        game.home_scores = gather_team_scores_from_web(request, 'home')

        print game.home_scores
        message = ""
        warning = ""
        game_record = None
        team = None

        if 'add-new-league-btn' in request.POST:
            print("add new league!")
            league_name = request.POST["new-league-name"]

            if league_name != None:

                league = League.objects.filter(name=league_name)
                if (league.exists()):
                    warning = "League name %s already exists." % league_name
                else:
                    league = League(name=league_name)
                    league.save()
                    message = 'Add new league: %s' % league_name

            league_list = League.objects.all()

        if 'add-new-member-btn' in request.POST:
            print("add new member!")
            member_name = request.POST["new-member-name"]
            member_number = int(request.POST["new-member-number"])

            if member_name != None:

                member = Member.objects.filter(name=member_name)
                if (member.exists()):
                    warning = "Member %s already exists." % member_name
                else:
                    member = Member(name=member_name, number=member_number)
                    member.save()
                    message = 'Add new member: %s(%d)' % (member_name,
                                                          member_number)

            member_list = Member.objects.all()

        if ('preview-btn' in request.POST) or ('save-game-btn'
                                               in request.POST):

            game.league = League.objects.get(id=league_id)
            record_table = text_to_table(game.record.encode('utf8'))

            away_name = game.away_name.encode('utf8')
            home_name = game.home_name.encode('utf8')

            if (away_name.upper() == 'RB'):
                away_table = record_table
                home_table = []
            else:
                away_table = []
                home_table = record_table

            game_record, warning = parse_game_record(away_name, game.away_scores, away_table, \
                                                      home_name, game.home_scores, home_table)

            game.away_R = game_record.away.R
            game.away_H = game_record.away.H
            game.away_E = game_record.away.E
            game.home_R = game_record.home.R
            game.home_H = game_record.home.H
            game.home_E = game_record.home.E

            if (warning == ""):
                message = "Preview record table!"

                game_record, team = extract_single_team_data(game_record, 'RB')

                batting_list = []
                for batter in team.batters:
                    batting = Batting()
                    for play in batting_query:
                        if batter.name.decode('utf8') == play.member.name:
                            batting = play
                            break

                    batting.member = Member.objects.get(
                        name=batter.name.decode('utf8'))
                    batting.game = game
                    batting.order = batter.order
                    batting.pa = batter.PA
                    batting.single = batter.B1
                    batting.double = batter.B2
                    batting.triple = batter.B3
                    batting.hr = batter.HR
                    batting.rbi = batter.RBI
                    batting.run = batter.RUN
                    batting.bb = batter.BB
                    batting.k = batter.K
                    batting.sf = batter.SF
                    batting.field = batter.pos

                    batting_list.append(batting)

                # DO NOT modify pitching query with team.pitchers
                pitching_list = []
                for pitching in pitching_query:
                    pitching_list.append(pitching)

                # add rows for changing pitchers
                N = len(pitching_list)
                for i in range(5 - N):
                    pitching_list.append(Pitching())

                if 'save-game-btn' in request.POST:

                    # create and save new Game object
                    game.away_scores = IntegerArray_to_CommaSeparatedString(
                        game.away_scores)
                    game.home_scores = IntegerArray_to_CommaSeparatedString(
                        game.home_scores)
                    game.save()

                    nBatter = len(batting_list)
                    for i in range(nBatter):
                        batting = batting_list[i]
                        member_id = int(
                            request.POST.get("batting_%d_id" % (i + 1), ""))

                        if (member_id != 0):
                            batting.member = Member.objects.get(id=member_id)
                            batting.game = game
                            batting.save()

                    nPitcher = len(pitching_list)
                    for i in range(nPitcher):
                        pitching = pitching_list[i]
                        member_id = int(
                            request.POST.get("pitching_%d_id" % (i + 1), ""))

                        if (member_id != 0):
                            pitching.member = Member.objects.get(id=member_id)
                            pitching.game = game
                            pitching.outs = int(
                                request.POST.get("pitching_%d_outs" % (i + 1),
                                                 ""))
                            pitching.pa = int(
                                request.POST.get("pitching_%d_pa" % (i + 1),
                                                 ""))
                            pitching.hit = int(
                                request.POST.get("pitching_%d_hit" % (i + 1),
                                                 ""))
                            pitching.hr = int(
                                request.POST.get("pitching_%d_hr" % (i + 1),
                                                 ""))
                            pitching.bb = int(
                                request.POST.get("pitching_%d_bb" % (i + 1),
                                                 ""))
                            pitching.k = int(
                                request.POST.get("pitching_%d_k" % (i + 1),
                                                 ""))
                            pitching.run = int(
                                request.POST.get("pitching_%d_run" % (i + 1),
                                                 ""))
                            pitching.er = int(
                                request.POST.get("pitching_%d_er" % (i + 1),
                                                 ""))
                            pitching.go = int(
                                request.POST.get("pitching_%d_go" % (i + 1),
                                                 ""))
                            pitching.fo = int(
                                request.POST.get("pitching_%d_fo" % (i + 1),
                                                 ""))

                            win = request.POST.get("pitching_%d_win" % (i + 1),
                                                   "")
                            lose = request.POST.get(
                                "pitching_%d_lose" % (i + 1), "")

                            if (win != ''):
                                pitching.win = 1
                            else:
                                pitching.win = 0

                            if (lose != ''):
                                pitching.lose = 1
                            else:
                                pitching.lose = 0

                            pitching.save()

                    return redirect("/game/" + str(game.id))

        context = {
            'league_list': league_list,
            'game': game,
            'warning': warning,
            'message': message,
            'game_record': game_record,
            'team': team,
            'member_list': member_list,
            'batting_list': batting_list,
            'pitching_list': pitching_list
        }

        return render(request, 'team/edit_game.html', context)
コード例 #37
0
ファイル: app.py プロジェクト: nomed/PhippsPassServer
def insertUpdate():
    logging.debug("In insertUpdate()")
    update_file = os.path.join(app.config['UPLOAD_FOLDER'], "update.csv")
    try:
        df = pd.read_csv(update_file)
    except:
        return -1
    df.columns = [
        "id", "level", "expiration_date", "status", "associates", "last_name",
        "first_name", "address_1", "address_2", "city", "state", "zip",
        "email", "add_ons", "quantity"
    ]
    diff_count = 0
    try:
        for row in df.itertuples():
            logging.debug("Checking a row")
            logging.debug(row.id)
            if str(row.id) == None or row.id == '' or pd.isnull(row.id):
                break

            diff_count += 1
            existing_mem = Member.query.filter_by(id=row.id).first()
            state = False
            exp_date = None
            add_2 = row.address_2
            add_on_val = row.add_ons
            if row.status == 'Active':
                state = True
            else:
                state = False
            if pd.isna(row.expiration_date) is False:
                for fmt in ('%m/%d/%Y', '%m/%d/%y'):
                    try:
                        exp_date = datetime.strptime(row.expiration_date,
                                                     fmt).astimezone(
                                                         timezone('EST5EDT'))
                    except ValueError:
                        pass
            if pd.isna(row.address_2):
                add_2 = None
            if pd.isna(row.add_ons):
                add_on_val = None
            if existing_mem is None:
                existing_mem = Member(
                    id=str(row.id),
                    member_level=str(row.level),
                    expiration_date=exp_date,
                    status=state,
                    full_name=row.first_name + " " + row.last_name,
                    associated_members=row.associates,
                    address_line_1=str(row.address_1),
                    address_line_2=add_2,
                    city=str(row.city),
                    state=str(row.state),
                    zip=str(row.zip).strip(".0"),
                    email=str(row.email),
                    add_on_name=add_on_val,
                    add_on_value=str(row.quantity).strip(".0"))
                db.session.add(existing_mem)
                db.session.commit()
            else:
                logging.debug("Updating existing member information")
                # Update existing member record
                existing_mem.member_level = row.level
                existing_mem.expiration_date = exp_date
                existing_mem.status = state
                existing_mem.full_name = row.first_name + " " + row.last_name
                existing_mem.associated_members = row.associates
                existing_mem.address_1 = row.address_1
                existing_mem.address_2 = add_2
                existing_mem.city = row.city
                existing_mem.state = row.state
                existing_mem.zip = row.zip
                existing_mem.email = row.email
                logging.debug("Completed")

            # Create a new pass (for both new and updates)
            if exp_date is not None:
                logging.debug(
                    "Creating/updating pass because expiration date is not None"
                )
                # A previous card record exists
                try:
                    logging.debug("Previous card was found")
                    card = db.session.query(
                        Member,
                        Card).join(member_card_association).join(Card).filter(
                            member_card_association.c.member_id ==
                            row.id).first()[1]
                    card.last_updated = datetime.now().astimezone(
                        timezone('EST5EDT')).strftime("%Y-%m-%dT%H:%M:%S")
                except:
                    # Make a new card
                    logging.debug("New card created")
                    card = Card(
                        authenticationToken=hashlib.sha1(
                            existing_mem.id.encode('utf-8')).hexdigest(),
                        file_name=row.first_name + row.last_name + ".pkpass",
                        last_sent=None,
                        last_updated=datetime.now().astimezone(
                            timezone('EST5EDT')).strftime("%Y-%m-%dT%H:%M:%S"))
                # Attach it to membership
                existing_mem.cards.append(card)
                db.session.add(existing_mem)
                db.session.commit()
                logging.debug(
                    "Card has been added to associated member record")

                # Create the actual pass file
                logging.debug("Creating actual card now")
                create_member_pass(row.id, card.file_name)

                # Notify devices attached to this card
                registrations = Device.query.join(registration).join(Card). \
                    filter(registration.c.card_id == card.id).all()
                for device in registrations:
                    logging.debug("Attempting to send push to APN")
                    token = device.push_token
                    alert = {}
                    client = APNSClient(certificate=os.path.join(
                        app.config['CERTIFICATES_FOLDER'],
                        "apn_certificate.pem"),
                                        default_error_timeout=10,
                                        default_expiration_offset=2592000,
                                        default_batch_size=100,
                                        default_retries=5)
                    res = client.send(token, alert)
                    logging.debug(res.errors)
                    logging.debug(res.failures)
                    logging.debug(res.message)
                    logging.debug(res.successes)
                    # TODO: if APNs tells you that a push token is invalid,
                    #  remove that device and its registrations from your server.
                    client.close()
                    db.session.commit()
    except IOError:
        return diff_count
    return diff_count
コード例 #38
0
ファイル: test_query.py プロジェクト: zhenruyan/macaron
 def _name_is_not_set(): Member.create(first_name="Azusa")
 self.assertRaises(macaron.ValidationError, _name_is_not_set)
コード例 #39
0
ファイル: views.py プロジェクト: timp21337/ucl
def _carers(request, db=None, ctx={}):
    t = loader.get_template('carers.html')
    ctx['carers'] = Member.carers()
    return HttpResponse(t.render(RequestContext(request, ctx)))
コード例 #40
0

def fixed_surname(surname):
    return "-".join(x.capitalize() for x in surname.split("-"))


def to_full_name(parts):
    return " ".join(parts[1:]) + " " + parts[0]


for person in os.listdir(image_directory):
    try:
        image_path = os.path.join(image_directory, person)
        base64image = read_base64_image(image_path)

        image = openface_helper.read_as_cv_image(base64image)
        position = openface_helper.all_face_positions(image)[0]

        representation = openface_helper.face_representation(image, position)
        all.append(Member(to_full_name([fixed_surname(x.capitalize()) for x in person[:-4].split("_")]), 
                    representation, base64image))
        


    except Exception as e:
        print("warn: {0}".format(e))


with open("people.pkl", 'wb') as file:
    pickle.dump(all, file)
コード例 #41
0
 def setPoints(self, points, IDs):
     for ID in IDs:
         member, _ = Member.get_or_create(discordID=ID)
         member.points = points
         member.save()
コード例 #42
0
from models import Member, Post
from store import MemberStore, PostStore

member1 = Member("Hany", 40)
member2 = Member("Tawfik", 32)

post1 = Post("Python", "13/02/2018", member1.name, "I love Python")
post2 = Post("Web development", "14/02/2018", member2.name,
             "I'd like to be a full stack web developer")

print(member1.name, member1.age)
print(post2.title, post2.published_date, "written by " + post2.author_name,
      post2.content)

member_store = MemberStore()

member_store.add(member1)
member_store.add(member2)

print(member_store.get_by_name("Hany"))

print(member_store.entity_exist(member1))

print(member_store.get_by_id(1))
member_store.delete(1)
print(member_store.get_by_id(1))

print(member_store.get_by_id(2))
member_store.delete(2)
print(member_store.get_by_id(2))
コード例 #43
0
ファイル: main.py プロジェクト: rakesh4real/FILTER
def add_members(mmbr_req: MemberRequest, db: Session = Depends(get_db)):
	"""
	Adds new Member to database via API.
	Email must be unique
	"""
		
	mmbr = Member()
	# personal
	mmbr.full_name      = mmbr_req.full_name
	mmbr.nick_name      = mmbr_req.nick_name
	mmbr.cur_status     = mmbr_req.cur_status
	mmbr.cur_city       = mmbr_req.cur_city
	mmbr.bio            = mmbr_req.bio
	mmbr.communities    = mmbr_req.communities
	
	# social
	mmbr.twitter_url    = mmbr_req.twitter_url
	mmbr.github_url     = mmbr_req.github_url
	mmbr.linkedin_url   = mmbr_req.linkedin_url
	mmbr.whatsapp_num   = mmbr_req.whatsapp_num
	mmbr.email          = mmbr_req.email
	
	# skill
	mmbr.dom_1          = mmbr_req.dom_1
	mmbr.dom_2          = mmbr_req.dom_2
	mmbr.dom_3          = mmbr_req.dom_3
	mmbr.dom_4          = mmbr_req.dom_4
	mmbr.dom_5          = mmbr_req.dom_5
	mmbr.dom_5          = mmbr_req.dom_5
	mmbr.dom_6          = mmbr_req.dom_6
	mmbr.dom_7          = mmbr_req.dom_7
	mmbr.dom_8          = mmbr_req.dom_8
	mmbr.dom_1skill     = mmbr_req.dom_1skill
	mmbr.dom_1interest  = mmbr_req.dom_1interest
	mmbr.dom_2skill     = mmbr_req.dom_2skill
	mmbr.dom_2interest  = mmbr_req.dom_2interest
	mmbr.dom_3skill     = mmbr_req.dom_3skill
	mmbr.dom_3interest  = mmbr_req.dom_3interest
	mmbr.dom_4skill     = mmbr_req.dom_4skill
	mmbr.dom_4interest  = mmbr_req.dom_4interest
	mmbr.dom_5skill     = mmbr_req.dom_5skill
	mmbr.dom_5interest  = mmbr_req.dom_5interest
	mmbr.dom_6skill     = mmbr_req.dom_6skill
	mmbr.dom_6interest  = mmbr_req.dom_6interest
	mmbr.dom_7skill     = mmbr_req.dom_7skill
	mmbr.dom_7interest  = mmbr_req.dom_7interest
	mmbr.dom_8skill     = mmbr_req.dom_8skill
	mmbr.dom_8interest  = mmbr_req.dom_8interest
	
	mmbr.secret_key     = mmbr_req.secret_key
	
	dberror = None
	
	try: 
		db.add(mmbr)
		db.commit()
	except Exception as e:
		dberror = e
	# todo: catch sql integrity error: unique mail
	
	return {"status": "success/failed", "dberror": dberror}
コード例 #44
0
ファイル: main.py プロジェクト: salimab/macoders-forum
from models import Member, Post

member1 = Member("Ahmed", 20)
member2 = Member("Mahmoud", 32)

post1 = Post("Post1", "Content1")
post2 = Post("Post2", "Content2")
post3 = Post("Post3", "Content3")
コード例 #45
0
 async def clearpoints(self, ctx):
     Member.update(points=0).execute()
     await ctx.send("The leaderboard has been cleared")
コード例 #46
0
ファイル: main.py プロジェクト: rroussmolina/Family_Tree
def handle_all():

    return jsonify(Member.getAllMembers()), 200