# HG changeset patch # User Nicolas DURAND # Date 1420477435 -3600 # Node ID 0ba28595fd4deb7650e34ed513dbbf79bbd20244 # Parent b1b002c5ff60a7443c02413ae8191ccdbd7f914a Refactoring: change lists are now dicts + template inheritance for app pages + added debug messages with remaining github request count after each github api request diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/models.py --- a/src/catedit/models.py Sat Jan 03 00:15:51 2015 +0100 +++ b/src/catedit/models.py Mon Jan 05 18:03:55 2015 +0100 @@ -177,7 +177,7 @@ deleted categories and save the changes using the persistence method * delete_category will delete a single category from its id """ - def __init__(self, persistence_method, repository=""): + def __init__(self, persistence_method): """ persistence_method is a class that must have 4 methods: @@ -202,9 +202,9 @@ return cat def save_changes(self, - deleted_cat_list=[], - modified_cat_list=[], - message=None): + deleted_cat_dict=None, + modified_cat_dict=None, + message=""): """ Saves all changes to categories @@ -216,12 +216,16 @@ {"name": category_id, "content": category turtle serialization} * message is used as commit message when applicable (github) """ + if modified_cat_dict is None: + modified_cat_dict = {} + if deleted_cat_dict is None: + deleted_cat_dict = {} logger.debug("Calling persistance save method - deleted list is " - + str(deleted_cat_list) + + str(deleted_cat_dict) + " and modified list is " - + str(modified_cat_list)) - self.persistence.save(deletion_list = deleted_cat_list, - modification_list = modified_cat_list, + + str(modified_cat_dict)) + self.persistence.save(deletion_dict=deleted_cat_dict, + modification_dict=modified_cat_dict, message=message) def delete_category(self, deleted_cat_id, message=None): @@ -235,10 +239,11 @@ references to deleted category. This is handled in the api as such operations apply to the intermediary persistence (changeset) """ + if message is None: + message = "" self.persistence.delete(name=deleted_cat_id, message=message) # Now we must clean up the categories that reference the deleted cat - def list_categories(self): """ Lists all categories available diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/persistence.py --- a/src/catedit/persistence.py Sat Jan 03 00:15:51 2015 +0100 +++ b/src/catedit/persistence.py Mon Jan 05 18:03:55 2015 +0100 @@ -32,14 +32,6 @@ return @abstractmethod - def submit_changes(self, **kwargs): - """ - Abstract - Submit all saved objects, only useful if persistence - method can submit a changeset - """ - return - - @abstractmethod def save(self, **kwargs): """ Abstract - Saves object @@ -84,11 +76,6 @@ """ return False - def submit_changes(self, **kwargs): - """ - As each modification is submitted, this is where we save to a file - """ - def save(self, **kwargs): """ Saves to a file @@ -160,12 +147,14 @@ Expected kwargs is: * message: the commit message to document the changes - * deletion_list : the list of files to delete, list of dicts, each - one of the format: - {"name": name_of_the_file} - * modification_list: the list of the files to change, list of - dicts, each one of the format: - {"name": name_of_the_file, "content": content_of_the_file} + * deletion_dict : a dict where the keys are the name of the files + to delete, from the category repository (defined in + config["CATEGORIES_PATH"]), currently value is a fixed + string + {cat_id: "deleted"} + * modification_dict: a dict where they keys are the name of the + files that changed and the values are the contents of said files + {name_of_the_file: content_of_the_file} IMPORTANT: To save to a file Github, we have to use Git internal mechanics: @@ -193,8 +182,8 @@ tree """ - deletion_list = kwargs["deletion_list"] - modification_list = kwargs["modification_list"] + deletion_dict = kwargs["deletion_dict"] + modification_dict = kwargs["modification_dict"] # point 1 try: @@ -258,14 +247,14 @@ # First we loop over the existing elements to spot which are modified # and which are untouched and create new blobs when needed for element in last_commit_tree["tree"]: - logger.debug(element) + # logger.debug(element) if element["type"] == "blob": # test if element is in deleted categories, if it is, # no point doing anything, the file won't be in the new tree if not( element["path"] in [ - (app.config["CATEGORIES_PATH"] + category["name"]) - for category in deletion_list + (app.config["CATEGORIES_PATH"] + cat_name) + for cat_name in deletion_dict.keys() ] ): @@ -276,18 +265,19 @@ # test if element is in modified categories if ( element["path"] in [ - (app.config["CATEGORIES_PATH"] + category["name"]) - for category in modification_list + (app.config["CATEGORIES_PATH"] + cat_name) + for cat_name in modification_dict.keys() ] ): # find element in modified categories - for category in modification_list: + for (cat_name, cat_content) \ + in modification_dict.items(): if element["path"] == ( - app.config["CATEGORIES_PATH"] + category["name"] + app.config["CATEGORIES_PATH"] + cat_name ): # 4-1 for modified files, creating a new blob new_blob_data = { - "content": category["content"], + "content": cat_content, "encoding": "utf-8" } try: @@ -307,7 +297,9 @@ + str(new_blob_data) ) logger.debug(ghe.response.text) - logger.debug(str(github.get("rate_limit")["resources"])) + logger.debug(str( + github.get("rate_limit")["resources"] + )) # this means element is an untouched file so we just get # its sha @@ -320,16 +312,16 @@ logger.debug(str(new_tree_data["tree"])) # Now we loop over modified categories to find the ones that don't # exist yet in the last commit tree in order to create blobs for them - for category in modification_list: - logger.debug(app.config["CATEGORIES_PATH"]+category["name"] + for (cat_name, cat_content) in modification_dict.items(): + logger.debug(app.config["CATEGORIES_PATH"]+cat_content + " should not be in " + str([elt["path"] for elt in last_commit_tree["tree"]])) - if (app.config["CATEGORIES_PATH"] + category["name"] not in - [file["path"] for file in last_commit_tree["tree"]]): + if (app.config["CATEGORIES_PATH"] + cat_name not in + [elt["path"] for elt in last_commit_tree["tree"]]): # 4-1 for added files, creating a new blob - new_blob_data = {"content": category["content"], + new_blob_data = {"content": cat_content, "encoding": "utf-8"} try: new_blob = github.post( @@ -348,7 +340,7 @@ logger.debug(ghe.response.text) logger.debug(str(github.get("rate_limit")["resources"])) new_tree_data["tree"].append({ - "path": app.config["CATEGORIES_PATH"] + category["name"], + "path": app.config["CATEGORIES_PATH"] + cat_name, "mode": "100644", "type": "blob", "sha": new_blob["sha"] diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/resources.py --- a/src/catedit/resources.py Sat Jan 03 00:15:51 2015 +0100 +++ b/src/catedit/resources.py Mon Jan 05 18:03:55 2015 +0100 @@ -1,5 +1,5 @@ """ -api.py: +resources.py: contains the api that links the views (views.py) to the model (models.py) and its persistence method (persistence.py). As it only trades rdf graphs serializations strings, it isn't bound to one specific view @@ -7,14 +7,12 @@ from rdflib import Graph -from flask.ext.cache import Cache from flask.ext.restful import Resource, reqparse from flask import request, session from catedit import app, cache from catedit.models import Category, CategoryManager import catedit.persistence from io import StringIO -import logging logger = app.logger @@ -24,7 +22,6 @@ cat_parser.add_argument('commit_message', type=str) cat_parser.add_argument('property_predicate', type=str, action="append") cat_parser.add_argument('property_object', type=str, action="append") -cat_parser.add_argument('delete_message', type=str) class CategoryAPI(Resource): @@ -68,15 +65,19 @@ )(repository=repository), ) args = cat_parser.parse_args() - if (cat_id is None): - if (cat_manager_instance.persistence.session_compliant is True): + if cat_id is None: + if cat_manager_instance.persistence.session_compliant is True: logger.debug("Submitting - deleted categories are:" - + str(session.get("deleted_categories", {}).get(repository, [])) + + str(session.get("deleted_categories", {}) + .get(repository, {})) + " and modified categories are:" - + str(session.get("modified_categories", {}).get(repository, []))) + + str(session.get("modified_categories", {}) + .get(repository, {}))) cat_manager_instance.save_changes( - deleted_cat_list = session.get("deleted_categories", {}).get(repository, []), - modified_cat_list = session.get("modified_categories", {}).get(repository, []), + deleted_cat_dict=session.get("deleted_categories", {}) + .get(repository, {}), + modified_cat_dict=session.get("modified_categories", {}) + .get(repository, {}), message=args["commit_message"] ) else: @@ -103,16 +104,16 @@ logger.debug(new_property_list) # is the edition occuring on an already modified category? - if cat_id in [category["name"] for category - in session.get("modified_categories", {}).get(repository, [])]: - for element in session.get("modified_categories", {}).get(repository, []): - if element["name"] == cat_id: - cat_graph = Graph() - cat_graph.parse( - source=StringIO(element["content"]), - format="turtle" - ) - cat = Category(graph=cat_graph) + if cat_id in session.get("modified_categories", {}) \ + .get(repository, {}).keys(): + cat_graph = Graph() + cat_graph.parse( + source=StringIO(session["modified_categories"] + [repository] + [cat_id]), + format="turtle" + ) + cat = Category(graph=cat_graph) else: cat = cat_manager_instance.load_category(cat_id) @@ -120,22 +121,17 @@ new_label=args["label"], new_other_properties=new_property_list) - session["modified_categories"][repository][:] = [ - elt for elt in session.get("modified_categories", {}).get(repository, []) - if elt["name"] != cat.cat_id - ] - session["modified_categories"][repository].append( - {"name": cat.cat_id, - "content": str( - cat.cat_graph.serialize(format="turtle"), "utf-8" - )} + session["modified_categories"][repository][cat.cat_id] = str( + cat.cat_graph.serialize(format="turtle"), "utf-8" ) # Now we must clean the deleted categories list in case the # modified category was deleted before being edited - for element in session.get("deleted_categories", {}).get(repository, []): - if element["name"] == cat.cat_id: - session["deleted_categories"][repository].remove(element) + session["deleted_categories"][repository] = { + cat_name: cat_content for cat_name, cat_content + in session["deleted_categories"][repository].items() + if cat_name != cat.cat_id + } logger.debug("put id: "+cat.cat_id) cache.clear() @@ -167,16 +163,10 @@ description=args["description"], other_properties=property_list) - session["modified_categories"][repository][:] = [ - elt for elt in session.get("modified_categories", {}).get(repository, []) - if elt["name"] != cat.cat_id - ] - session["modified_categories"][repository].append( - {"name": cat.cat_id, - "content": str( + if cat.cat_id not in session["modified_categories"][repository].keys(): + session["modified_categories"][repository][cat.cat_id] = str( cat.cat_graph.serialize(format="turtle"), "utf-8" - )} - ) + ) logger.debug("post id: "+cat.cat_id) cache.clear() @@ -187,20 +177,38 @@ API to delete the category of id cat_id or restore it from the deletion list """ - if (deleted_cat_id in [ - element["name"] for element in session.get("deleted_categories", {}).get(repository, []) - ]): - session["deleted_categories"][repository].remove({"name": deleted_cat_id}) + # if cat_id is already in deleted categories, we restore it + if deleted_cat_id in session["deleted_categories"][repository].keys(): + session["deleted_categories"][repository] = { + cat_name: cat_content for cat_name, cat_content + in session["deleted_categories"][repository].items() + if cat_name != deleted_cat_id + } # warning, not safe if 2 files share the same name (or category id) # but that shouldn't happen else: - session["deleted_categories"][repository].append({"name": deleted_cat_id}) + session["deleted_categories"] \ + [repository] \ + [deleted_cat_id] = "deleted" + # Maybe we can store something more useful in there, such as + # category content when deleted to restore last edit? + # It would be nice to have symetry between modified and + # deleted dicts + # now we must clean the modified categories list in case the # deleted category was modified before - for element in session.get("modified_categories", {}).get(repository, []): - if element["name"] == deleted_cat_id: - session["modified_categories"][repository].remove(element) - + session["modified_categories"][repository] = { + cat_name: cat_content for cat_name, cat_content + in session["modified_categories"][repository].items() + if cat_name != deleted_cat_id + } + logger.debug(str( + { + cat_name: cat_content for cat_name, cat_content + in session["modified_categories"][repository].items() + if cat_name != deleted_cat_id + } + )) # Now we also have to clean up categories that reference the # deleted category cat_manager_instance = CategoryManager( @@ -211,15 +219,18 @@ ) cat_list = cat_manager_instance.list_categories() # first we edit what was already modified before the deletion - logger.debug(session["modified_categories"][repository]) - element_list = list(session.get("modified_categories", {}).get(repository, [])) - if deleted_cat_id in [element["name"] for - element in session.get("deleted_categories", {}).get(repository, [])]: - for element in element_list: + logger.debug(session.get("modified_categories", {}) + .get(repository, {})) + if deleted_cat_id in session["deleted_categories"] \ + [repository].keys(): + for element in session.get("modified_categories", {}) \ + .get(repository, {}).keys(): logger.debug(str(element)) modified_cat_graph = Graph() modified_cat_graph.parse( - source=StringIO(element["content"]), + source=StringIO(session["modified_categories"] + [repository] + [element]), format="turtle" ) modified_cat = Category(graph=modified_cat_graph) @@ -228,9 +239,9 @@ new_property_list = [] for (predicate, obj) in modified_cat.properties: if not ( - (app.config["PROPERTY_LIST"] - [predicate] - ["object_type"] == "uriref-category") + app.config["PROPERTY_LIST"] + [predicate] + ["object_type"] == "uriref-category" and (obj == (app.config["CATEGORY_NAMESPACE"] + deleted_cat_id)) @@ -242,39 +253,35 @@ modified_cat.edit_category( new_other_properties=new_property_list ) - session["modified_categories"][repository][:] = [ - elt for elt in session.get( - "modified_categories", [] - ) - if elt["name"] != modified_cat.cat_id - ] - session["modified_categories"][repository].append( - {"name": modified_cat.cat_id, - "content": str( - modified_cat.cat_graph - .serialize(format="turtle"), - "utf-8" - )} + session["modified_categories"] \ + [repository] \ + [modified_cat.cat_id] = str( + modified_cat.cat_graph + .serialize(format="turtle"), + "utf-8" ) + # now we check if an unmodified category reference the deleted # category for cat in cat_list: - if cat.cat_id not in [ - element["name"] for element in - session.get("modified_categories", {}).get(repository, []) - ] and cat.cat_id not in [ - element["name"] for element in - session.get("deleted_categories", {}).get(repository, []) - ]: + if (cat.cat_id not in ( + list(session["modified_categories"] + [repository].keys()) + + list(session["deleted_categories"] + [repository].keys()) + )): new_property_list = [] for (predicate, obj) in cat.properties: if not ( - (app.config["PROPERTY_LIST"] - [predicate] - ["object_type"] == "uriref-category") - and - (obj == (app.config["CATEGORY_NAMESPACE"] + - deleted_cat_id)) + app.config["PROPERTY_LIST"] + [predicate] + ["object_type"] + == "uriref-category" + and ( + obj == + app.config["CATEGORY_NAMESPACE"] + + deleted_cat_id + ) ): new_property_list.append((predicate, obj)) @@ -283,32 +290,28 @@ cat.edit_category( new_other_properties=new_property_list ) - session["modified_categories"][repository][:] = [ - elt for elt in session.get( - "modified_categories", {} - ).get(repository, []) - if elt["name"] != cat.cat_id - ] - session["modified_categories"][repository].append( - {"name": cat.cat_id, - "content": str( - cat.cat_graph.serialize(format="turtle"), - "utf-8" - )} + session["modified_categories"] \ + [repository] \ + [cat.cat_id] = str( + cat.cat_graph.serialize(format="turtle"), + "utf-8" ) logger.debug("delete id: " + deleted_cat_id) cache.clear() return 204 + class CategoryChangesAPI(Resource): """ API for getting and deleting category changes, returns a dict when succesful if category is a modified one, returns only the cat_id if it is a deleted one - All changes and deletions are saved in session["modified_categories"][repository] - and session["deleted_categories"][repository] + All changes and deletions are saved in + session["modified_categories"][repository] and + session["deleted_categories"][repository] under the format: + {changed_cat_id: content_of_changed_cat} """ def get(self, repository, modified_cat_id=None): """ @@ -316,21 +319,36 @@ """ logger.debug(modified_cat_id) logger.debug(str(session.get("modified_categories", {}))) - logger.debug(str(session.get("modified_categories", {}).get(repository, []))) + logger.debug(str(session.get("modified_categories", {}) + .get(repository, {}))) if modified_cat_id is None: return { - "modified_categories": session.get("modified_categories", {}).get(repository, []), - "deleted_categories": session.get("deleted_categories", {}).get(repository, []) + "modified_categories": session.get("modified_categories", {}) + .get(repository, {}), + "deleted_categories": session.get("deleted_categories", {}) + .get(repository, {}) }, 201 else: - for category in session.get("modified_categories", {}).get(repository, []): - logger.debug(category) - if category["name"] == modified_cat_id: - return { "type": "modified", "category": category }, 201 - for category in session.get("deleted_categories", {}).get(repository, []): - logger.debug(category) - if category["name"] == modified_cat_id: - return { "type": "deleted", "category": category }, 201 + if modified_cat_id in session.get("modified_categories", {}) \ + .get(repository, {}): + return { + "type": "modified", + "category": { + modified_cat_id: session["modified_categories"] + [repository] + [modified_cat_id] + } + }, 201 + if modified_cat_id in session.get("deleted_categories", {}) \ + .get(repository, {}): + return { + "type": "deleted", + "category": { + modified_cat_id: session["deleted_categories"] + [repository] + [modified_cat_id] + } + }, 201 return 404 def delete(self, repository, modified_cat_id=None): @@ -339,19 +357,17 @@ is None, delete the whole changelist """ if modified_cat_id is not None: - session["modified_categories"][repository][:] = [ - elt for elt in session.get( - "modified_categories", {} - ).get(repository, []) - if elt["name"] != modified_cat_id - ] - session["deleted_categories"][repository][:] = [ - elt for elt in session.get( - "modified_categories", {} - ).get(repository, []) - if elt["name"] != modified_cat_id - ] + session["modified_categories"][repository] = { + cat_name: cat_content for cat_name, cat_content + in session["modified_categories"][repository].items() + if cat_name != modified_cat_id + } + session["deleted_categories"][repository] = { + cat_name: cat_content for cat_name, cat_content + in session["deleted_categories"][repository].items() + if cat_name != modified_cat_id + } else: - session["modified_categories"][repository] = [] - session["deleted_categories"][repository] = [] + session["modified_categories"][repository] = {} + session["deleted_categories"][repository] = {} return 204 diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/static/css/style.css --- a/src/catedit/static/css/style.css Sat Jan 03 00:15:51 2015 +0100 +++ b/src/catedit/static/css/style.css Mon Jan 05 18:03:55 2015 +0100 @@ -37,7 +37,7 @@ float:right; } -.navbar-decorative,.navbar-decorative:hover +ul.nav a.navbar-decorative { - color:blue; + color: white !important; } diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/static/img/catedit_brand.png Binary file src/catedit/static/img/catedit_brand.png has changed diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/templates/catbase.html --- a/src/catedit/templates/catbase.html Sat Jan 03 00:15:51 2015 +0100 +++ b/src/catedit/templates/catbase.html Mon Jan 05 18:03:55 2015 +0100 @@ -0,0 +1,55 @@ + + + + {% block head %} + + + + {% block title %}{% endblock title %} + + + {% endblock head %} + + + +
+ {% block page_content %} + {% endblock page_content %} +
+ diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/templates/cateditor.html --- a/src/catedit/templates/cateditor.html Sat Jan 03 00:15:51 2015 +0100 +++ b/src/catedit/templates/cateditor.html Mon Jan 05 18:03:55 2015 +0100 @@ -1,170 +1,12 @@ +{% extends "catbase.html" %} {% if not session["user_logged"] or not session["user_can_edit"] %} {% set readonly="readonly" %} {% else %} {% set readonly=False %} {% endif %} - - - - - - - Editeur de catégorie - - - - - -
-

CatEdit - {{current_repository}}

- {% if session["user_logged"] and not session["user_can_edit"] %} - - {% endif %} - {% if not session["user_logged"] %} - {% endif %} - {% if form.label.errors or form.description.errors %} -
- - - Erreur: - - Vous n'avez pas rempli certains champs obligatoires. -
- {% endif %} -

{% if cat_id: %} Edition : Catégorie existante{% else %}Création : Nouvelle catégorie{% endif %}

- {% if readonly %}
{% endif %} -
- {{ form.hidden_tag() }} - {% if form.label.errors %} - {% set label_placeholder="Champ obligatoire" %} - {% endif %} - {% if form.description.errors %} - {% set description_placeholder="Champ obligatoire" %} - {% endif %} - {{ form.label.label }}
{{ form.label(size=40, class="form-control", readonly=readonly, placeholder=label_placeholder) }}
- {{ form.description.label }}
{{ form.description(size=150, class="form-control", readonly=readonly, placeholder=description_placeholder) }}
- -
- - - - - -
- -
-
- Annuler -
- {% if readonly %}
{% endif %} +{% block title %} {{ current_repository}}: Editeur {% endblock title %} +{% block head %} + {{ super() }} {% if cat_id %} {% endif %} - - +{% endblock head %} +{% block navbar_items %} + {{ super() }} + {% if session.get("user_logged", None) %} +
  • >
  • +
  • Atelier
  • +
  • >
  • +
  • Editeur
  • + {% endif %} +{% endblock navbar_items%} +{% block repo_list %} + {{ super() }} +{% endblock repo_list %} +{% block page_content %} +

    CatEdit - {{current_repository}}

    +{% if session["user_logged"] and not session["user_can_edit"] %} + +{% endif %} +{% if not session["user_logged"] %} + {% endif %} +{% if form.label.errors or form.description.errors %} +
    + + + Erreur: + + Vous n'avez pas rempli certains champs obligatoires. +
    +{% endif %} +

    {% if cat_id: %} Edition : Catégorie existante{% else %}Création : Nouvelle catégorie{% endif %}

    + {% if readonly %}
    {% endif %} +
    + {{ form.hidden_tag() }} + {% if form.label.errors %} + {% set label_placeholder="Champ obligatoire" %} + {% endif %} + {% if form.description.errors %} + {% set description_placeholder="Champ obligatoire" %} + {% endif %} + {{ form.label.label }}
    {{ form.label(size=40, class="form-control", readonly=readonly, placeholder=label_placeholder) }}
    + {{ form.description.label }}
    {{ form.description(size=150, class="form-control", readonly=readonly, placeholder=description_placeholder) }}
    + +
    + + + + + +
    + +
    +
    +
    +
    + + + {% set property_count=1 %} + {% for (predicate, object) in cat_properties %} + + {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-category" %} + {% for cat in cat_list %} + {% if object == config["CATEGORY_NAMESPACE"]+cat.cat_id %} + {% if cat.cat_id not in deleted_cat_list %} + + + + + + {% endif %} + {% endif %} + {% endfor %} + {% else %} + + + + + + {% endif %} + {% set property_count=property_count+1 %} + + {% endfor %} + +
    + {{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }} + + {{ cat.cat_label }} + + + + {{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }} + + {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %} + {{ object }} + {% else %} + {{ object }} + {% endif %} + + +
    +
    +
    +


    + + Annuler +
    + {% if readonly %}
    {% endif %} +{% endblock page_content %} diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/templates/catindex.html --- a/src/catedit/templates/catindex.html Sat Jan 03 00:15:51 2015 +0100 +++ b/src/catedit/templates/catindex.html Mon Jan 05 18:03:55 2015 +0100 @@ -1,117 +1,73 @@ +{% extends "catbase.html" %} {% if not session["user_logged"] or not session["user_can_edit"] %} {% set readonly="readonly" %} {% else %} {% set readonly=False %} {% endif %} - - - - - - - Page d'accueil - - - - - - - -
    -

    CatEdit: Editeur de Catégories

    -

    Mode d'emploi

    -
    -

    - CatEdit est un outil permettant de créer et d'éditer des catégories. - Vous aurez besoin d'un compte Github pour utiliser CatEdit: - s'inscrire sur Github -

    -

    - Une fois authentifié, choisissez un ensemble de catégorie dans la liste se trouvant - dans la barre de navigation pour être redirigé vers l'atelier correspondant. - Vous pourrez y trouver la liste des catégories existantes pour cet ensemble, - présentée dans un tableau qui initialement ne comprend que les catégories de l'état courant. -

    -

    - L'état courant de l'ensemble de catégorie est la base à partir de laquelle - vous pourrez créer et éditer des catégories. Une catégorie consiste en un label, unique - et non-vide, une description, unique et non-vide et un nombre variable de propriétés. -

    -

    La liste de catégories

    -

    - A chaque fois que vous faites des modifications, elles sont stockées - de manière temporaire tant que vous restez authentifié. La liste de catégories - dans l'Atelier est mise à jour au fil de vos modifications selon un code couleur - vous permettant de visualiser vos changements. -

    -
      -
    • - Une ligne de tableau blanche représente une catégorie de l'état courant - que vous n'avez ni modifié ni supprimé. -
    • -
    • - Une ligne de tableau verte représente une catégorie que vous avez créée de zéro - et qui n'existait pas précédemment dans l'état courant. -
    • -
    • - Une ligne de tableau orange représente une catégorie qui existait - initialement et que vous avez modifié. -
    • -
    • - Une ligne de tableau rouge représente une catégorie de l'état courant que - vous avez supprimé. -
    • -
    -

    -

    - Pour que vos modifications soient permanentes et qu'elles deviennent le nouvel état courant - de l'ensemble de catégories, vous devez soumettre vos modifications en suivant le lien dans l'Atelier. - Vous trouverez une page vous présentant l'état initial d'une part et vos changements d'autre part. -

    -

    - Vous devez obligatoirement renseigner une explication de vos changements avant soumission. -

    -
    -
    - - +{% block title %}Page d'accueil{% endblock title %} +{% block head %} + {{ super() }} +{% endblock head %} +{% block navbar_items %} +
  • Page d'accueil
  • +{% endblock navbar_items %} +{% block repo_list %} + + {{ super() }} +{% endblock repo_list %} +{% block page_content %} +

    CatEdit: Editeur de Catégories

    +

    Mode d'emploi

    +
    +

    + CatEdit est un outil permettant de créer et d'éditer des catégories. + Vous aurez besoin d'un compte Github pour utiliser CatEdit: + s'inscrire sur Github +

    +

    + Une fois authentifié, choisissez un ensemble de catégorie dans la liste se trouvant + dans la barre de navigation pour être redirigé vers l'atelier correspondant. + Vous pourrez y trouver la liste des catégories existantes pour cet ensemble, + présentée dans un tableau qui initialement ne comprend que les catégories de l'état courant. +

    +

    + L'état courant de l'ensemble de catégorie est la base à partir de laquelle + vous pourrez créer et éditer des catégories. Une catégorie consiste en un label, unique + et non-vide, une description, unique et non-vide et un nombre variable de propriétés. +

    +

    La liste de catégories

    +

    + A chaque fois que vous faites des modifications, elles sont stockées + de manière temporaire tant que vous restez authentifié. La liste de catégories + dans l'Atelier est mise à jour au fil de vos modifications selon un code couleur + vous permettant de visualiser vos changements. +

    +
      +
    • + Une ligne de tableau blanche représente une catégorie de l'état courant + que vous n'avez ni modifié ni supprimé. +
    • +
    • + Une ligne de tableau verte représente une catégorie que vous avez créée de zéro + et qui n'existait pas précédemment dans l'état courant. +
    • +
    • + Une ligne de tableau orange représente une catégorie qui existait + initialement et que vous avez modifié. +
    • +
    • + Une ligne de tableau rouge représente une catégorie de l'état courant que + vous avez supprimé. +
    • +
    +

    +

    + Pour que vos modifications soient permanentes et qu'elles deviennent le nouvel état courant + de l'ensemble de catégories, vous devez soumettre vos modifications en suivant le lien dans l'Atelier. + Vous trouverez une page vous présentant l'état initial d'une part et vos changements d'autre part. +

    +

    + Vous devez obligatoirement renseigner une explication de vos changements avant soumission. +

    +
    +{% endblock page_content %} diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/templates/catmodifs.html --- a/src/catedit/templates/catmodifs.html Sat Jan 03 00:15:51 2015 +0100 +++ b/src/catedit/templates/catmodifs.html Mon Jan 05 18:03:55 2015 +0100 @@ -1,358 +1,325 @@ +{% extends "catbase.html" %} {% if not session["user_logged"] or not session["user_can_edit"] %} {% set readonly="readonly" %} {% else %} {% set readonly=False %} {% endif %} - - - - - - - Soumettre mes changements - - - - + - - - -
    -

    CatEdit - {{current_repository}}

    -

    Catégories existantes

    - - - - - - - - - {% if not session["user_logged"] %} + {% endfor %} + }); + +{% endblock head %} +{% block navbar_items %} + {{ super() }} + {% if session.get("user_logged", None) %} +
  • >
  • +
  • Atelier
  • +
  • >
  • +
  • Soumission
  • + {% endif %} +{% endblock navbar_items %} +{% block repo_list %} + {{ super() }} +{% endblock repo_list %} +{% block page_content %} +

    CatEdit - {{current_repository}}

    +

    Catégories existantes

    +
    Nom de la catégorieDescription de la catégorie
    + + + + + + + + {% if not session["user_logged"] %} + + + + {% else %} + {% if cat_list|length == 0 %} - + - {% else %} - {% if cat_list|length == 0 %} + {% else %} + {% for cat in cat_list %} + + + + + {% if cat.cat_id not in deleted_cat_namelist and cat.cat_id not in modified_cat_namelist %} + + + {% else %} + + {% endif %} + - - - {% else %} - {% for cat in cat_list %} - - - - - {% if cat.cat_id not in deleted_cat_namelist and cat.cat_id not in modified_cat_namelist %} - - + + {% for (predicate, object) in cat.cat_properties %} +
    {{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}
    +
    + {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-category" %} + {% for cat in cat_list %} + {% if object == config["CATEGORY_NAMESPACE"]+cat.cat_id %} + {{ cat.cat_label }} + {% endif %} + {% endfor %} + {% elif config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %} + {{ object }} + {% else %} + {{ object }} + {% endif %} +
    + {% endfor %} {% endif %} - - - - - {% endfor %} - {% endif %} - {% endif %} - -
    Nom de la catégorieDescription de la catégorie
    + + Attention: + Veuillez vous identifier pour visualiser les catégories +
    - - Attention: - Veuillez vous identifier pour visualiser les catégories - Aucune catégorie n'a été créée pour l'instant. {% if not readonly %}Créer une catégorie{% endif %}
    {{ cat.cat_label }}{{ cat.cat_description}} + + + + + +
    +
    + +
    +
    +
    +
    +
    Aucune catégorie n'a été créée pour l'instant. {% if not readonly %}Créer une catégorie{% endif %}
    {{ cat.cat_label }}{{ cat.cat_description}} - - - - - -
    -
    - -
    -
    -
    -
    +
    +
    + {% if cat.cat_properties|length == 0 %}
    Aucune autre propriété
    {% else %} -
    -
    -
    -
    - {% if cat.cat_properties|length == 0 %}
    Aucune autre propriété
    - {% else %} - {% for (predicate, object) in cat.cat_properties %} -
    {{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}
    -
    - {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-category" %} - {% for cat in cat_list %} - {% if object == config["CATEGORY_NAMESPACE"]+cat.cat_id %} - {{ cat.cat_label }} - {% endif %} - {% endfor %} - {% elif config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %} - {{ object }} - {% else %} - {{ object }} - {% endif %} -
    - {% endfor %} - {% endif %} -
    -
    -
    + +
    + + + {% endfor %} + {% endif %} + {% endif %} + + -

    Mes modifications

    - - - - - - - - - {% if not session["user_logged"] %} +

    Mes modifications

    +
    Nom de la catégorieDescription de la catégorie
    + + + + + + + + {% if not session["user_logged"] %} + + + + {% else %} + + + + {% if created_cat_list|length == 0 %} - + - {% else %} + {% else %} + {% for cat in created_cat_list %} - + + - {% if created_cat_list|length == 0 %} - - - - {% else %} - {% for cat in created_cat_list %} - - - - - - - + - - {% endfor %} - {% endif %} + {% endfor %} + {% elif config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %} + {{ object }} + {% else %} + {{ object }} + {% endif %} + + {% endfor %} + {% endif %} + + +
    +
    +
    +
    +
    + Vous allez supprimer les changements faits sur cette catégorie. +
    + +
    +
    + +
    + + + {% endfor %} + {% endif %} + + + + {% if modified_cat_list|length == 0 %} + + + + {% else %} + {% for cat in modified_cat_list %} - + + - {% if modified_cat_list|length == 0 %} - - + + - {% else %} - {% for cat in modified_cat_list %} - - - + {% endfor %} + {% endif %} + + + + + {% if deleted_cat_namelist|length == 0 %} + + + + {% else %} + {% for deleted_cat in deleted_cat_namelist %} + {% for existing_cat in cat_list %} + {% if existing_cat.cat_id == deleted_cat %} + + + - - - - {% endfor %} - {% endif %} - - - - - {% if deleted_cat_namelist|length == 0 %} - - - - {% else %} - {% for deleted_cat in deleted_cat_namelist %} - {% for existing_cat in cat_list %} - {% if existing_cat.cat_id == deleted_cat %} - - - - - - {% endif %} - {% endfor %} - {% endfor %} - {% endif %} - {% endif %} - -
    Nom de la catégorieDescription de la catégorie
    + + Attention: + Veuillez vous identifier pour visualiser les modifications +
    + Catégories ajoutées +
    - - Attention: - Veuillez vous identifier pour visualiser les modifications - Aucune catégorie n'a été ajoutée pour l'instant.
    - Catégories ajoutées + {{ cat.cat_label }}{{ cat.cat_description}} + + +
    Aucune catégorie n'a été ajoutée pour l'instant.
    {{ cat.cat_label }}{{ cat.cat_description}} - - - -
    -
    -
    - {% if cat.cat_properties|length == 0 %}
    Aucune autre propriété
    - {% else %} - {% for (predicate, object) in cat.cat_properties %} -
    {{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}
    -
    - {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-category" %} - {% for cat in cat_list %} - {% if object == config["CATEGORY_NAMESPACE"]+cat.cat_id %} - {{ cat.cat_label }} - {% endif %} - {% endfor %} - {% elif config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %} - {{ object }} - {% else %} - {{ object }} +
    +
    +
    + {% if cat.cat_properties|length == 0 %}
    Aucune autre propriété
    + {% else %} + {% for (predicate, object) in cat.cat_properties %} +
    {{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}
    +
    + {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-category" %} + {% for cat in cat_list %} + {% if object == config["CATEGORY_NAMESPACE"]+cat.cat_id %} + {{ cat.cat_label }} {% endif %} -
    - {% endfor %} - {% endif %} -
    -
    -
    -
    -
    -
    -
    - Vous allez supprimer les changements faits sur cette catégorie. -
    - -
    -
    -
    -
    -
    + Catégories modifiées +
    Aucune catégorie n'a été modifiée pour l'instant.
    - Catégories modifiées + {{ cat.cat_label }}{{ cat.cat_description}} + + +
    Aucune catégorie n'a été modifiée pour l'instant.
    +
    +
    + {% if cat.cat_properties|length == 0 %}
    Aucune autre propriété
    + {% else %} + {% for (predicate, object) in cat.cat_properties %} +
    {{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}
    +
    + {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-category" %} + {% for cat in cat_list %} + {% if object == config["CATEGORY_NAMESPACE"]+cat.cat_id %} + {{ cat.cat_label }} + {% endif %} + {% endfor %} + {% elif config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %} + {{ object }} + {% else %} + {{ object }} + {% endif %} +
    + {% endfor %} + {% endif %} +
    +
    +
    +
    +
    +
    +
    + Vous allez supprimer les changements faits sur cette catégorie. +
    + +
    +
    +
    +
    +
    {{ cat.cat_label }}{{ cat.cat_description}}
    + Catégories supprimées +
    Aucune catégorie n'a été supprimée pour l'instant.
    {{ existing_cat.cat_label }}Cette catégorie va être supprimée quand vous soumettrez vos modifications. - - - +
    +
    + +
    +
    -
    -
    - {% if cat.cat_properties|length == 0 %}
    Aucune autre propriété
    - {% else %} - {% for (predicate, object) in cat.cat_properties %} -
    {{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}
    -
    - {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-category" %} - {% for cat in cat_list %} - {% if object == config["CATEGORY_NAMESPACE"]+cat.cat_id %} - {{ cat.cat_label }} - {% endif %} - {% endfor %} - {% elif config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %} - {{ object }} - {% else %} - {{ object }} - {% endif %} -
    - {% endfor %} - {% endif %} -
    -
    -
    -
    -
    -
    -
    - Vous allez supprimer les changements faits sur cette catégorie. -
    - -
    -
    -
    -
    -
    - Catégories supprimées -
    Aucune catégorie n'a été supprimée pour l'instant.
    {{ existing_cat.cat_label }}Cette catégorie va être supprimée quand vous soumettrez vos modifications. -
    -
    - -
    -
    -
    -

    Soumettre mes changements

    -
    -
    -
    - {{ commit_form.hidden_tag() }} -
    - {{ commit_form.commit_message.label }} - {{ commit_form.commit_message(size=40, class="form-control", readonly=readonly) }} -
    - - Retour -
    -

    -
    -
    - - + {% endif %} + {% endfor %} + {% endfor %} + {% endif %} + {% endif %} + + +

    Soumettre mes changements

    +
    +
    +
    + {{ commit_form.hidden_tag() }} +
    + {{ commit_form.commit_message.label }} + {{ commit_form.commit_message(size=40, class="form-control", readonly=readonly) }} +
    + + Retour +
    +

    +
    +{% endblock page_content %} diff -r b1b002c5ff60 -r 0ba28595fd4d src/catedit/templates/catrecap.html --- a/src/catedit/templates/catrecap.html Sat Jan 03 00:15:51 2015 +0100 +++ b/src/catedit/templates/catrecap.html Mon Jan 05 18:03:55 2015 +0100 @@ -1,199 +1,172 @@ +{% extends "catbase.html" %} +{% if not session["user_logged"] or not session["user_can_edit"] %} + {% set readonly="readonly" %} +{% else %} + {% set readonly=False %} +{% endif %} {% if not session["user_logged"] or not session["user_can_edit"] %} {% set readonly="readonly" %} {% else %} {% set readonly=False %} {% endif %} - - - - - - - Atelier - - - - - - - -
    -

    CatEdit - {{current_repository}}

    -

    Créer une catégorie :

    - {% if session["user_logged"] and not session["user_can_edit"] %} -