# HG changeset patch # User ymh # Date 1429007467 -7200 # Node ID 59450d8648814e5fc9fa46dd02189826457c2f48 # Parent 447bac7821e6916d5068f5ca2e2b987706cd9eef add task indicator + some cleaning tasks diff -r 447bac7821e6 -r 59450d864881 src/catedit/__init__.py --- a/src/catedit/__init__.py Fri Apr 10 17:30:19 2015 +0200 +++ b/src/catedit/__init__.py Tue Apr 14 12:31:07 2015 +0200 @@ -39,7 +39,7 @@ cache = Cache(app, config=app.config["CACHE_CONFIG"]) # CSRF protection -CsrfProtect(app) +csrf = CsrfProtect(app) # Github app.config["GITHUB_CLIENT_ID"] = app.config["PERSISTENCE_CONFIG"].get( @@ -52,7 +52,8 @@ ) github = GitHub(app) -celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL']) +#celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'], backend=app.config['CE']) +celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'], backend=app.config['CELERY_RESULT_BACKEND']) celery.conf.update(app.config) @github.access_token_getter @@ -141,11 +142,12 @@ app.config["CURRENT_VERSION"] = CURRENT_VERSION # Views and APIs -from catedit.views import home, categories, social +from catedit.views import home, categories, social, meta from catedit.resources import CategoryAPI, CategoryChangesAPI app.register_blueprint(home.module) -app.register_blueprint(categories.module) -app.register_blueprint(social.module) +app.register_blueprint(categories.module, url_prefix='/cat') +app.register_blueprint(social.module, url_prefix='/social') +app.register_blueprint(meta.meta, url_prefix='/meta') api.add_resource(CategoryAPI, diff -r 447bac7821e6 -r 59450d864881 src/catedit/config.py.tmpl --- a/src/catedit/config.py.tmpl Fri Apr 10 17:30:19 2015 +0200 +++ b/src/catedit/config.py.tmpl Tue Apr 14 12:31:07 2015 +0200 @@ -6,6 +6,7 @@ from rdflib import RDF, RDFS, Literal from rdflib.namespace import SKOS from kombu import Queue +import os class AppConfig(object): @@ -13,7 +14,8 @@ HOST = "0.0.0.0" DEBUG = True - + + # WTForms settings SECRET_KEY = 'totally-secret-key' @@ -27,7 +29,7 @@ LOGGING_CONFIG = { "IS_LOGGING": False, "LOGGING_LEVEL": "DEBUG", - "LOG_FILE_PATH": "../../run/log/log.txt", + "LOG_FILE_PATH": os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'../../run/log/log.txt')), } """ @@ -73,34 +75,35 @@ "GITHUB_CLIENT_ID" : "github-client-placeholder", "GITHUB_CLIENT_SECRET" : "github-secret-placeholder", } - + PROPERTY_LIST = { "http://www.w3.org/2000/01/rdf-schema#comment": { - "descriptive_label_fr": "Commentaire", - "descriptive_label_en": "Comment", - "object_type": "literal", - "usable_in_editor": false, - "rdflib_class": "http://www.w3.org/2000/01/rdf-schema#comment" - }, - "http://www.w3.org/2000/01/rdf-schema#Resource": { - "descriptive_label_fr": "Ressource", - "descriptive_label_en": "Resource", - "object_type": "uriref-link", - "usable_in_editor": false, - "rdflib_class": "http://www.w3.org/2000/01/rdf-schema#Resource" - }, - "http://www.w3.org/2004/02/skos/core#related": { - "descriptive_label_fr": "En relation avec", - "descriptive_label_en": "Related to", - "object_type": "uriref-category", - "usable_in_editor": false, - "rdflib_class": "http://www.w3.org/2004/02/skos/core#related" - } + "descriptive_label_fr": "Commentaire", + "descriptive_label_en": "Comment", + "object_type": "literal", + "usable_in_editor": false, + "rdflib_class": "http://www.w3.org/2000/01/rdf-schema#comment" + }, + "http://www.w3.org/2000/01/rdf-schema#Resource": { + "descriptive_label_fr": "Ressource", + "descriptive_label_en": "Resource", + "object_type": "uriref-link", + "usable_in_editor": false, + "rdflib_class": "http://www.w3.org/2000/01/rdf-schema#Resource" + }, + "http://www.w3.org/2004/02/skos/core#related": { + "descriptive_label_fr": "En relation avec", + "descriptive_label_en": "Related to", + "object_type": "uriref-category", + "usable_in_editor": false, + "rdflib_class": "http://www.w3.org/2004/02/skos/core#related" + } } - + # Celery settings - - CELERY_BROKER_URL = 'sqla+sqlite:////Users/durandn/IRIProjects/catedit/src/catedit/celerydb.sqlite' + + CELERY_BROKER_URL = 'sqla+sqlite:///' + os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'../../run/files/celerydb.sqlite')) + CELERY_RESULT_BACKEND = 'db+sqlite:///' + os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'../../run/files/celeryresults.sqlite')) if PERSISTENCE_CONFIG["METHOD"] == "PersistenceToGithub": CELERY_QUEUES = tuple( Queue("repo_"+repository, routing_key="task_for_"+repository) for repository in PERSISTENCE_CONFIG["REPOSITORY_LIST"] diff -r 447bac7821e6 -r 59450d864881 src/catedit/settings.py --- a/src/catedit/settings.py Fri Apr 10 17:30:19 2015 +0200 +++ b/src/catedit/settings.py Tue Apr 14 12:31:07 2015 +0200 @@ -15,5 +15,7 @@ BASE_NAMESPACE = "http://ld.iri-research.org/ontology/categorisation" CATEGORY_NAMESPACE = Namespace("http://ld.iri-research.org/ontology/categorisation/category#") + CELERY_IGNORE_RESULT = False CELERY_TASK_SERIALIZER = 'json' CELERY_ACCEPT_CONTENT = ['json', 'msgpack', 'yaml'] + CELERY_DISABLE_RATE_LIMITS = True diff -r 447bac7821e6 -r 59450d864881 src/catedit/static/css/style.css --- a/src/catedit/static/css/style.css Fri Apr 10 17:30:19 2015 +0200 +++ b/src/catedit/static/css/style.css Tue Apr 14 12:31:07 2015 +0200 @@ -81,3 +81,15 @@ width: 100%; height: 60px; } + + +#task_message { + position: absolute; + top: 70px; + right: 10px; + white-space: nowrap; +} + +#task_message span { + margin-right: 15px; +} diff -r 447bac7821e6 -r 59450d864881 src/catedit/static/js/check_tasks.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/catedit/static/js/check_tasks.js Tue Apr 14 12:31:07 2015 +0200 @@ -0,0 +1,56 @@ +// -*- coding: utf-8 -*- +/*! + * + */ +"use strict"; + +function setTasksMessage(running_tasks_nb) { + var message; + var klass; + + console.log('running_tasks_nb : ', running_tasks_nb); + + if(running_tasks_nb === 0) { + message = 'Soumission terminée. '; + klass = 'alert-success'; + } + else if(running_tasks_nb === 1) { + message = '1 soummission en cour.'; + klass = 'alert-info'; + } + else { + message = running_tasks_nb.toString() + ' soumissions en cour.' + klass = 'alert-info'; + } + + $('#task_indicator').html(message); + //TODO: check something mor efficient + $('#task_message').removeClass('alert-info alert-success').addClass(klass); + if(!$('#task_message').data('closed')) { + $('#task_message').removeClass('hide'); + } + +} + + +function checkTasks(endpoint_url) { + $.get(endpoint_url).done(function(data) { + + console.log("check tasks", data); + setTasksMessage(parseInt(data.running_tasks_nb)); + + }); +} + + +$(function() { + + setTasksMessage(running_tasks_nb); + setInterval(function() { + checkTasks(check_tasks_url); + }, 5000); + + $('#task_message a.close').click(function(e) { + $(e.target).data('closed', 'true'); + }); +}); diff -r 447bac7821e6 -r 59450d864881 src/catedit/tasks.py --- a/src/catedit/tasks.py Fri Apr 10 17:30:19 2015 +0200 +++ b/src/catedit/tasks.py Tue Apr 14 12:31:07 2015 +0200 @@ -33,9 +33,9 @@ modified_cat_dict=modified_categories, message=message ) - requests.get(app.config['BASE_URL']+"/cache-clear-after-task") - -@app.route('/cache-clear-after-task', methods=["GET"]) -def cache_clear_endpoint(): - cache.clear() - return ('', 204) + r = requests.post(app.config['BASE_URL']+"/meta/cache-clear") + try: + r.raise_for_status() + except: + logger.exception("Error when clearing cache.") + pass diff -r 447bac7821e6 -r 59450d864881 src/catedit/templates/categories/submit.html --- a/src/catedit/templates/categories/submit.html Fri Apr 10 17:30:19 2015 +0200 +++ b/src/catedit/templates/categories/submit.html Tue Apr 14 12:31:07 2015 +0200 @@ -7,7 +7,6 @@ {% block title %}{{current_repository}}: Soumission{% endblock title %} {% block head %} {{ super() }} - @@ -50,7 +49,7 @@ {% endif %}

-

Etat de l'ensemble de catégories +

Etat de l'ensemble de catégories @@ -66,7 +65,7 @@
  • Soumettre tous mes changements:
  • - {% endif %} + {% endif %} {% if session["modified_categories"][current_repository] or session["deleted_categories"][current_repository] %}
  • Supprimer tous mes changements: diff -r 447bac7821e6 -r 59450d864881 src/catedit/templates/layout.html --- a/src/catedit/templates/layout.html Fri Apr 10 17:30:19 2015 +0200 +++ b/src/catedit/templates/layout.html Tue Apr 14 12:31:07 2015 +0200 @@ -8,6 +8,15 @@ {% block title %}{% endblock title %} + + {% if current_repository and session.get('tasks',{}).get(current_repository,[]) and running_tasks_nb %} + + + + {% endif %} {% endblock head %} @@ -30,10 +39,10 @@
  • Accueil
  • {% endblock navbar_items %} - +

    {% if session["user_logged"] %}