Giter Club home page Giter Club logo

c2cgeoform's Introduction

c2cgeoform

c2cgeoform is a framework easing the creation of web pages with forms. Users of c2cgeoform declaratively create models, from which the framework can create forms, views, lists, ...

c2cgeoform supports various data types, including geometry types (points, lines, polygons). For geometry types c2geoform generates maps with editing tools to create, modify or delete geometries.

c2cgeoform is based on Pylons technologies. More specifically, it uses Pyramid, Colander, and Deform. For interacting with the database it uses SQLAlchemy and GeoAlchemy 2.

Documentation: https://c2cgeoform.readthedocs.io/en/latest/

Demo: https://geomapfish-demo.camptocamp.com/c2cgeoform

Copyright

c2cgeoform makes use of the icons by GLYPHICONS. Make sure to comply with the usage terms when utilizing c2cgeoform.

Contributing

Install the pre-commit hooks:

pip install pre-commit
pre-commit install --allow-missing-config

c2cgeoform's People

Contributors

arnaud-morvan avatar cmangeat avatar elemoine avatar fredj avatar fvanderbiest avatar julsbreakdown avatar jwkaltz avatar kalbermattenm avatar renovate[bot] avatar sbrunner avatar tonio avatar yjacolin avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

c2cgeoform's Issues

The "form" view does too much

The current form view handles many types of requests:

  • it displays the initial form,
  • it inserts the form data in the database (after confirmation)
  • it just validates the form data when the user goes from one step to another
  • it stores the form data in the session after submission but before confirmation

The code is complex, and inflexible. For example we want to support the following use-cases:

  • it should be possible to create forms without multi-step
  • it should be possible to create forms without the confirmation page (a.k.a. "two-step submission")
  • it should be possible to redirect to a custom read-only view after submission

This requires somehow untangling that view, and split it into multiple functions/views.

broken make serve in template app

.build/venv/bin/pserve --reload development.ini
Starting monitor for PID 12087.
2017-11-03 13:10:21,609 INFO  [shapely.speedups._speedups][MainThread] Numpy was not imported, continuing without requires()
Traceback (most recent call last):
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/config/__init__.py", line 1212, in execute_actions
    callable(*args, **kw)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/config/assets.py", line 381, in register
    __import__(package)
ImportError: No module named 'c2cgeoform_demo'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/hupper/ipc.py", line 322, in spawn_main
    func(**kwargs)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/hupper/worker.py", line 237, in worker_main
    func(*spec_args, **spec_kwargs)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/scripts/pserve.py", line 32, in main
    return command.run()
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/scripts/pserve.py", line 229, in run
    app = loader.get_wsgi_app(app_name, config_vars)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/plaster_pastedeploy/__init__.py", line 131, in get_wsgi_app
    global_conf=defaults)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/home/fvanderbiest/workspace/MyGeoformProject/mygeoformproject/__init__.py", line 31, in main
    return config.make_wsgi_app()
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/config/__init__.py", line 1052, in make_wsgi_app
    self.commit()
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/config/__init__.py", line 684, in commit
    self.action_state.execute_actions(introspector=self.introspector)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/config/__init__.py", line 1218, in execute_actions
    tb)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/compat.py", line 147, in reraise
    raise value.with_traceback(tb)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/config/__init__.py", line 1212, in execute_actions
    callable(*args, **kw)
  File "/home/fvanderbiest/workspace/MyGeoformProject/.build/venv/lib/python3.5/site-packages/pyramid/config/assets.py", line 381, in register
    __import__(package)
pyramid.exceptions.ConfigurationExecutionError: <class 'ImportError'>: No module named 'c2cgeoform_demo'
  in:
  Line 16 of file /home/fvanderbiest/workspace/MyGeoformProject/mygeoformproject/routes.py:
    'node_modules'))

Database migration

At some point we'll need to handle database migrations. We'll use Alembic for that.

Geometry type support

  • Support projections: database vs. map projection
  • Deform map: draw and modify controls
  • Support for read-only

Hide/display role-specific fields in the form page

That use-case: users of a given role do not need to see fields that are specific to other roles. We think this can be implemented by the application administrator in the form template. Per-role classes can be used in the HTML. And a select element displaying and hiding fields based on the selected role.

This should be implemented in the pully example.

Map in a sub-form

Test if a map can be used in a sub-form (e.g. in a relation). Maybe the map will not be initialized properly if a new entity is added in the form (with "Add Contact" for example).

Use ColanderAlchemy 0.3.2

#89 required a change to ColanderAlchemy. That change is merged into ColanderAlchemy's master branch, but there's no new release yet. When ColanderAlchemy 0.3.2 is released we need to use ColanderAlchemy >= 0.3.2 in setup.py.

initializedb fails

The initializedb command fails for me on my development environment:

sqlalchemy.exc.ProgrammingError: (ProgrammingError) column "locationposition" does not exist
 'CREATE INDEX "idx_excavations_locationPosition" ON "public"."excavations" USING GIST (locationPosition)' {}

So the failure occurs on the creation of the index for the locationPosition geometry column.

If I copy the CREATE INDEX SQL query in psql I get the same error. And if I add double-quotes around locationPosition in the query the error is gone. This may be a bug in GeoAlchemy.

Use either Mako or Chameleon

At the moment, we have Mako and Chameleon templates in our project: Mako templates for the page templates and Chameleon templates for the map widget and the form.
Originally we wanted to use Mako because the prospective users are already familiar with Mako. Deform uses Chameleon, that's why the map widget is written with Chameleon.

PR #15 showed how to customize the form by overriding the Deform form template. This form template is also a Chameleon template. But because overriding the form template is the envisaged way to customize the form, we would force the users to write templates in Mako AND in Chameleon. We should try to only have one template language.

I see two possibilities:

Only Chameleon templates
+ We would have to convert the existing Mako templates, but this is no big deal.
+ Deform is still our friend.
- Users will have to learn Chameleon.

Only Mako templates
+ Maybe easier for the users.
- We will have to force Deform to use Mako for the form template (and maybe also for the map widget), but to continue using Chameleon for all other field widgets (so that we don't have to port all templates).
- If a user wants to customize a field (for example the date picker), he/she would still have to deal with Chameleon.

I would go with Chameleon only.

Form wizard

This issue is about making it possible to fill a form in multiple steps, with some sort of wizard. One potential option is to use jQuery Steps.

Improve documentation

  • Add more comments to the example
  • Improve documentation
    • The basic idea
    • Creating the model
      • hash-column
      • colander property: Deform widgets, Colander validators
      • map widget
    • The views provided by c2cgeoform
      • Overriding the site and widget templates
    • Creating a project with c2cgeoform
  • Improve c2cgeoform documentation a bit

Two-step form submission

For Pully we would like to introduce a two-step submission, where the user gets a confirmation page before actually submitting his form. The confirmation page includes a read-only view of the form and a checkbox that must be checked for submitting the form.

UnicodeDecodeError with chameleon

In form template ${myvar} with utf8 string throw errors.
Should'nt they supposed to be utf8 by default.
we use ${myvar.decode('utf-8')} as a workaround.

https://groups.google.com/forum/#!msg/pylons-discuss/GYc-T2AAn74/i-ulDCdKsAUJ

Traceback (most recent call last):
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/channel.py", line 337, in service
task.service()
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/task.py", line 173, in service
self.execute()
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/waitress-0.8.9-py2.7.egg/waitress/task.py", line 392, in execute
app_iter = self.channel.server.application(env, start_response)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid-1.5.1-py2.7.egg/pyramid/router.py", line 242, in call
response = self.invoke_subrequest(request, use_tweens=True)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid-1.5.1-py2.7.egg/pyramid/router.py", line 217, in invoke_subrequest
response = handle_request(request)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar-2.2-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 165, in toolb
ar_tween
return handler(request)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid-1.5.1-py2.7.egg/pyramid/tweens.py", line 21, in excview_tween
response = handler(request)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid_tm-0.7-py2.7.egg/pyramid_tm/init.py", line 82, in tm_tween
reraise(_exc_info)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid_tm-0.7-py2.7.egg/pyramid_tm/init.py", line 63, in tm_tween
response = handler(request)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid-1.5.1-py2.7.egg/pyramid/router.py", line 163, in handle_request
response = view_callable(context, request)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid-1.5.1-py2.7.egg/pyramid/config/views.py", line 377, in rendered_view
context)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid-1.5.1-py2.7.egg/pyramid/renderers.py", line 418, in render_view
return self.render_to_response(response, system, request=request)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid-1.5.1-py2.7.egg/pyramid/renderers.py", line 441, in render_to_response
result = self.render(value, system_values, request=request)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid-1.5.1-py2.7.egg/pyramid/renderers.py", line 437, in render
result = renderer(value, system_values)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/pyramid_chameleon-0.3-py2.7.egg/pyramid_chameleon/zpt.py", line 47, in call
result = self.template(__system)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/Chameleon-2.16-py2.7.egg/chameleon/template.py", line 123, in call
return self.render(__kwargs)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/Chameleon-2.16-py2.7.egg/chameleon/zpt/template.py", line 258, in render
return super(PageTemplate, self).render(__vars)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/Chameleon-2.16-py2.7.egg/chameleon/template.py", line 188, in render
raise_with_traceback(exc, tb)
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/Chameleon-2.16-py2.7.egg/chameleon/template.py", line 170, in render
self._render(stream, econtext, rcontext)
File "form_ef67fe0b2dabab19a29176a33a82da3b.py", line 129, in render
File "/home/amorvan/pullymorges_dpfe/geoform/.build/venv/local/lib/python2.7/site-packages/Chameleon-2.16-py2.7.egg/chameleon/zpt/template.py", line 262, in include
self._render(_args, **kwargs)
File "site_658ecdaad617d9582f8c1232b810651b.py", line 222, in render
File "site_658ecdaad617d9582f8c1232b810651b.py", line 82, in __quote
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 38: ordinal not in range(128)

  • Stream: ... des de permis de fouilles et empiétements
    ^
  • Expression: "${request.registry.settings['title']} - ${request.registry.settings['subtitle']}"
  • Filename: ... van/pullymorges_dpfe/geoform/dpfe/templates/site/site.pt
  • Location: (line 9: col 11)
  • Source: ... ${request.registry.settings['title']} - ${request.registry.settings['subtitle']} ...
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  • Arguments: repeat: {...} (0)
    renderer_name: templates/site/form.pt
    deform_dependencies: {...} (2)
    form: \n

    Commune de Pully

    \n

    Filing a request fo...
    localizer: <Localizer - at 0x2e39290>
    site: <PyramidPageTemplateFile - at 0x3056b10>
    renderer_info: <RendererHelper - at 0x2be5b10>
    _: <function auto_translate at 0x2bba758>
    req: <Request - at 0x2ae4dd0>
    request: <Request - at 0x2ae4dd0>
    context: <instance None at 0x2e3ab90>
    view: <function form at 0x2be82a8>

Improve list view

  • Make fields that are shown configurable (for example with a property admin_list: True)
  • Add pagination
  • Make columns sortable
  • Add search

404 not found on comments page (scaffolded app)

2017-11-03 14:08:00,240 ERROR [pyramid_debugtoolbar][waitress] Squashed Exception at http://localhost:6543/comments/
traceback url: http://localhost:6543/_debug_toolbar/313430303732313739393934373532/exception
Traceback (most recent call last):
  File "/home/fvanderbiest/workspace/MyProject/.build/venv/lib/python3.5/site-packages/pyramid/tweens.py", line 39, in excview_tween
    response = handler(request)
  File "/home/fvanderbiest/workspace/MyProject/.build/venv/lib/python3.5/site-packages/pyramid/router.py", line 156, in handle_request
    view_name
  File "/home/fvanderbiest/workspace/MyProject/.build/venv/lib/python3.5/site-packages/pyramid/view.py", line 648, in _call_view
    raise pme
  File "/home/fvanderbiest/workspace/MyProject/.build/venv/lib/python3.5/site-packages/pyramid/view.py", line 642, in _call_view
    response = view_callable(context, request)
  File "/home/fvanderbiest/workspace/MyProject/.build/venv/lib/python3.5/site-packages/pyramid/viewderivers.py", line 390, in attr_view
    return view(context, request)
  File "/home/fvanderbiest/workspace/MyProject/.build/venv/lib/python3.5/site-packages/pyramid/viewderivers.py", line 367, in predicate_wrapper
    view_name, predicate.text()))
pyramid.exceptions.PredicateMismatch: predicate mismatch for view ExcavationViews (match_param table=excavations)

Update Deform

Once a new version of Deform is released, which contains this PR Pylons/deform#243, we can do the following change in views.py:

# FIXME see https://github.com/Pylons/deform/pull/243

Replace

 except ValidationFailure, e:
    # FIXME see https://github.com/Pylons/deform/pull/243
    rendered = e.field.widget.serialize(
    e.field, e.cstruct, custom_data=custom_data)

with

 except ValidationFailure, e:
    rendered = e.serialize(custom_data=custom_data)

Allow for different user profiles

Currently c2cgeoform supports two user profiles only: user and admin. There are use-cases where other profiles may be needed. Profiles are an application-specific thing. c2cgeoform should allow using any number and any type of profiles. In particular it should be possible to assign a user profile to a field, and c2cgeoform could provide a function that creates a Form for a given profile.

Make default c2cgeoform views/routes optional

Currently, an application that uses c2cgeoform (config.include('c2cgeoform')) gets the c2cgeoform views and routes. This is because the c2cgeoform views and routes are defined in c2cgeoform's includeme function. So if some views/routes are unwanted in an application then they must be explicitly removed. See dpfe project for example. Instead, the use of the c2cgeoform views should optional.

Implement cstruct_children

Colander documentation's "Extending Colander" chapter says that "The cstruct_children method became required in Colander 0.9.9.". So our colander_ext.Geometry type should probably implement that method.

Support upload field

File upload fields should be supported. Deform 2 has a file upload widget, but we need to verify that colander and colander-alchemy also support that type.

Infrastructure

  • Test server
  • mod_wsgi config
  • requirements.txt
  • build file
  • Travis CI

Redirect to read-only view after submission

Currently after form submission we just display a new page including a read-only view of the form. For more flexibility, and to avoid re-submitting the form data when the user reloads the page, we should use a redirect (HTTPFound). The page we redirect to will have its own view and template. In this way the application developer will be able to customize the view and the template.

This issue is related to #51 which is invalid because the read-only view we have currently is "admin only".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.