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


Python forms.GroupForm类代码示例

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


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

示例1: edit_group

def edit_group(grupo):
	# grupo = Grupo.objects.get_or_404(nombre=grupo)
	grupo = Grupo.objects.get_or_create(nombre=grupo,defaults={'horario': 'Sin definir'})
	grupo_id=grupo[0].id
	# if len(grupo[0].horario)<1:
	# 	grupo[0].horario = 'Sin definir'
	# user_json=usuario
	# uuu = [{'nombre':'nombre','username':'username'}]
	# post = Usuario.objects.get_or_404(username=username)
	form = GroupForm(request.form,grupo[0])
	if request.method == 'POST':
		if form.validate() == False:
			flash('Todos los campos son necesarios.')
			return render_template('usuarios/groups.html', form=form, data_type="Grupos", action="Editar")
		else:
			# flash('Valores por defecto.')
			g=Grupo.objects.get(id=grupo_id)
			g.update(set__nombre=form.nombre.data)
			g.update(set__horario=form.horario.data)
			# grupo[0].nombre=form.nombre.data
			# grupo[0].horario=form.horario.data
			# grupo[0].save()
			# return render_template('usuarios/groups.html', form=form, data_type="Grupos", action="Editar")
			grupos = Grupo.objects.all()
			return render_template ('usuarios/groups.html', grupos=grupos, action="Listar")
			# return render_template('grupos.html')
 
	elif request.method == 'GET':
		return render_template('usuarios/groups.html', form=form, data_type="Grupos", action="Editar")
开发者ID:miguelp77,项目名称:flaskDemo,代码行数:29,代码来源:manage.py

示例2: edit_group

def edit_group(request, id):
    group = get_object_or_404(Group, id=id)
    try:
        group_title = models.GroupTitle.objects.get(group=group)
    except models.GroupTitle.DoesNotExist:
        group_title = None

    if request.method == 'POST':
        form = GroupForm(request.POST, instance=group)
        group_title_form = GroupTitleForm(request.POST, prefix='gtf', instance=group_title)
        if form.is_valid() and group_title_form.is_valid():
            group = form.save(commit=False)

            if form.cleaned_data['permissions']:
                group.permissions = form.cleaned_data['permissions']
            else:
                group.permissions.clear()

            group.save()

            if not group_title:
                group_title = group_title_form.save(commit=False)
                group_title.group = group
                group_title.save()
            else:
                group_title_form.save()
            return redirect('accounts:administration:groups_list')
    else:
        form = GroupForm(instance=group)
        group_title_form = GroupTitleForm(prefix='gtf', instance=group_title)
    return render(request, 'accounts/administration/edit_group.html', {
        'form': form,
        'group_title_form': group_title_form
    })
开发者ID:VBelozyorov,项目名称:libcms,代码行数:34,代码来源:views.py

示例3: addGroup

def addGroup():

  if 'email' not in session:
    return redirect(url_for('signin'))

  user = Smarketer.query.filter_by(username = session['email']).first()

  if user is None:
    return redirect(url_for('signin'))
  else:
    form = GroupForm()

    if request.method == 'POST':
      if form.validate() == False:
        return render_template('addGroup.html', form=form)
      else:
	totalTitle = form.groupTitle.data + " - " + form.groupID.data
        newGroup = Group(form.groupID.data, totalTitle)
        db.session.add(newGroup)
        db.session.commit()

	form.groupID.data = ""
	form.groupTitle.data = ""
        return render_template('addGroup.html', form=form, success=True)

    elif request.method == 'GET':
      return render_template('addGroup.html', form=form)
开发者ID:shotput,项目名称:linkedin-sales-tool,代码行数:27,代码来源:routes.py

示例4: new_group

def new_group(request):
    if request.method == 'POST':
        form = GroupForm(request.POST)
        if form.is_valid():
            group_code = helper.post_request("https://a6.cfapps.io/groups", {})
            groupID = json.loads(group_code)['groupId']
            group = Group.objects.create(code=groupID, name=form.cleaned_data['name'])
            group.save()
            #Create a new subscription for group
            url = "https://a6.cfapps.io/subscriptions"
            payload = {}
            payload['groupId'] = group.code
            payload['insights'] = [
                "home.window.open",
                "home.window.closed",
                "home.garage.open",
                "home.garage.closed",
                "home.smoke.alarm_on",
                "home.smoke.alarm_off",
                "home.smoke.alarm_battery_low",
                "home.fire.alarm_on",
                "home.fire.alarm_off",
                "home.water.sensor.alarm_on",
                "home.water.sensor.alarm_off",
                "vehicle.trip.arrived",
                "vehicle.health.arrived"]
            payload['webhookUrl'] = 'https://homesensing.cfapps.io/callback'
            result = helper.post_request(url, payload)
            print result
            return HttpResponseRedirect("/index")
    else:
        form = GroupForm()
    return render_to_response('new_group.html', { 'form' : form }, context_instance=RequestContext(request))
开发者ID:sameetandpotatoes,项目名称:Homesense,代码行数:33,代码来源:views.py

示例5: group_create

def group_create(request):
    """
    create a form a user can use to create a custom group, on POST save this group to the database
    and automatically add the creator to the said group as a manager.
    """
    nav_selected = "communities"
    if request.method == "POST":
        form = GroupForm(request.POST, request.FILES)
        if form.is_valid():
            group = form.save()
            GroupUsers.objects.create(group=group, user=request.user, is_manager=True)
            Stream.objects.get(slug="community-create").enqueue(content_object=group, start=group.created)
            Record.objects.create_record(request.user, 'group_create', group)
            badge_cache.possibly_award_badge('created_a_community', user=request.user)
            messages.success(request, _("%(group)s has been created.") % {
                    'group': group})
            return redirect("group_detail", group_slug=group.slug)
    else:
        form = GroupForm()
    return render_to_response("groups/group_create.html", {
        "form": form,
        "site": Site.objects.get_current(),
        "nav_selected": nav_selected,
        'external_group': False,
    }, context_instance=RequestContext(request))
开发者ID:ejucovy,项目名称:localpower,代码行数:25,代码来源:views.py

示例6: groups

def groups(group_id=None):
    form = GroupForm(request.form)
    if request.method == 'POST':
        if not form.validate():
            pass
        else:
            pass
    return render_template('groups.html', user=get_user(), form=form)
开发者ID:rontom,项目名称:l0flask,代码行数:8,代码来源:views.py

示例7: 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

示例8: create_group

def create_group(request):
    if request.method == 'POST':
        form = GroupForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('accounts:administration:groups_list')
    else:
        form = GroupForm()
    return render(request, 'accounts/administration/create_group.html', {
        'form': form
    })
开发者ID:isergey,项目名称:liart_portal,代码行数:11,代码来源:views.py

示例9: 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.save()

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

示例10: save_group

def save_group(request, group_id):
    try:
        group = Group.objects.get(id=group_id)
    except Group.DoesNotExist:
        return HttpResponseRedirect('/webconf/aclsmanager/show_groups/')

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

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

示例11: add_group

def add_group(request):
    
    if request.method == 'POST':
        groupForm = GroupForm(request.POST)
        if groupForm.is_valid():
            group = groupForm.save()
            request.user.message_set.create(message=_('Group created'))
            return redirect('picket-admin-users')
    else:
        groupForm = GroupForm()
    
    return direct_to_template(request, 'picket/admin/group_add.html',
        {'group_form': groupForm,})
开发者ID:lig,项目名称:picket_classic,代码行数:13,代码来源:views.py

示例12: groups

def groups():
    form = GroupForm()
    if form.validate_on_submit():
        group_id = form.id.data
        if group_id:
            group = models.Group.query.get(group_id)
            group.name = form.name.data
        else:
            group = models.Group(name=form.name.data)
            db.session.add(group)
        db.session.commit()
        flash('The group was successffully saved.', 'success')
        return redirect(url_for('groups'))
    groups = models.Group.query.all()
    return render_template('groups.html', form=form, groups=groups)
开发者ID:dirtycoder,项目名称:benicio,代码行数:15,代码来源:views.py

示例13: add_group

def add_group(request):
    context = {}

    if request.method == "POST":
        form = GroupForm(request.POST)
        if form.is_valid():
            group = form.save(commit=False)
            group.added_by = request.user
            group.save()
            return HttpResponseRedirect("/group/%s" % group.id)
    else:
        form = GroupForm()

    context["form"] = form
    return r2r(request, "add_group", context)
开发者ID:Veterun,项目名称:questions,代码行数:15,代码来源:views.py

示例14: edit_group

def edit_group(request, groupId):
    
    group = get_object_or_404(Group, id=groupId)
    
    if request.method == 'POST':
        groupForm = GroupForm(request.POST, instance=group)
        if groupForm.is_valid():
            group = groupForm.save()
            request.user.message_set.create(message=_('Group updated'))
            return redirect('picket-admin-users')
    else:
        groupForm = GroupForm(instance=group)
    
    return direct_to_template(request, 'picket/admin/group_edit.html',
        {'group_form': groupForm,})
开发者ID:lig,项目名称:picket_classic,代码行数:15,代码来源:views.py

示例15: group_add

def group_add(request):
    temp_name = "cmdb/cmdb-header.html"
    if request.method == "POST":
        group_form = GroupForm(request.POST)
        if group_form.is_valid():
            group_form.save()
            tips = u"增加成功!"
            display_control = ""
        else:
            tips = u"增加失败!"
            display_control = ""
        return render(request, "cmdb/group_base.html", locals())
    else:
        display_control = "none"
        group_form = GroupForm()
        return render(request, "cmdb/group_base.html", locals())
开发者ID:ccc520,项目名称:adminset,代码行数:16,代码来源:group.py


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