当前位置: 首页>>代码示例>>Python>>正文


Python Group.get方法代码示例

本文整理汇总了Python中models.Group.get方法的典型用法代码示例。如果您正苦于以下问题:Python Group.get方法的具体用法?Python Group.get怎么用?Python Group.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Group的用法示例。


在下文中一共展示了Group.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
 def delete(self, key):
     if auth.user_is_admin():
         Group.get(key).delete()
     else:
         Messages.add('Only an administrator may delete groups. This ' +
                      'incident has been logged.')
     return self.redirect('/groups')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:9,代码来源:back.main.py

示例2: popup

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
    def popup(self, pos):
        row = self.selectionModel().selection().indexes()[0].row()
        if row < 1:
            return
        menu = QMenu()
        delaction = menu.addAction("Supprimer")
        action = menu.exec_(self.mapToGlobal(pos))

        if action == delaction:
            Group.get(Group.name == self.item(row).text()).delete_instance()
            self.refresh_()
开发者ID:fadiga,项目名称:waritchi,代码行数:13,代码来源:addressbook.py

示例3: show

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
 def show(self, key):
     if self.request.method == 'GET':
         return self.render('groups_show', { 'group': Group.get(key)})
     elif self.request.method == 'POST':
         self.update_group(key)
     else:
         return self.abort(405)  # all other methods not allowed
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:9,代码来源:back.main.py

示例4: groups_put

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
def groups_put(request):
	try:
		try:
			r = GetParams(request)
		except:# Exception as e:
			return JsonResponse(sys.exc_info()[0].__str__())
		
		if (not 'id' in r or not 'name' in r):
			return JsonResponse({}, 400)
		
		id = r['id']
		name = r['name']
		try:
			key = db.Key(id)
			group = Group.get(key)
			if (group.type() == 'user'):
				if ('email' in r):
					group.account = users.User(r['email'])
		except: # Exception as e:
			return JsonResponse(sys.exc_info()[0].__str__(), 404) 
		if 'calId' in r:
			group.calendarId = r['calId'].strip() if r['calId'].strip().__len__() > 0 else None
		group.name = name
		group.put()
		return JsonResponse({})
	except:# Exception as e:
		return JsonResponse(sys.exc_info()[0].__str__()) 
开发者ID:qwer,项目名称:schedule,代码行数:29,代码来源:views.py

示例5: addEvent

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
def addEvent(user, cs, name, where, when, who, repeat):
	calendars = []
	if who:
		try:
			key = db.Key(who)
			group = Group.get(key)
		except:
			return JsonResponse({}, 404)
		gg = group.getAllChildren()
		#gg.append(group)
		for g in gg:
			if g.calendarId and len(g.calendarId) > 0 and g.type != 'user':
				calendars.append(g.calendarId)
	#try:
	calendars.append(user.calendarId)
	#return JsonResponse(calendars)
	#event = InsertSingleEvent(calendarService,
	#		user.calendarId, name, '', where, when[0], when[1])
	cs2 = CS(cs)
	for cal in calendars:
		event = cs2.InsertSingleEvent(cal, name, '',
				where, when[0], when[1], reccurence(when, repeat), 
				{	'name': user.name if cal != user.calendarId else group.name, 
					'email': getSystemAccount().email 
				})
	#except Exception, err:
	#	return JsonResponse(cal + ' ' + err.__str__())
	
	return JsonResponse({ 'id': event.id.text })
开发者ID:qwer,项目名称:schedule,代码行数:31,代码来源:views.py

示例6: get_group

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
 def get_group(self, title):
     db.connect()
     try:
         g = Group.get(Group.title == title)
     except Group.DoesNotExist:
         g = Group.create(title = title)
     db.close()
     return g
开发者ID:matsufan,项目名称:bottle-fever,代码行数:10,代码来源:users.py

示例7: update_group

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
    def update_group(self, key):
        if not auth.logged_in():
            return self.redirect('/groups')
        
        user = auth.current_user()
        group = Group.get(key)
        if group.owner.user_id() != user.user_id() and not auth.user_is_admin():
            Messages.add('Only the owner of the group owner may modify it')
            return self.redirect('/groups')
        
        name = self.request.get('name')
        public = self.request.get('public') == 'public'
        abandon = self.request.get('abandon-project')
        sub_text = self.request.get('submission-text')
        sub_url = self.request.get('submission-url')
        remove_submission = self.request.get_all('remove-submission')
        remove = self.request.get_all('remove')
        owner = self.request.get('owner')
        delete = self.request.get('delete')
        
        if delete:
            group.delete()
            return self.redirect('/groups')
        
        group.name = name
        group.public = public
        
        if abandon:
            group.project = None
        
        if sub_text and sub_url:
            Submission(text=sub_text, url=sub_url, group=group).put()

        for sub in Submission.get(remove_submission):
            sub.delete()

        pending  = list(group.pending_users)
        for user in pending:
            approve = self.request.get("approve-%s" % user)
            if approve == "approve":
                group.members.append(user)
                group.pending_users.remove(user)
            elif approve == "refuse":
                group.pending_users.remove(user)
        
        group.owner = auth.user_from_email(owner)
        
        for user in remove:
            if auth.user_from_email(user) == group.owner:
                Messages.add('Cannot remove the group owner')
                return self.redirect('/groups/%s/edit' % key)
            else:
                group.members.remove(auth.user_from_email(user))
        
        group.put()
        return self.redirect('/groups/%s' % key)
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:58,代码来源:back.main.py

示例8: leave

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
 def leave(self, key):
     group = Group.get(key)
     user = auth.User(auth.current_user())
     
     if user.group != group:
         Messages.add('You cannot leave a group you are not in')
         return self.redirect('/groups/%s' % key)
     
     group.members.remove(user.gae_user)
     group.put()
     return self.redirect('/groups')
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:13,代码来源:back.main.py

示例9: edit

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
 def edit(self, key):
     if not auth.logged_in():
         return self.redirect('/groups')
     
     user = auth.current_user()
     group = Group.get(key)
     if group.owner.user_id() == user.user_id() or auth.user_is_admin():
         return self.render('groups_edit', { 'group': group })
     else:
         Messages.add('Only the owner of this group may edit it')
         return self.redirect('/groups/%s' % key)
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:13,代码来源:back.main.py

示例10: set_data_for

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
 def set_data_for(self, group_id=None, search=None):
     if isinstance(group_id, int):
         qs = ContactGroup.select().where(ContactGroup.group ==
                                          Group.get(Group.id == group_id))
         self.data = [("", contact_gp.contact.name, contact_gp.contact.number)
                      for contact_gp in qs]
     else:
         qs = Contact.select()
         if search:
             print(search)
             qs = qs.where(Contact.number.contains(search)
                           | Contact.name.contains(search))
             print(qs)
         self.data = [("", contact.name, contact.number) for contact in qs]
开发者ID:fadiga,项目名称:waritchi,代码行数:16,代码来源:addressbook.py

示例11: group

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
def group(group_name):
    group_answers = []
    for puzzle in Puzzle.select().order_by(Puzzle.name):
        puzzle_answers = (
            puzzle.answers.select()
            .join(Player).join(Group)
            .where(Group.name == group_name)
        )
        group_answers.append((puzzle.name, puzzle_answers))

    return render_template(
        'group.html',
        group=Group.get(Group.name == group_name),
        group_answers=group_answers)
开发者ID:ChickTech,项目名称:puzzle-hunt,代码行数:16,代码来源:flask_app.py

示例12: groups_newcal

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
def groups_newcal(request):
	if not 'id' in request.REQUEST:
		return JsonResponse({}, 400)
	id = request.REQUEST['id']
	try:
		key = db.Key(id)
		group = Group.get(key)
	except:
		return JsonResponse({}, 404)
	
	cs = getCalendarService(request)
	cal = createCalendar(cs, group.name)
	calendarId = cal.GetEventFeedLink()
	group.calendarId = calendarId
	group.put()
	return JsonResponse({ 'calId' : calendarId })
开发者ID:qwer,项目名称:schedule,代码行数:18,代码来源:views.py

示例13: join

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
 def join(self, key):
     group = Group.get(key)
     user = auth.User(auth.current_user())
     if user.in_group():
         Messages.add('You are already in a group')
         return self.redirect('/groups/%s' % key)
     if user.pending_join():
         Messages.add('You have already applied to join a group')
         return self.redirect('/groups/%s' % key)
     if group.public:
         group.members.append(auth.current_user())
         Messages.add('You have joined the group')
     else:
         group.pending_users.append(auth.current_user())
         Messages.add('You have requested to join the group')
     group.put()
     return self.redirect('/groups/%s' % key)
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:19,代码来源:back.main.py

示例14: addressbook_contactlist

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
def addressbook_contactlist(group_id):
    try:
        group_id = int(group_id)
    except:
        group_id = ALL_CONTACTS

    if group_id == ALL_CONTACTS:
        qs = ContactGroup.filter().group_by('contact')
        group_dict = {'id': -1, 'name': u"Tous"}
    else:
        qs = ContactGroup.filter(group__id=group_id)
        group_dict = Group.get(id=group_id).to_dict()

    data = {'contacts': [contact_group.contact.to_dict()
                         for contact_group in qs],
            'group': group_dict}
    return json.dumps(data)
开发者ID:yeleman,项目名称:zerin,代码行数:19,代码来源:addressbook.py

示例15: save_group

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get [as 别名]
def save_group(request, group_id):
    if request.method == 'POST':
        form = GroupForm(request.POST)
        if form.is_valid():

            try:
                group = Group.get(group_id)
            except:
                return HttpResponseRedirect('/webconf/couchauth/show_groups/')

            users = request.POST.getlist('users')
            group.update_users(users)
            if group.name != form.cleaned_data['name']:
                group.name = form.cleaned_data['name']
                group.save()


    return HttpResponseRedirect('/webconf/couchauth/show_groups/')
开发者ID:GaloC,项目名称:gplib,代码行数:20,代码来源:webconf.py


注:本文中的models.Group.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。