• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Group类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createGroup

def createGroup(request):
	'''
		USAGE:
			create a civi Group responsible for creating and managing civi content.
			Please validate file uploads as valid images on the frontend.

		File Uploads:
			profile (optional)
			cover (optional)

		Text POST:
			title
			description

		:returns: (200, ok, group_id) (500, error)
	'''
	pi = request.FILES.get('profile', False)
	ci = request.FILES.get('cover', False)
	title = request.POST.get(title, '')
	data = {
		"owner": Account.objects.get(user=request.user),
		"title": title,
		"description": request.POST.get('description',''),
		"profile_image": writeImage('profile', pi, title),
		"cover_image": writeImage('cover', ci, title)
	}

	try:
		group = Group(**data)
		group.save()
		account.groups.add(group)
		return JsonResponse({'result':group.id})
	except Exception as e:
		return HttpResponseServerError(reason=e)
开发者ID:CiviWikiorg,项目名称:civiwiki.org,代码行数:34,代码来源:views_write.py


示例2: populate_with_defaults

def populate_with_defaults():
    '''Create user admin and grant him all permission

    If the admin user already exists the function will simply return
    '''
    logging.getLogger(__name__).debug("Populating with default users")
    if not User.select().where(User.name == 'admin').exists():
        admin = User.create(name='admin', password='admin')
        admins = Group.create(name='admins')
        starCap = Capability.create(domain='.+',
                                    action=(Action.CREATE |
                                            Action.READ |
                                            Action.UPDATE |
                                            Action.DELETE))
        admins.capabilities.add(starCap)
        admin.groups.add(admins)
        admin.save()
    if not User.select().where(User.name == 'anonymous').exists():
        anon = User.create(name='anonymous', password='')
        anons = Group.create(name='anonymous')
        readCap = Capability.create(domain=Capability.simToReg('/volumes/*'),
                                    action=Action.READ)
        anons.capabilities.add(readCap)
        anon.groups.add(anons)
        anon.save()
开发者ID:insomnia-lab,项目名称:libreant,代码行数:25,代码来源:__init__.py


示例3: search

def search():
    if request.method == 'POST':
        if g.search_form.validate_on_submit():
            n = unicode(g.search_form.select.data)
            text = unicode(g.search_form.text.data)
            if n == 'group':
                if text.isdigit():
                    return render_template('search_result.html', type=n,
                                           data=Group.get_group_by_number_like(int(text)),
                                           count=Specialty.count() + 1)
                elif text.isalpha():
                    return render_template('search_result.html', type=n, data=Group.get_by_specialty_like(text),
                                           count=Specialty.count() + 1)
                else:
                    if text.find(' ') != -1:
                        arr = text.split(' ')
                        if arr[0].isdigit():
                            return render_template('search_result.html', type=n,
                                                   data=Group.get_by_number_and_specialty(arr[0], arr[1]),
                                                   count=Specialty.count() + 1)
                        else:
                            return render_template('search_result.html', type=n,
                                                   data=Group.get_by_number_and_specialty(arr[1], arr[0]),
                                                   count=Specialty.count() + 1)
            elif n == 'lecturer':
                if text.isalpha():
                    return render_template('search_result.html', type=n, data=Lecturer.get_by_name(text))
            elif n == 'subject':
                if text.isalnum():
                    return render_template('search_result.html', type=n, data=Subject.get_by_substring(text), text=text)
            return redirect(url_for('index'))
        return redirect(url_for('group_timetable', group_number=427, week=get_week()))
开发者ID:stepanov-valentin,项目名称:TimeTable,代码行数:32,代码来源:views.py


示例4: group_edit_view

def group_edit_view(request):
    """returns current group information for editing and then collects
    all information that has been added by the user whether new or existing
    and edits the existing entries.
    """
    username = request.authenticated_userid
    group = Group.lookup_by_attribute(name=request.matchdict['group_name'])[0]
    criteria = Criteria.lookup_by_attribute(group=group)[0]
    if request.method == 'POST':
        criteria = Criteria.edit(location=request.params.getall('location'),
                                 taste=request.params.getall('taste'),
                                 diet=request.params.getall('diet'),
                                 cost=request.params.getall('cost'),
                                 age=request.params.getall('age'),
                                 id=criteria.id)
        group = Group.edit(name=request.params.get('name'),
                           description=request.params.get('description'),
                           id=group.id)
        return HTTPFound(request.route_url('group_detail',
                                           group_name=group.name))

    profile = {}
    profile['criteria'] = criteria
    profile['group'] = group
    profile['username'] = username

    return profile
开发者ID:kaka0525,项目名称:taste-buddies,代码行数:27,代码来源:views.py


示例5: test_parse_group

    def test_parse_group(self):

        response = '''
            {"response":[{"gid":1,"name":"ВКонтакте API","screen_name":"apiclub","is_closed":0,
                "is_admin":1,"type":"group","photo":"http://cs400.vkontakte.ru/g00001/e_5ba03323.jpg",
                "photo_medium":"http://cs400.vkontakte.ru/g00001/d_7bfe2183.jpg",
                "photo_big":"http://cs400.vkontakte.ru/g00001/a_9a5cd502.jpg"},
                {"gid":45,"name":"›››› ФМЛ 239 ››››","screen_name":"fml239","is_closed":1,"is_admin":0,"type":"group",
                "photo":"http://cs39.vkontakte.ru/g00045/c_5a38eec.jpg",
                "photo_medium":"http://cs39.vkontakte.ru/g00045/b_5a38eec.jpg",
                "photo_big":"http://cs39.vkontakte.ru/g00045/a_5a38eec.jpg"}]}
            '''
        instance = Group()
        instance.parse(json.loads(response)['response'][0])
        instance.save()

        self.assertEqual(instance.remote_id, 1)
        self.assertEqual(instance.name, u'ВКонтакте API')
        self.assertEqual(instance.screen_name, 'apiclub')
        self.assertEqual(instance.is_closed, False)
        self.assertEqual(instance.is_admin, True)
        self.assertEqual(instance.type, 'group')
        self.assertEqual(instance.photo, 'http://cs400.vkontakte.ru/g00001/e_5ba03323.jpg')
        self.assertEqual(instance.photo_medium, 'http://cs400.vkontakte.ru/g00001/d_7bfe2183.jpg')
        self.assertEqual(instance.photo_big, 'http://cs400.vkontakte.ru/g00001/a_9a5cd502.jpg')
开发者ID:wd5,项目名称:1-django-vkontakte-groups,代码行数:25,代码来源:tests.py


示例6: delete

 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,代码行数:7,代码来源:back.main.py


示例7: addressbook_add_group

def addressbook_add_group():

    group_name = request.form.get('group_name', None)

    data = {}
    subst = {'group': group_name}

    if not group_name:
        dict_return(data, WARNING, u"Veuillez saisir un nom de groupe",
                    message_html=u"Veuillez saisir un nom de"
                                 u"<strong> groupe</strong>.")

        return json.dumps(data)

    try:
        group = Group(name=group_name)
        group.save()
        dict_return(data, SUCCESS,
                    u"%(group)s a été ajouté avec succès." % subst,
                    message_html=u"<strong>%(group)s</strong> "
                                 u"a été ajouté avec succès." % subst)
    except sqlite3.IntegrityError:
        dict_return(data, INFO,
                    u"%(group)s existe déjà." % subst,
                    message_html=u"<strong>%(group)s</strong> existe déjà."
                                 % subst)
    except Exception as e:
        subst.update({'err': e.message})
        dict_return(data, ERROR,
                    u"Impossible d'enregistrer le groupe %(group)s : %(err)r" % subst,
                    message_html=u"Impossible d'enregistrer le groupe "
                                 u"<strong>%(group)s</strong><br />"
                                 u"<em>%(err)r</em>" % subst)

    return json.dumps(data)
开发者ID:yeleman,项目名称:zerin,代码行数:35,代码来源:addressbook.py


示例8: store_seller_post

def store_seller_post(store_id):
    """
    store 添加商店人员

    """
    db = g._imdb
    developer_id = session['user']['id']

    form = request.form
    name = form.get('name', '')
    password = form.get('password', '')
    number = form.get('number', '')
    if not name or not password or not store_id:
        return INVALID_PARAM()
        
    if not number:
        number = None
    password = md5.new(password).hexdigest()

    group_id = Store.get_store_gid(db, store_id)

    db.begin()
    seller_id = Seller.add_seller(db, name, password, store_id, group_id, number)
    Group.add_group_member(db, group_id, seller_id)
    db.commit()

    content = "%d,%d"%(group_id, seller_id)
    publish_message(g.im_rds, "group_member_add", content)
    
    return redirect(url_for('.store_seller', store_id=store_id))
开发者ID:richmonkey,项目名称:xiaowei_web,代码行数:30,代码来源:store.py


示例9: admin_group

def admin_group():
    form = GroupForm()
    form.group_specialty.choices = [(h.id, h.long_form) for h in Specialty.get_all()]
    if form.validate_on_submit():
        Group.add(form.group_number.data, form.group_course.data, form.group_specialty.data)
        flash(u'Спеціальність успішно додано')
        return redirect_back('admin_group')
    return render_template('admin_group.html', data=Group.get_all(), form=form)
开发者ID:stepanov-valentin,项目名称:TimeTable,代码行数:8,代码来源:views.py


示例10: get_group

 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,代码行数:8,代码来源:users.py


示例11: group

def group(request):
    dbsession = DBSession()
    name = clean_matchdict_value(request, 'group')
    group = Group()
    group.name = name
    group.timestamp = get_timestamp()
    dbsession.add(group)
    transaction.commit()
    return {'status': 'success'}
开发者ID:vishakh,项目名称:metamkt,代码行数:9,代码来源:views.py


示例12: group

def group(name):
    """
    New or existing group
    """
    try:
        group = Group.objects.get(name__exact=name)
    except:
        group = Group(name=name)
        group.save()
    return group
开发者ID:FOSSRIT,项目名称:RITRemixerator,代码行数:10,代码来源:helper.py


示例13: insert

    def insert(self, group_name):
        existing_group = self._get_group(group_name=group_name)
        if existing_group:
            return existing_group

        group = Group()
        group.user = self.user_key
        group.name = group_name
        group.put()
        return group
开发者ID:xplot,项目名称:imeet,代码行数:10,代码来源:group.py


示例14: upload_opml_file

def upload_opml_file(request):
    if request.method == 'POST':
        form = UploadOpmlFileForm(request.POST, request.FILES)
        if form.is_valid():
        	#opml_file = request.FILES['file'].read()
        	#tree = ET.parse(opml_file)
        	#root = tree.getroot()
        	#for outline in root.iter('outline'):
			#	source = Source(user=request.user, xml_url=outline.get('xmlUrl'))
			#	source.save()

			Source.objects.all().delete()
			Group.objects.all().delete()

			group = None
			for event, elem in ET.iterparse(request.FILES['file']):
				#import pdb; pdb.set_trace()
				if elem.tag == 'body':
					outlines = list(elem)

					for outline in outlines:
						if 'xmlUrl' not in outline.attrib:
							group = Group(user=request.user, name=outline.attrib['title']) 
							group.save()

							children = list(outline)
							for child in children:
								source = Source()
								source.text = child.attrib['text']
								source.title = child.attrib['title']
								source.feed_type = child.attrib['type'] 
								source.xml_url = child.attrib['xmlUrl']
								source.html_url = child.attrib['htmlUrl']
								source.save()

								user_source = UserSource(user=request.user, source=source, group=group)
								user_source.save()		
						elif 'xmlUrl' in outline.attrib:
							print outline.attrib
							source = Source()
							source.text = outline.attrib['text']
							source.title = outline.attrib['title']
							source.feed_type = outline.attrib['type'] 
							source.xml_url = outline.attrib['xmlUrl']
							source.html_url = outline.attrib['htmlUrl']
							source.save()	

							user_source = UserSource(user=request.user, source=source)
							user_source.save()		

			return HttpResponseRedirect( reverse('entries') )
    else:
        form = UploadOpmlFileForm()

    return render_to_response('feeds/upload_opml.html', {'form': form}, context_instance=RequestContext(request)) 
开发者ID:juliangay,项目名称:ticker-tape,代码行数:55,代码来源:views.py


示例15: test_session_to_group

    def test_session_to_group(self):
        m = Mentor(name='Snoke')

        g1 = Group(name='Solo')
        g2 = Group(name='Generals')

        s1 = Student(name='Ray')
        s2 = Student(name='Kylo')
        s3 = Student(name='Hux')


        db.session.add(m)
        db.session.add(g1)
        db.session.add(g2)
        db.session.add(s1)
        db.session.add(s2)
        db.session.add(s3)
        db.session.commit()

        sesh1 = Session()
        g1.add_session(sesh1)
        db.session.add(sesh1)
        db.session.commit()

        g1.add_student(s1)
        g1.add_student(s2)
        g2.add_student(s3)

        assert g1.has_session(sesh1)
        assert sesh1.group_id == g1.id
开发者ID:morganrconnolly,项目名称:billingPlatform,代码行数:30,代码来源:tests.py


示例16: _addStickTopic

 def _addStickTopic(self, webPage):
     """ 访问小组首页,添加置顶贴
     """
     #pdb.set_trace()
     
     group = Group(self.group_id)
     group.parse(webPage)
     
     self.group_info = group
     
     self.save_thread.putTask(self._saveGroupHandler, group)
开发者ID:hitalex,项目名称:douban-group-crawler,代码行数:11,代码来源:topic_crawler.py


示例17: test_model_User_profile_change_default_group

 def test_model_User_profile_change_default_group(self):
     username = "testusername"
     user = DjangoUser(username=username)
     user.save()
     profile = user.profile
     group = Group(name='testgroupname')
     group.save()
     profile.default_group = group
     profile.save()
     profile = User.objects.get(user=user)
     self.assertEquals(profile.default_group, group)
开发者ID:tovmeod,项目名称:anaf,代码行数:11,代码来源:tests.py


示例18: popup

    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,代码行数:11,代码来源:addressbook.py


示例19: save_new_group

def save_new_group(request):

    if request.method == 'POST':
        form = GroupForm(request.POST)
        if form.is_valid():
            group = Group()
            group.name = form.cleaned_data['name']
            group.max_loan_days = form.cleaned_data['max_loan_days']
            group.save()

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


示例20: group

def group(request, id):
    c = {}
    group_info = get_group(request.session['token'], id)
    c['group_info'] = group_info
    c['member_map'] = {member[u'user_id']: member[u'nickname'] for member in group_info[u'members']}
    request.session['member_map'] = c['member_map']

    if cache.get('group-%s' % id) and settings.CACHE_ENABLED:
        c['group'] = cache.get('group-%s' % id)
        return render(request, 'group.html', c)
    if request.GET.get('ajaxLoad', '0') == '0' and settings.CACHE_ENABLED:
        return render(request, 'group-loader.html', c)
    get_attachment = lambda x: x[0].get('url', None) if len(x) else None
    try:
        group = Group.objects.get(id=id)
        msgs = list(Message.objects.filter(group=group).order_by('created'))
        if msgs:
            after_id = msgs[-1].id
            if not str(after_id).isdigit():
                after_id = 0
            elif str(after_id) != str(group_info[u'messages'][u'last_message_id']):
                msgs += [Message(
                        id=msg[u'id'],
                        created=datetime.fromtimestamp(float(msg[u'created_at'])),
                        author=msg[u'user_id'] if msg[u'user_id'] != 'system' else 0,
                        text=msg[u'text'],
                        img=get_attachment(msg[u'attachments']),
                        likes=msg[u'favorited_by'],
                        n_likes=len(msg[u'favorited_by'])
                        ) for msg in msg_concurrent(request.session['token'], id, after_id=after_id, n_workers=(int(group_info[u'messages'][u'count'])/10 + 1))]
        group.analysis = analysis(request, msgs, group_info)

    except Group.DoesNotExist:
        msgs = [Message(
                id=msg[u'id'],
                created=datetime.fromtimestamp(float(msg[u'created_at'])),
                author=msg[u'user_id'] if msg[u'user_id'] != 'system' else 0,
                text=msg[u'text'],
                img=get_attachment(msg[u'attachments']),
                likes=msg[u'favorited_by'],
                n_likes=len(msg[u'favorited_by'])
                ) for msg in msg_concurrent(request.session['token'], id, n_workers=(int(group_info[u'messages'][u'count'])/10 + 1))]

        group = Group(id=id, analysis=analysis(request, msgs, group_info))
        def save_msg(m):
            m.group = group
            m.save()
        map(lambda m: save_msg(m), msgs)
    if settings.CACHE_ENABLED:
        cache.set('group-%s' % id, group, 180)
    group.save()
    c['group'] = group
    return render(request, 'group.html', c)
开发者ID:pmcgannon22,项目名称:gma-ui,代码行数:53,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.HDLog类代码示例发布时间:2022-05-27
下一篇:
Python models.Game类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap