Exemple #1
0
 def __init__(self, group, request):
     self.group = group
     self.request = request
     self.schema = schemas.GroupSchema().bind(request=self.request)
     self.form = request.create_form(self.schema,
                                     buttons=(_('Save'), ),
                                     use_inline_editing=True)
Exemple #2
0
def create_form(request):
    """Render the form for creating a new group."""
    if not request.feature('groups'):
        raise exc.HTTPNotFound()

    schema = schemas.GroupSchema().bind(request=request)
    form = deform.Form(schema)

    return {'form': form, 'data': {}}
Exemple #3
0
def _group_form(request):
    schema = schemas.GroupSchema().bind(request=request)
    submit = deform.Button(title=_('Create a new group'),
                           css_class='primary-action-btn '
                                     'group-form__submit-btn '
                                     'js-create-group-create-btn')
    form = deform.Form(schema,
                       css_class='group-form__form',
                       buttons=(submit,))
    return form
Exemple #4
0
    def __init__(self, request):
        self.request = request

        if request.feature('activity_pages'):
            self.schema = schemas.GroupSchema().bind(request=self.request)
        else:
            self.schema = schemas.LegacyGroupSchema().bind(request=self.request)

        submit = deform.Button(title=_('Create a new group'),
                               css_class='primary-action-btn '
                                         'group-form__submit-btn '
                                         'js-create-group-create-btn')
        self.form = request.create_form(self.schema,
                                        css_class='group-form__form',
                                        buttons=(submit,))
Exemple #5
0
def create(request):
    """Respond to a submission of the create group form."""
    if not request.feature('groups'):
        raise exc.HTTPNotFound()

    form = deform.Form(schemas.GroupSchema().bind(request=request))
    try:
        appstruct = form.validate(request.POST.items())
    except deform.ValidationFailure:
        return {'form': form, 'data': request.params}

    user = accounts_models.User.get_by_userid(request.domain,
                                              request.authenticated_userid)
    group = models.Group(name=appstruct["name"], creator=user)
    request.db.add(group)

    # We need to flush the db session here so that group.id will be generated.
    request.db.flush()

    return exc.HTTPSeeOther(logic.url_for_group(request, group))