Example #1
0
def edit(request):
    """ edit(request)
        no return value, called with route_url('apex_edit', request)

        This function will only work if you have set apex.auth_profile.

        This is a very simple edit function it works off your auth_profile
        class, all columns inside your auth_profile class will be rendered.
    """
    title = _('Edit')

    ProfileForm = model_form(
        model=get_module(apex_settings('auth_profile')),
        base_class=ExtendedForm,
        exclude=('id', 'user_id'),
    )

    record = AuthUser.get_profile(request)
    form = ProfileForm(obj=record)
    if request.method == 'POST' and form.validate():
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        flash(_('Profile Updated'))
        return HTTPFound(location=request.url)

    return {'title': title, 'form': form, 'action': 'edit'}
Example #2
0
def profile_edit(request):
    form = ProfileRecordForm(request.POST)
    if 'record_id' in request.matchdict:
        record = get_profile_record(request.matchdict['id'], \
            request.matchdict['record_id'])
        if not request.POST:
            form.record_type.data = record.record_type
            form.name.data = record.name
            form.contents.data = record.contents
    else:
        record = Profile_Record(profile_id=request.matchdict['id'])

    if request.method == 'POST' and form.validate():
        if request.POST['record_type'] in ['TXT', 'SPF']:
            request.POST['contents'] = '"' + request.POST['contents'] \
                .replace('"','') + '"'
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_profile_edit', request, \
            id=request.matchdict['id']))
    return {'title':'Edit Profile Records', \
        'form':form, \
        'profile':get_profile(request.matchdict['id']), \
        'profile_records':get_profile_records(request.matchdict['id'])}
Example #3
0
def edit(request):
    """ edit(request)
        no return value, called with route_url('apex_edit', request)

        This function will only work if you have set apex.auth_profile.

        This is a very simple edit function it works off your auth_profile
        class, all columns inside your auth_profile class will be rendered.
    """
    title = _('Edit')

    ProfileForm = model_form(
        model=get_module(apex_settings('auth_profile')),
        base_class=ExtendedForm,
        exclude=('id', 'user_id'),
    )

    record = AuthUser.get_profile(request)
    form = ProfileForm(obj=record)
    if request.method == 'POST' and form.validate():
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        flash(_('Profile Updated'))
        return HTTPFound(location=request.url)

    return {'title': title, 'form': form, 'action': 'edit'}
Example #4
0
def profile_edit(request):
    form = ProfileRecordForm(request.POST)
    if 'record_id' in request.matchdict:
        record = get_profile_record(request.matchdict['id'], \
            request.matchdict['record_id'])
        if not request.POST:
            form.record_type.data = record.record_type
            form.name.data = record.name
            form.contents.data = record.contents
    else:
        record = Profile_Record(profile_id=request.matchdict['id'])

    if request.method == 'POST' and form.validate():
        if request.POST['record_type'] in ['TXT', 'SPF']:
            request.POST['contents'] = '"' + request.POST['contents'] \
                .replace('"','') + '"'
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_profile_edit', request, \
            id=request.matchdict['id']))
    return {'title':'Edit Profile Records', \
        'form':form, \
        'profile':get_profile(request.matchdict['id']), \
        'profile_records':get_profile_records(request.matchdict['id'])}
Example #5
0
File: form.py Project: Qwait/apex
    def save(self, session, model, commit=True):
        record = model()
        record = merge_session_with_post(record, self.data.items())
        if commit:
            session.add(record)
            session.flush()

        return record
Example #6
0
    def save(self, session, model, commit=True):
        record = model()
        record = merge_session_with_post(record, self.data.items())
        if commit:
            session.add(record)
            session.flush()

        return record
Example #7
0
def profiles(request):
    form = ProfileForm(request.POST)
    if request.method == 'POST' and form.validate():
        record = Profile()
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_profiles', request))
    return {'title':'Profiles', 'form':form, 'profiles':get_profiles()}
Example #8
0
def profiles(request):
    form = ProfileForm(request.POST)
    if request.method == 'POST' and form.validate():
        record = Profile()
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_profiles', request))
    return {'title': 'Profiles', 'form': form, 'profiles': get_profiles()}
Example #9
0
def webhosts(request):
    form = ProviderForm(request.POST)
    providers = DBSession.query(Provider).order_by(Provider.name).all()
    record = Provider()

    if request.method == 'POST' and form.validate():
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_webhosts', request))
    return {'title':'Web Hosts', 'form':form, 'providers':providers}
Example #10
0
def registrars(request):
    form = RegistrarForm(request.POST)
    registrars = get_registrars()
    record = Registrar()

    if request.method == 'POST' and form.validate():
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_registrars', request))
    return {'title':'Registrars', 'form':form, 'registrars':registrars}
Example #11
0
def webhosts(request):
    form = ProviderForm(request.POST)
    providers = DBSession.query(Provider).order_by(Provider.name).all()
    record = Provider()

    if request.method == 'POST' and form.validate():
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_webhosts', request))
    return {'title': 'Web Hosts', 'form': form, 'providers': providers}
Example #12
0
def registrars(request):
    form = RegistrarForm(request.POST)
    registrars = get_registrars()
    record = Registrar()

    if request.method == 'POST' and form.validate():
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_registrars', request))
    return {'title': 'Registrars', 'form': form, 'registrars': registrars}
Example #13
0
def ips(request):
    providers = get_providers()
    ips = get_ips()
    if not providers:
        flash('You have no providers defined, please add at least one')
        return HTTPFound(location=route_url('apex_route53_webhosts', request))
    form = IPForm(request.POST, providers=providers)
    form.provider_id.choices = providers
    record = IP()

    if request.method == 'POST' and form.validate():
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_ips', request))
    return {'title':'IP Addresses', 'form':form, 'ips':ips}
Example #14
0
def ips(request):
    providers = get_providers()
    ips = get_ips()
    if not providers:
        flash('You have no providers defined, please add at least one')
        return HTTPFound(location=route_url('apex_route53_webhosts', request))
    form = IPForm(request.POST, providers=providers)
    form.provider_id.choices = providers
    record = IP()

    if request.method == 'POST' and form.validate():
        record = merge_session_with_post(record, request.POST.items())
        DBSession.merge(record)
        DBSession.flush()
        return HTTPFound(location= \
            route_url('apex_route53_ips', request))
    return {'title': 'IP Addresses', 'form': form, 'ips': ips}
Example #15
0
def profile(request):
    record = DBSession.query(Shelter).filter(Shelter.auth_id==request.user.id).first()
    if record is None:
      record = Shelter(auth_id=request.user.id)

    form = ProfileForm(request.POST, obj=record)

    if request.method == 'POST' and form.validate():
        record = merge_session_with_post(record, request.POST.items())
        record.auth_id = request.user.id
        if record.id:
            DBSession.merge(record)
        else:
            DBSession.add(record)
        DBSession.flush()
        #raise HTTPFound(location=request.route_url('index'))
        raise HTTPFound(location=request.route_url('profile'))
    return {'form': form}