Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 2, 2017
2 parents af3608f + c41a208 commit cfc54eb
Show file tree
Hide file tree
Showing 19 changed files with 230 additions and 250 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,6 +9,7 @@
/c2cgeoportal/locale/c2cgeoportal.pot
/c2cgeoportal/locale/*/LC_MESSAGES/c2cgeoportal.po
/c2cgeoportal/locale/*/LC_MESSAGES/c2cgeoportal.mo
/c2cgeoportal/scaffolds/create/+package+/locale/*/LC_MESSAGES/+package+-client.po
/c2cgeoportal/scaffolds/update/CONST_Makefile_tmpl.mk
/c2cgeoportal/scaffolds/create/package.json_tmpl
/c2cgeoportal/scaffolds/update/+dot+tx/CONST_config_mako
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -17,7 +17,7 @@ before_install:
- sudo apt-get remove --assume-yes --force-yes python-zope.interface postgresql-*
- sudo apt-get install --assume-yes --force-yes aptitude
- curl --silent --location https://deb.nodesource.com/setup_6.x | sudo -E bash -
- sudo aptitude install --assume-yes apache2 libapache2-mod-wsgi libapache2-mod-fcgid tomcat7 nodejs cgi-mapserver
- sudo aptitude install --assume-yes apache2 libapache2-mod-wsgi libapache2-mod-fcgid tomcat7 nodejs cgi-mapserver gettext
- sudo apt-get install --option Dpkg::Options::="--force-confold" --force-yes --assume-yes docker-engine
- sudo pip install pyignore git+https://github.com/docker/docker-py.git@1.10.6#egg=docker docker-compose==1.9.0 requests==2.11.1

Expand Down
6 changes: 6 additions & 0 deletions .tx/config.mako
Expand Up @@ -7,3 +7,9 @@ source_file = c2cgeoportal/locale/c2cgeoportal.pot
source_lang = en
trans.de = c2cgeoportal/locale/de/LC_MESSAGES/c2cgeoportal.po
trans.fr = c2cgeoportal/locale/fr/LC_MESSAGES/c2cgeoportal.po

[ngeo.gmf-apps-${tx_version.strip()}]
type = PO
source_lang = en
trans.de = c2cgeoportal/scaffolds/create/+package+/locale/de/LC_MESSAGES/+package+-client.po
trans.fr = c2cgeoportal/scaffolds/create/+package+/locale/fr/LC_MESSAGES/+package+-client.po
10 changes: 9 additions & 1 deletion Makefile
Expand Up @@ -41,7 +41,8 @@ else
TOUCHBACK_TXRC = touch --date "$(shell stat -c '%y' $(HOME)/.transifexrc)" $(HOME)/.transifexrc
endif
L10N_LANGUAGES = fr de
L10N_PO_FILES = $(addprefix c2cgeoportal/locale/,$(addsuffix /LC_MESSAGES/c2cgeoportal.po, $(L10N_LANGUAGES)))
L10N_PO_FILES = $(addprefix c2cgeoportal/locale/,$(addsuffix /LC_MESSAGES/c2cgeoportal.po, $(L10N_LANGUAGES))) \
$(addprefix c2cgeoportal/scaffolds/create/+package+/locale/,$(addsuffix LC_MESSAGES/+package+-client.po, $(L10N_LANGUAGES)))
LANGUAGES = en $(L10N_LANGUAGES)
PO_FILES = $(addprefix c2cgeoportal/locale/,$(addsuffix /LC_MESSAGES/c2cgeoportal.po, $(LANGUAGES)))
MO_FILES = $(addprefix $(BUILD_DIR)/,$(addsuffix .mo.timestamp,$(basename $(PO_FILES))))
Expand Down Expand Up @@ -259,6 +260,13 @@ c2cgeoportal/locale/%/LC_MESSAGES/c2cgeoportal.po: $(TX_DEPENDENCIES)
$(TOUCHBACK_TXRC)
test -s $@

c2cgeoportal/scaffolds/create/+package+/locale/%/LC_MESSAGES/+package+-client.po: \
$(TX_DEPENDENCIES) .build/dev-requirements.timestamp
mkdir -p $(dir $@)
.build/venv/bin/tx pull -l $* --force
$(TOUCHBACK_TXRC)
test -s $@

$(BUILD_DIR)/%.mo.timestamp: %.po
mkdir -p $(dir $@)
msgfmt -o $*.mo $<
Expand Down
18 changes: 10 additions & 8 deletions c2cgeoportal/pyramid_.py
Expand Up @@ -114,8 +114,8 @@ def add_interface(
)


def add_interface_cgxp(config, interface_name, route_names, routes, renderers,
permission=None): # pragma: no cover
def add_interface_cgxp(
config, interface_name, route_names, routes, renderers, permission=None): # pragma: no cover
# Cannot be at the header to don"t load the model too early
from c2cgeoportal.views.entry import Entry

Expand Down Expand Up @@ -165,8 +165,8 @@ def new_f(root, request):
ngeo_static_init = False


def add_interface_ngeo(config, interface_name, route_name, route, renderer,
permission=None): # pragma: no cover
def add_interface_ngeo(
config, interface_name, route_name, route, renderer, permission=None): # pragma: no cover
# Cannot be at the header to do not load the model too early
from c2cgeoportal.views.entry import Entry

Expand Down Expand Up @@ -288,7 +288,7 @@ def is_valid_referer(request, settings):


def create_get_user_from_request(settings):
def get_user_from_request(request):
def get_user_from_request(request, username=None):
""" Return the User object for the request.
Return ``None`` if:
Expand Down Expand Up @@ -331,7 +331,8 @@ def get_user_from_request(request):

if not hasattr(request, "_user"):
request._user = None
username = request.authenticated_userid
if username is None:
username = request.authenticated_userid
if username is not None:
# We know we will need the role object of the
# user so we use joined loading
Expand Down Expand Up @@ -471,8 +472,9 @@ def includeme(config):

call_hook(settings, "after_settings", settings)

config.add_request_method(create_get_user_from_request(settings),
name="user", property=True)
get_user_from_request = create_get_user_from_request(settings)
config.add_request_method(get_user_from_request, name="user", property=True)
config.add_request_method(get_user_from_request, name="get_user")

# configure 'locale' dir as the translation dir for c2cgeoportal app
config.add_translation_dirs("c2cgeoportal:locale/")
Expand Down
1 change: 1 addition & 0 deletions c2cgeoportal/scaffolds/create/language_mapping
@@ -0,0 +1 @@
fr=fr-ch
8 changes: 8 additions & 0 deletions c2cgeoportal/scaffolds/update/CONST_CHANGELOG.txt_tmpl
@@ -1,6 +1,14 @@
This file includes migration steps for each release of c2cgeoportal.


Version 2.1.5
=============

1. Get the new language mapping used to select angular sub local:

cp CONST_create_template/language_mapping .


Version 2.1.2
=============

Expand Down
23 changes: 10 additions & 13 deletions c2cgeoportal/scaffolds/update/CONST_Makefile_tmpl
Expand Up @@ -615,8 +615,13 @@ serve: build development.ini
$(VENV_BIN)/pserve --reload --monitor-restart development.ini

.PHONY: update-node-modules
<<<<<<< HEAD
update-node-modules: $(NPM_CMD)
$(NPM_CMD) install --force || sleep 20 || $(NPM_CMD) install --force || sleep 90 || $(NPM_CMD) install --force
=======
update-node-modules:
npm install --force
>>>>>>> origin/2.1
mkdir -p .build
touch .build/node_modules.timestamp

Expand Down Expand Up @@ -818,9 +823,9 @@ $(APP_OUTPUT_DIR)/%.json: $(PACKAGE)/locale/%/LC_MESSAGES/$(PACKAGE)-$(L10N_CLIE
.build/locale/$*/LC_MESSAGES/ngeo.po \
$< > $@

$(APP_OUTPUT_DIR)/angular-locale_%.js: node_modules/ngeo/github_versions
$(APP_OUTPUT_DIR)/angular-locale_%.js: node_modules/ngeo/github_versions language_mapping
mkdir -p $(dir $@)
wget -O $@ https://raw.githubusercontent.com/angular/angular.js/`grep ^angular.js= $< | cut --delimiter = --fields 2`/src/ngLocale/angular-locale_$*.js
wget -O $@ https://raw.githubusercontent.com/angular/angular.js/`grep ^angular.js= $< | cut --delimiter = --fields 2`/src/ngLocale/angular-locale_`(grep $* language_mapping || echo $*) | cut -d = -f 2`.js

$(APP_OUTPUT_DIR)/%.js: .build/%.js .build/node_modules.timestamp $(NGEO_LIBS_JS_FILES) $(NGEO_PROJECT_LIBS_JS_FILES)
$(PRERULE_CMD)
Expand Down Expand Up @@ -971,19 +976,11 @@ else
touch $@
endif

$(NPM_CMD):
$(PRERULE_CMD)
ifeq ($(OPERATING_SYSTEM), LINUX)
npm install npm || sleep 20 || npm install npm || sleep 90 || npm install npm
else
touch $@
endif

.build/node_modules.timestamp: package.json $(NPM_CMD)
.build/node_modules.timestamp: package.json
$(PRERULE_CMD)
mkdir -p $(dir $@)
ifneq ($(NGEO_INTERFACES), "")
$(NPM_CMD) install || sleep 20 || $(NPM_CMD) install || sleep 90 || $(NPM_CMD) install
npm install || sleep 20 || npm install || sleep 90 || npm install
endif
touch $@

Expand Down Expand Up @@ -1012,7 +1009,7 @@ update:
git submodule foreach git submodule foreach git clean -fd
ifneq ($(NGEO_INTERFACES), "")
rm -f .build/node_modules.timestamp
$(NPM_CMD) install --force
npm install --force
touch .build/node_modules.timestamp
endif
@echo After that you should launch the `build` task.
Expand Down
3 changes: 2 additions & 1 deletion c2cgeoportal/scripts/c2ctool.py
Expand Up @@ -366,7 +366,8 @@ def step1(self):
pip_cmd += ["c2cgeoportal=={0!s}".format((self.options.version))]
check_call(pip_cmd)

shutil.rmtree("CONST_create_template")
if os.path.exists("CONST_create_template"):
shutil.rmtree("CONST_create_template")
check_call([
"{0!s}/pcreate".format(self.venv_bin), "--ignore-conflicting-name", "--overwrite",
"--scaffold=c2cgeoportal_update", "../{0!s}".format(self.project["project_folder"])
Expand Down
1 change: 1 addition & 0 deletions c2cgeoportal/scripts/themev1tov2.py
Expand Up @@ -213,6 +213,7 @@ def layer_v1tov2(session, layer):
for link in layer.parents_relation:
new_link = LayergroupTreeitem()
new_link.ordering = link.ordering
new_link.description = link.description
new_link.treegroup_id = link.treegroup_id
new_link.group = link.group
new_link.item = new_layer
Expand Down
4 changes: 2 additions & 2 deletions c2cgeoportal/scripts/treeitem_uniquename.py
Expand Up @@ -61,10 +61,10 @@ def main():
for item in DBSession.query(class_).all():
if item.name in names:
i = 2
while "{}-{}".format(item.name, i) in names:
while u"{}-{}".format(item.name, i) in names:
i += 1

item.name = "{}-{}".format(item.name, i)
item.name = u"{}-{}".format(item.name, i)
names.append(item.name)

transaction.commit()
34 changes: 0 additions & 34 deletions c2cgeoportal/static/adminapp/js/Admin/checkbox.js
Expand Up @@ -137,25 +137,6 @@ either expressed or implied, of the FreeBSD Project.
// els.attr('disabled', state);
};

/**
* show / hide restrictionArea input fields
*/
$.fn.adminapp.toogleRestrictionAreas = function(el) {
var els = $.fn.adminapp.findField('restrictionareas', [el.id]);
var state = el.value == "internal WMS" || el.value == "WMTS";
if (state) {
els.removeClass('disabledinput');
} else {
// reset value
$.fn.adminapp.resetField(els);

els.addClass('disabledinput');
}
// set readonly
els.attr('readOnly', !state);
els.attr('disabled', !state);
};

/**
* show / hide unneeded fields
*/
Expand Down Expand Up @@ -198,20 +179,6 @@ either expressed or implied, of the FreeBSD Project.
change("query_layers", fields);
change("is_single_tile", fields);
change("legend_rule", fields);

enablePrivateOption = state == "internal WMS" || state == "WMTS"
var e = $.fn.adminapp.findField("public", [el.id]);
e.attr('readOnly', !enablePrivateOption);
if (enablePrivateOption) {
e.removeClass('disabledinput');
}
else {
e.addClass('disabledinput');
e.attr('checked', true);
}
this.toogleRestrictionAreas(el);
// true should be send ...
//e.attr('disabled', !internalWMS);
};

$.fn.adminapp.toogleBaseLayer = function(wmsi, bl) {
Expand Down Expand Up @@ -287,7 +254,6 @@ $(document).ready(function(){
// restrictionareas
$.fn.adminapp.bindEventOnLayer(lt[0]);
// init state
$.fn.adminapp.toogleRestrictionAreas(lt[0]);
$.fn.adminapp.toogleLayerType(lt[0]);
}

Expand Down
7 changes: 7 additions & 0 deletions c2cgeoportal/tests/functional/__init__.py
Expand Up @@ -122,6 +122,12 @@ def create_default_ogcserver():
return ogcserver, ogcserver_external


def _get_user(username):
from c2cgeoportal.models import DBSession, User

return DBSession.query(User).filter(User.username == username).one()


def create_dummy_request(additional_settings=None, authentication=True, user=None, *args, **kargs):
if additional_settings is None:
additional_settings = {}
Expand All @@ -148,6 +154,7 @@ def create_dummy_request(additional_settings=None, authentication=True, user=Non
request.referer = "http://example.com/app"
request.path_info_peek = lambda: "main"
request.interface_name = "main"
request.get_user = _get_user
request.registry.validate_user = default_user_validator
request.client_addr = None
if authentication:
Expand Down

0 comments on commit cfc54eb

Please sign in to comment.