Beispiel #1
0
class NewPostForm(Form):
    title = StringField(_l('Title'), validators=[DataRequired()])
    content = TextAreaField(_l('Content'), validators=[DataRequired()])
    covered_period = DateField(_l('Date'),
                               validators=[DataRequired()],
                               default=lambda: dtdate.today())
    week = BooleanField(_l('Covers whole week'))
    categories = SelectMultipleField(_('Categories'),
                                     widget=ListWidget(),
                                     option_widget=CheckboxInput(),
                                     choices=ClassChoices(
                                         Category.query.order_by('name'),
                                         'name'))

    def get_slug(self):
        return slugify(self.title.data)

    def fill_post_object(self, post):
        post.title = self.title.data
        post.content = self.content.data
        post.covered_period = self.covered_period.data
        post.covers_week = self.week.data
        post.categories.extend(
            Category.query.filter(Category.name.in_(self.categories.data)))

        return post
Beispiel #2
0
class RecoverSetForm(Form):
    password = PasswordField(_l('password'), [
        validators.Required(),
        validators.EqualTo('password2', message=_l("Passwords must match")),
        check_password_length
    ])
    password2 = PasswordField(_l('password repeat'))
Beispiel #3
0
class NewCategoryForm(Form):
    name = StringField(_l('Name'), validators=[DataRequired()])
    public = BooleanField(_l('Public'))
    users = SelectMultipleField(_l('Allowed readers'),
                                coerce=int,
                                widget=ListWidget(),
                                option_widget=CheckboxInput(),
                                choices=ClassChoices(
                                    User.query.order_by('login'), 'login'))
Beispiel #4
0
    class RegistrationForm(mixin_class, Form):
        email = EmailField(label=_l(u"Your email address"),
                           validators=[required(), email()])

        coming_on_oct_3 = BooleanField(
            label=_l(u"Will you come on Oct. 3th? (Thursday)"))
        coming_on_oct_4 = BooleanField(
            label=_l(u"Will you come on Oct. 4th? (Friday)"))
        coming_on_oct_5 = BooleanField(
            label=_l(u"Will you come on Oct. 5th? (Saturday)"))
Beispiel #5
0
class WFSEditForm(Form):
    def is_submitted(self):
        return request and request.method in ("PUT", "POST") and request.form.get('edit_form')

    layer = SelectField(_l('wfs_layer'))
    external_editor = HiddenField()
    edit_form = HiddenField()
Beispiel #6
0
 def validate(self):
     if not Form.validate(self):
         return False
     user = User.objects(name=self.name.data).first()
     if user is None:
         self.name.errors.append(_l(u'Username or password mismatch.'))
         return False
     return True
Beispiel #7
0
class ClassRoom(Slugged, Publishable, db.EmbeddedDocument):
    WEEKDAYS = (
        ("sun", _l("Sunday")),
        ("mon", _l("Monday")),
        ("tue", _l("Tuesday")),
        ("wed", _l("Wednesday")),
        ("thu", _l("Thursday")),
        ("fri", _l("Friday")),
        ("sat", _l("Saturday")),
    )
    title = db.StringField(required=True, max_length=100)
    description = db.StringField()
    weekdays = db.ListField(db.StringField(choices=WEEKDAYS), default=[])
    start_date = db.DateTimeField()
    end_date = db.DateTimeField()
    status = db.StringField()

    def get_description(self):
        return "<br>".join([
            self.title, self.description, ",".join(self.weekdays),
            self.start_date.strftime("%Y-%m-%d") if self.start_date else ''
        ])

    def get_weekdays_display(self, **kwargs):
        data = dict(self.WEEKDAYS)
        data.update(kwargs)
        return [data.get(k) for k in self.weekdays]

    def clean(self):
        self.validate_slug()

    def __unicode__(self):
        return self.title
Beispiel #8
0
def display_form():
  form = make_registration_form_class()()
  print form['track_1']

  page = dict(title=_l(u"Register as a participant"))
  tracks = Track.query.all()
  print g.lang
  return render_template("registration/form.html",
                         page=page, tracks=tracks, form=form, lang="en")
Beispiel #9
0
def display_form():
    form = make_registration_form_class()()
    print form['track_1']

    page = dict(title=_l(u"Register as a participant"))
    tracks = Track.query.all()
    return render_template("registration/form.html",
                           page=page,
                           tracks=tracks,
                           form=form)
Beispiel #10
0
    class ConfirmationForm(mixin_class, Form):
        email = EmailField(label=_l(u"Your email address"),
                           validators=[required(), email()])

        coming_on_oct_3 = BooleanField(
            label=_l(u"Will you come on Oct. 3th? (Thursday)"))
        coming_on_oct_4 = BooleanField(
            label=_l(u"Will you come on Oct. 4th? (Friday)"))
        coming_on_oct_5 = BooleanField(
            label=_l(u"Will you come on Oct. 5th? (Saturday)"))

        first_name = TextField(label=_l("First name"))
        last_name = TextField(label=_l("Last name"))
        organization = TextField(label=_l("Organization"))
        url = TextField(label=_l("URL"))
        url = TextAreaField(label=_l("Biography"))
Beispiel #11
0
class SDCApplicationForm(Form):
    theme = SelectField(label=_l(u"Merci de choisir une catégorie"),
                        choices=THEMES_AS_CHOICE,
                        validators=[required()])
    leader = StringField(label=_l(u"Votre nom"), validators=[required()])
    prenom = StringField(label=_l(u"Votre prénom"), validators=[required()])
    email = EmailField(label=_l(u"Your email address"),
                       validators=[required(), email()])
    telephone = StringField(label=_l(u"Votre téléphone"),
                            validators=[required()])
    organization = StringField(label=_l(u"Etablissement / entreprise"),
                               validators=[required()])
    intervenants = TextAreaField(
        label=_l(u"Autres intervenants (autant de possible)"))
    summary = TextAreaField(label=_l(u"Résumé du projet"),
                            validators=[required()])
Beispiel #12
0
class NewUserForm(EditAddressForm):
    type = SelectField(_l('type'), coerce=int)
    email = TextField(
        _l('email'),
        [validators.Required(), username_unique,
         validators.Email()])
    password = PasswordField(_l('password'), [
        validators.Required(),
        validators.EqualTo('password2', message=_l("Passwords must match")),
        check_password_length
    ])
    password2 = PasswordField(_l('password repeat'))
    terms_of_use = BooleanField(_l('terms of use'), [validators.Required()])
Beispiel #13
0
    def apply(self, permission, acl, resource=_l('resource')):
        """apply acl, abort if not allowed"""
        logger.debug('check %r with acl %r', permission, acl)
        if isinstance(acl, Container) and len(acl) < 0:
            return
        thruth = self.get_thruth(permission, current_user, acl)
        if thruth == 'ALLOW':
            logger.debug('ALLOW for space')
            return
        elif thruth == 'DENY':
            logger.debug('DENY for space')
            abort(403,
                  _('You are not allowed to "%(permission)s" this\
 %(resource)s',
                    permission=PERMISSIONS.get(permission, _('unknown')),
                    resource=resource))
        else:
            logger.debug('no match for space, ignore')
            return
Beispiel #14
0
  def __init__(self, *panels, **kwargs):
    self.app = None
    self.panels = []
    self.breadcrumb_items = {}
    self.setup_blueprint()

    self.nav_root = NavGroup(
      'admin', 'root', title=_l(u'Admin'),
      endpoint=None,
      condition=lambda context: (not current_user.is_anonymous()
                                 and security.has_role(current_user, AdminRole))
    )

    for panel in panels:
      self.register_panel(panel)

    app = kwargs.pop('app', None)
    if app is not None:
      self.init_app(app)
Beispiel #15
0
def check_password_length(form, field):
    if len(field.data) < 5:
        raise ValidationError(_l('Password must at least 6 characters'))
Beispiel #16
0
def username_exists(form, field):
    if not User.by_email(field.data):
        raise ValidationError(_l('email does not exist.'))
Beispiel #17
0
def username_unique(form, field):
    if User.by_email(field.data):
        raise ValidationError(_l('email already exists.'))
Beispiel #18
0
class WFSSearchForm(Form):
    wfs_serach_layer = QuerySelectField(_l('select coverage'), [validators.Required()], query_factory=query_all_wfs,
        get_label=lambda a: ('%s (%s)' % (a.name, a.search_property)), get_pk=lambda a: a.name)
Beispiel #19
0
class CopyFileForm(Form):
    filename = TextField(_l('filename'), [validators.Required()])
    boxes = QuerySelectField(_l('select target user'), [validators.Required()],
                             query_factory=query_all_user_boxes,
                             get_label='email')
Beispiel #20
0
import logging
from collections import Container
from functools import wraps
from flask import abort
from flask.ext.login import current_user
from flask.ext.babel import gettext as _, lazy_gettext as _l

from gasoline.services.base import Service

__all__ = ['ACLService']

logger = logging.getLogger('gasoline')

PERMISSIONS = {
    'read': _l('read'),
    'write': _l('write'),
    'delete': _l('delete'),
    'write.comments': _l('write comments'),
    'write.attachments': _l('write attachments'),
}


class ACLService(Service):
    name = 'acl'

    def init_app(self, app):
        """intialise ACL service with flask configuration"""
        super(ACLService, self).init_app(app)

    def apply(self, permission, acl, resource=_l('resource')):
Beispiel #21
0
    """
    args, kwargs = super(ObjectView, self).prepare_args(args, kwargs)
    self.form = self.Form(**self.get_form_kwargs())
    return args, kwargs

  def get_form_kwargs(self):
    return dict(obj=self.obj)

  def index_url(self):
    return url_for('.index')

  def redirect_to_index(self):
    return redirect(self.index_url())


CANCEL_BUTTON = ButtonAction('form', 'cancel', title=_l(u'Cancel'))
EDIT_BUTTON = ButtonAction('form', 'edit', btn_class='primary', title=_l(u'Save'))


class ObjectEdit(ObjectView):
  """
  Edit objects
  """
  template = 'default/object_edit.html'

  #: :class:ButtonAction instance to show on form
  _buttons = ()

  #: submitted form data
  data = None
Beispiel #22
0
 def validate_view_level_end(form, field):
     if form.data['view_level_start'] > field.data:
         raise validators.ValidationError(_l('level needs to be bigger or equal to start level'))
Beispiel #23
0
 def validate_view_level_end(form, field):
     if form.data['view_level_start'] > field.data:
         raise validators.ValidationError(_l('level needs to be bigger or equal to start level'))
Beispiel #24
0
class LoginForm(Form):
    login = StringField(_l('Login'), validators=[DataRequired()])
    password = PasswordField(_l('Password'))
    next = HiddenField()
Beispiel #25
0
class RemoveUserForm(Form):
    password = PasswordField(_l('password'), [validators.Required()])
Beispiel #26
0
class EditPasswordForm(RecoverSetForm):
    old_password = PasswordField(_l('old password'), [validators.Required()])
Beispiel #27
0
class EditAddressForm(Form):
    title = SelectField(
        _l('title'),
        [validators.Required()],
        choices=[
        ]  # at the moment choices are set on view, because we load they from config
    )

    lastname = TextField(_l('lastname'), [validators.Required()])
    firstname = TextField(_l('firstname'), [validators.Required()])

    address = TextField(_l('address'), [validators.Required()])
    address_extend = TextField(_l('address_extend'))
    company_name = TextField(_l('company_name'))

    zipcode = TextField(_l('zipcode'), [validators.Required()])
    city = TextField(_l('city'), [validators.Required()])
    federal_state = TextField(_l('federal_state'))

    federal_state = SelectField(
        _l('federal_state'),
        [validators.Required()],
        choices=[
        ]  # at the moment choices are set on view, because we load they from config
    )

    phone = TextField(_l('phone'))
    fax = TextField(_l('fax'))

    # only used for customers number has 10-16 characters
    company_number = TextField(_l('company_number'),
                               # [validators.Length(min=10, max=16)]
                               )

    # only used for service_provider
    commercial_register_number = TextField(_l('commercial_register_number'))
Beispiel #28
0
class LoginForm(Form):
    email = TextField(_l('email'), [validators.Required(), validators.Email()])
    password = PasswordField(_l('password'), [validators.Required()])
Beispiel #29
0
class DefaultConfig(object):
    """
    Default configuration
    """

    TESTING = False

    DEBUG = True

    # config for pagination
    USER_PER_PAGE = 20

    WTF_I18N_ENABLED = True

    SESSION_COOKIE_NAME = 'gbi_server_session'

    # allow access to admin URLs without authentication
    # (e.g. for testing with curl)
    ADMIN_PARTY = False

    # change this in your production settings !!!

    SECRET_KEY = "verysecret"

    # keys for localhost. Change as appropriate.

    SQLALCHEMY_DATABASE_URI = 'postgresql://*****:*****@127.0.0.1:5432/igreen'
    SQLALCHEMY_ECHO = False
    # from warning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.
    # TODO check if tracking is required
    SQLALCHEMY_TRACK_MODIFICATIONS = True

    ACCEPT_LANGUAGES = ['de']

    ASSETS_DEBUG = True
    ASSETS_BUNDLES_CONF = p.join(p.dirname(__file__), 'asset_bundles.yaml')

    LOG_DIR = p.abspath(p.join(p.dirname(__file__), '../../var/log'))
    DEBUG_LOG = 'debug.log'
    ERROR_LOG = 'error.log'

    CACHE_TYPE = "simple"
    CACHE_DEFAULT_TIMEOUT = 300

    BCRYPT_LOG_ROUNDS = 10

    MAIL_SERVER = "localhost"
    MAIL_USERNAME = '******'
    MAIL_PASSWORD = '******'
    MAIL_DEBUG = DEBUG
    MAIL_DEFAULT_SENDER = "GeoBox Server <*****@*****.**>"
    MAIL_FOOTER = '''
--
Internet: https://example.org
E-Mail: [email protected]
'''

    TINYOWS_NAME = "TinyOWS Server"
    TINYOWS_TITLE = "TinyOWS Server - Demo Service"
    TINYOWS_BIN = "/usr/local/bin/tinyows"
    TINYOWS_SCHEMA_DIR = "/usr/local/share/tinyows/schema/"
    TINYOWS_LOG_FILE = "/tmp/tinyows.log"
    TINYOWS_LOG_LEVEL = "7"
    TINYOWS_NS_PREFIX = "tows"
    TINYOWS_NS_URI = "http://www.tinyows.org/"

    TINYOWS_TMP_CONFIG_DIR = "/tmp/tinyows"
    TEMP_PG_HOST = "127.0.0.1"
    TEMP_PG_DB = "wfs_tmp"
    TEMP_PG_USER = "******"
    TEMP_PG_PASSWORD = "******"
    TEMP_PG_PORT = "5432"

    # remove this one if we remove the editor completly
    USER_READONLY_LAYER = "florlp"
    USER_WORKON_LAYER = "baselayer"

    COUCH_DB_URL = "http://127.0.0.1:5984"
    # user name and password for db admin that is allowed to
    # create new user boxes
    COUCH_DB_ADMIN_USER = '******'
    COUCH_DB_ADMIN_PASSWORD = '******'

    PARCEL_SEARCH_DATABASE_URI = ''
    PARCEL_SEARCH_DATABASE_SRID = 25832
    PARCEL_SEARCH_DATABASE_ECHO = False
    PARCEL_SEARCH_USE_DUMMY_DATA = False

    AUTHPROXY_CACHE_DIR = "/tmp/authproxy"

    MAPPROXY_SRS = ['EPSG:25832']
    MAPPROXY_YAML_DIR = "/tmp/"

    GBI_CLIENT_DOWNLOAD_URL = "http://download.omniscale.de/geobox/dist/setup-geobox-0.2.7.exe"

    STATIC_PAGES_DIR = p.join(p.dirname(__file__), '..', 'pages')
    USERMANUAL_URL = 'usermanual-gbi-server.pdf'

    # enable/disable document boxes (CUSTOMER/CONSULTANT)
    FEATURE_DOC_BOXES = True
    # enable/disable area boxes
    FEATURE_AREA_BOXES = True

    # enable WFS editor
    FEATURE_EDITOR = True

    # allow CUSTOMER accounts
    FEATURE_CUSTOMER_USERS = True
    # allow CONSULTANT accounts
    FEATURE_CONSULTANT_USERS = True

    SALUTATIONS = [
        ('mr', _l(u'mr')),
        ('mrs', _l(u'mrs')),
    ]

    FEDERAL_STATES = [
        ('BW', _l(u'Baden-Wuerttemberg')),
        ('BY', _l(u'Bavaria')),
        ('BE', _l(u'Berlin')),
        ('BB', _l(u'Brandenburg')),
        ('HB', _l(u'Bremen')),
        ('HH', _l(u'Hamburg')),
        ('HE', _l(u'Hesse')),
        ('MV', _l(u'Mecklenburg Western Pomerania')),
        ('NI', _l(u'Lower Saxony')),
        ('NW', _l(u'Northrhine-Westphalia')),
        ('RP', _l(u'Rhineland Palatinate')),
        ('SL', _l(u'Saarland')),
        ('SN', _l(u'Saxony')),
        ('ST', _l(u'Saxony-Anhalt')),
        ('SH', _l(u'Schleswig Holstein')),
        ('TH', _l(u'Thuringia')),
    ]

    PORTAL_PREFIX = "DEFAULT"
    PORTAL_TITLE = "Unconfigured GeoBox-Server"

    LOG_CSV_HEADER = [
        "time", "action", "format", "srs", "mapping", "source", "layer",
        "zoom_level_start", "zoom_level_end", "refreshed",
        "geometry_as_geojson"
    ]

    TILE_PROXY_URLS = [
        (
            re.compile(
                'http://igreendemo.omniscale.net/wmts/(?P<layer>[^/]+)/GoogleMapsCompatible-(?P<z>[^/]+)-(?P<x>[^/]+)-(?P<y>[^/]+)/tile$'
            ),
            'http://igreendemo.omniscale.net/wmts/%(layer)s/GoogleMapsCompatible-%(z)s-%(x)s-%(y)s/tile'
            # 'http://localhost:8099/%(layer)s/GoogleMapsCompatible-%(z)s-%(x)s-%(y)s/tile'
        ),
    ]
Beispiel #30
0
class NewUserForm(Form):
    login = StringField(_l('Login'), validators=[DataRequired()])
    password = PasswordField(_l('Password'), validators=[DataRequired()])
Beispiel #31
0
def username_unique(form, field):
    if User.by_email(field.data):
    	raise ValidationError(_l('email already exists.'))
Beispiel #32
0
class WMSForm(RasterSourceForm):
    version = SelectField(_l('wms_version'), choices=[('1.1.1', '1.1.1'), ('1.3.0', '1.3.0')],
        validators=[validators.Required()])
Beispiel #33
0
def check_password_length(form, field):
    if len(field.data) < 5:
        raise ValidationError(_l('Password must at least 6 characters'))
Beispiel #34
0
class CommentForm(Form):
    post = IntegerField(widget=HiddenInput())
    comment = TextAreaField(_l('Leave a comment'), validators=[DataRequired()])
Beispiel #35
0
class UploadForm(Form):
    file = FileField(_l('file'), [validators.Required()])
    overwrite = HiddenField('overwrite', default=False)
Beispiel #36
0
def username_exists(form, field):
    if not User.by_email(field.data):
    	raise ValidationError(_l('email does not exist.'))
Beispiel #37
0
class WFSAddLayerForm(Form):
    def is_submitted(self):
        return request and request.method in ("PUT", "POST") and request.form.get('add_form')

    new_layer = TextField(_l('wfs_new_layer_name'), validators=[validators.Required(),])
    add_form = HiddenField()
Beispiel #38
0
class RecoverRequestForm(Form):
    email = TextField(
        _l('email'),
        [validators.Required(), username_exists,
         validators.Email()])
Beispiel #39
0
def display_form():
    form = SDCApplicationForm()
    page = dict(title=_l(u"Candidature pour la Student Demo Cup"))
    return render_template("sdc/form.html", page=page, form=form)
Beispiel #40
0
# -*- coding: utf-8 -*-
"""
Based on:
Activity Stream Specs: http://activitystrea.ms/specs/json/1.0/
"""


from datetime import datetime

from gasoline.core.extensions import db
from flask.ext.babel import gettext as _, lazy_gettext as _l

ACTIONS = {
    'create': {
        'page': _l('create page'),
        'event': _l('create event'),
        'issue': _l('create issue'),
        'task': _l('create task'),
    },
    'update': {
        'page': _l('update page'),
    },
    'remove': {
        'page': _l('remove page'),
    },
    'attach': {
        'file': _l('attach file'),
    },
    'add': {
        'comment': _l('comment'),
    },
Beispiel #41
0
class RasterSourceForm(Form):
    url = TextField(_l('rastersource_url'), [validators.Required()])
    username = TextField(_l('rastersource_username'))
    password = PasswordField(_l('rastersource_password'))
    name = TextField(_l('rastersource_name'), [validators.Required(), validators.Regexp('[a-z0-9_-]+$')])
    title = TextField(_l('rastersource_title'), [validators.Required()])
    layer = TextField(_l('rastersource_layer'), [validators.Required()])
    format = SelectField(_l('rastersource_format'), [validators.Required()], choices=[('png', 'png'), ('jpeg', 'jpeg')])
    srs = TextField(_l('rastersource_srs'), [validators.Required()])
    max_tiles = TextField(_l('rastersource_max_tiles'), [validators.Regexp('^\d*$')])

    view_coverage = TextAreaField(_l('rastersource_view_coverage'), [validators.Required()]) #XXX kai: geojson validator?
    view_level_start = SelectField(_l('rastersource_view_level_start'), coerce=int, choices=[(x, x) for x in range(20)])
    view_level_end = SelectField(_l('rastersource_view_level_end'), coerce=int, choices=[(x, x) for x in range(20)])

    is_background_layer = BooleanField(_l('rastersource_background_layer'))
    is_transparent = BooleanField(_l('rastersource_transparent'))
    is_visible = BooleanField(_l('rastersource_visibility'))
    is_public = BooleanField(_l('rastersource_public'))
    is_accessible = BooleanField(_l('rastersource_accessible'))
    is_protected = BooleanField(_l('rastersource_protected'))

    def validate_view_level_end(form, field):
        if form.data['view_level_start'] > field.data:
            raise validators.ValidationError(_l('level needs to be bigger or equal to start level'))