Refactoring: change lists are now dicts + template inheritance for app pages + added debug messages with remaining github request count after each github api request
--- 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
--- 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"]
--- 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
--- 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;
}
Binary file src/catedit/static/img/catedit_brand.png has changed
--- 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 @@
+<!DOCTYPE html>
+<html lang="fr">
+<head>
+ {% block head %}
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>{% block title %}{% endblock title %}</title>
+ <link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
+ <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
+ {% endblock head %}
+</head>
+<body>
+ <div class="navbar navbar-inverse" role="navigation">
+ <div class="container">
+ <div class="navbar-header">
+ <a class="navbar-brand" href="{{ url_for('cat_index') }}">
+ <img alt="Brand" src="{{ url_for('static', filename='img/catedit_brand.png') }}" class="navbar-img" width="32" height="32">
+ </a>
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ </div>
+ <div class="collapse navbar-collapse">
+ <ul class="nav navbar-nav">
+ {% block navbar_items %}
+ <li><a href="{{ url_for('cat_index') }}">Page d'accueil</a></li>
+ {% endblock navbar_items %}
+ </ul>
+ <div class="navbar-text navbar-right">
+ {% if not session.get("user_logged", None)%} Non authentifié - <a href="{{ url_for('github_login') }}" class="navbar-link">S'authentifier</a>
+ {% else %} Authentifié: {{ session["user_login"] }} - <a href="{{ url_for('logout') }}" class="navbar-link">Quitter</a>{% endif %}
+ </div>
+ {% if session["user_logged"] %}
+ <form class="navbar-form navbar-right">
+ <select class="form-control select-repo" name="navrepo" onchange="window.location.href=this.form.navrepo.options[this.form.navrepo.selectedIndex].value">
+ {% block repo_list %}
+ {% for repo in config["REPOSITORY_LIST"] %}
+ <option value="{{url_for('cat_recap', repository=repo)}}" {% if repo==current_repository %}selected="selected"{% endif %}>{{repo}}</option>
+ {% endfor %}
+ {% endblock repo_list %}
+ </select>
+ </form>
+ {% endif %}
+ </div>
+ </div>
+ </div>
+ <div class="container">
+ {% block page_content %}
+ {% endblock page_content %}
+ </div>
+</body>
--- 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 %}
-<!DOCTYPE html>
-<html lang="fr">
-<head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Editeur de catégorie</title>
- <link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
- <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
-</head>
-<body>
- <div class="navbar navbar-inverse" role="navigation">
- <div class="container">
- <div class="navbar-header">
- <a class="navbar-brand" href="{{ url_for('cat_index') }}">
- <img alt="Brand" src="{{ url_for('static', filename='img/catedit_brand.png') }}" class="navbar-img" width="32" height="32">
- </a>
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- </div>
- <div class="collapse navbar-collapse">
- <ul class="nav navbar-nav">
- <li><a href="{{ url_for('cat_index') }}">Page d'accueil</a></li>
- {% if session.get("user_logged", None) %}
- <li><a href="{{ url_for('cat_recap', repository=current_repository) }}">Atelier</a></li>
- {% endif %}
- <li class="active"><a>Editeur</a></li>
- </ul>
- <div class="navbar-text navbar-right">
- {% if not session.get("user_logged", None)%} Non authentifié - <a href="{{ url_for('github_login') }}" class="navbar-link">S'authentifier</a>
- {% else %} Authentifié: {{ session["user_login"] }} - <a href="{{ url_for('logout') }}" class="navbar-link">Quitter</a>{% endif %}
- </div>
- {% if session["user_logged"] %}
- <form class="navbar-form navbar-right">
- <select class="form-control select-repo" name="navrepo" onchange="window.location.href=this.form.navrepo.options[this.form.navrepo.selectedIndex].value">
- {% for repo in config["REPOSITORY_LIST"] %}
- <option value="{{url_for('cat_recap', repository=repo)}}" {% if repo==current_repository %}selected="selected"{% endif %}>{{repo}}</option>
- {% endfor %}
- </select>
- </form>
- {% endif %}
- </div>
- </div>
- </div>
- <div class="container">
- <h2> <b>CatEdit</b> - <small>{{current_repository}}</small></h2>
- {% if session["user_logged"] and not session["user_can_edit"] %}
- <div class="alert alert-warning" role="alert">
- <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
- <span class="sr-only">Attention:</span>
- Vous n'avez pas accès en écriture au repository contenant les catégories - Vous ne pourrez pas les modifier.
- </div>
- {% endif %}
- {% if not session["user_logged"] %}
- <div class="alert alert-warning" role="alert">
- <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
- <span class="sr-only">Attention:</span>
- Vous devez être authentifié pour modifier les catégories.
- </div> {% endif %}
- {% if form.label.errors or form.description.errors %}
- <div class="alert alert-danger">
- <strong>
- <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
- Erreur:
- </strong>
- Vous n'avez pas rempli certains champs obligatoires.
- </div>
- {% endif %}
- <h3>{% if cat_id: %} Edition : <small>Catégorie existante</small>{% else %}Création : <small>Nouvelle catégorie</small>{% endif %}</h3>
- {% if readonly %} <fieldset disabled> {% endif %}
- <form method="POST" action="{% if cat_id %}{{ url_for('cat_editor', cat_id=cat_id, repository=current_repository) }}{% else %}{{ url_for('cat_editor', repository=current_repository) }}{% endif %}" id="cat_form" role="form">
- {{ 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 }} <br> {{ form.label(size=40, class="form-control", readonly=readonly, placeholder=label_placeholder) }} <br>
- {{ form.description.label }} <br> {{ form.description(size=150, class="form-control", readonly=readonly, placeholder=description_placeholder) }} <br>
- <label>Propriétés </label>
- <div class="form-inline">
- <select id="property_selector" class="form-control" onChange="CatEditScripts.displayCorrespondingField();" {{readonly}}>
- <option label="property_type_default" selected>
- Liste des propriétés ...
- </option>
- {% for predicate in config["PROPERTY_LIST"] %}
- <option value='{{ predicate }}' label={{ config["PROPERTY_LIST"][predicate]["object_type"] }} >{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</option>
- {% endfor %}
- </select>
- <input type="text" id="literal-field" class="hidden form-control">
- <input type="text" id="uriref-link-field" placeholder="http://my-example.com" class="hidden form-control">
- <select class="hidden form-control" id="uriref-category-field">
- <option value="default" selected> Liste des catégories </option>
- {% for cat in cat_list %}
- <option value="{{ cat.cat_id }}"> {{ cat.cat_label }} </option>
- {% endfor %}
- </select>
- <input type="button" value="Ajouter propriété" onClick="CatEditScripts.addProperty('properties','property_table_body');" class="btn btn-default" {{ readonly }}>
- </div>
- <div class="alert alert-warning hidden" role="alert" id="uriref-category-field-text">
- </div>
- <div id="properties" class="row hidden">
- <div class="row">
- <div class="col-md-6">
- <br>
- <table id="property_table" class="table table-condensed">
- <tbody id="property_table_body">
- {% set property_count=1 %}
- {% for (predicate, object) in cat_properties %}
- <tr id="property_tr{{property_count}}">
- {% 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 %}
- <input type="hidden" id="property_predicate{{ property_count }}" name="property_predicate" value="{{predicate}}"/>
- <input type="hidden" id="property_object{{ property_count }}" name="property_object" value="{{cat.cat_id}}"/>
- <td id="predicate_td{{ property_count }}">
- <strong>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</strong>
- </td>
- <td id="object_td{{ property_count }}">
- {{ cat.cat_label }}
- </td>
- <td id="delete_button_td{{ property_count }}">
- <input type="button" id="property_delete_button{{ property_count }}" class="btn btn-default property-delete-button" onClick="CatEditScripts.removeProperty({{ property_count }}, 'properties')" value="Supprimer">
- </td>
- {% endif %}
- {% endif %}
- {% endfor %}
- {% else %}
- <input type="hidden" id="property_predicate{{ property_count }}" name="property_predicate" value="{{predicate}}"/>
- <input type="hidden" id="property_object{{ property_count }}" name="property_object" value="{{object}}"/>
- <td id="predicate_td{{ property_count }}">
- <strong>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</strong>
- </td>
- <td id="object_td{{ property_count }}">
- {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %}
- <a href="{{ object }}">{{ object }}</a>
- {% else %}
- {{ object }}
- {% endif %}
- </td>
- <td id="delete_button_td{{ property_count }}">
- <input type="button" id="property_delete_button{{ property_count }}" class="btn btn-default property-delete-button" onClick="CatEditScripts.removeProperty({{ property_count }}, 'properties')" value="Supprimer">
- </td>
- {% endif %}
- {% set property_count=property_count+1 %}
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
- </div>
- </div><br>
- <br><input type="submit" value="Sauvegarder" class="btn btn-default">
- <a href="{{ url_for('cat_recap', repository=current_repository)}}"class="btn btn-default">Annuler</a>
- </form>
- {% if readonly %} </fieldset> {% endif %}
+{% block title %} {{ current_repository}}: Editeur {% endblock title %}
+{% block head %}
+ {{ super() }}
<script src="{{ url_for('static', filename='js/property_functions.js') }}" language="Javascript" type="text/javascript"></script>
{% if cat_id %}
<script type=text/javascript>
@@ -172,5 +14,131 @@
CatEditScripts.initCreatedProperties({{cat_properties|length}});
</script>
{% endif %}
-</body>
-</html>
+{% endblock head %}
+{% block navbar_items %}
+ {{ super() }}
+ {% if session.get("user_logged", None) %}
+ <li><a class="navbar-decorative">></a></li>
+ <li><a href="{{ url_for('cat_recap', repository=current_repository) }}">Atelier</a></li>
+ <li><a class="navbar-decorative">></a></li>
+ <li class="active"><a>Editeur</a></li>
+ {% endif %}
+{% endblock navbar_items%}
+{% block repo_list %}
+ {{ super() }}
+{% endblock repo_list %}
+{% block page_content %}
+<h2> <b>CatEdit</b> - <small>{{current_repository}}</small></h2>
+{% if session["user_logged"] and not session["user_can_edit"] %}
+<div class="alert alert-warning" role="alert">
+ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
+ <span class="sr-only">Attention:</span>
+ Vous n'avez pas accès en écriture au repository contenant les catégories - Vous ne pourrez pas les modifier.
+</div>
+{% endif %}
+{% if not session["user_logged"] %}
+<div class="alert alert-warning" role="alert">
+ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
+ <span class="sr-only">Attention:</span>
+ Vous devez être authentifié pour modifier les catégories.
+</div> {% endif %}
+{% if form.label.errors or form.description.errors %}
+<div class="alert alert-danger">
+ <strong>
+ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
+ Erreur:
+ </strong>
+ Vous n'avez pas rempli certains champs obligatoires.
+</div>
+{% endif %}
+ <h3>{% if cat_id: %} Edition : <small>Catégorie existante</small>{% else %}Création : <small>Nouvelle catégorie</small>{% endif %}</h3>
+ {% if readonly %} <fieldset disabled> {% endif %}
+ <form method="POST" action="{% if cat_id %}{{ url_for('cat_editor', cat_id=cat_id, repository=current_repository) }}{% else %}{{ url_for('cat_editor', repository=current_repository) }}{% endif %}" id="cat_form" role="form">
+ {{ 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 }} <br> {{ form.label(size=40, class="form-control", readonly=readonly, placeholder=label_placeholder) }} <br>
+ {{ form.description.label }} <br> {{ form.description(size=150, class="form-control", readonly=readonly, placeholder=description_placeholder) }} <br>
+ <label>Propriétés </label>
+ <div class="form-inline">
+ <select id="property_selector" class="form-control" onChange="CatEditScripts.displayCorrespondingField();" {{readonly}}>
+ <option label="property_type_default" selected="selected">
+ Liste des propriétés ...
+ </option>
+ {% for predicate in config["PROPERTY_LIST"] %}
+ <option value='{{ predicate }}' label={{ config["PROPERTY_LIST"][predicate]["object_type"] }} >{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</option>
+ {% endfor %}
+ </select>
+ <input type="text" id="literal-field" class="hidden form-control">
+ <input type="text" id="uriref-link-field" placeholder="http://my-example.com" class="hidden form-control">
+ <select class="hidden form-control" id="uriref-category-field">
+ <option value="default" selected="selected"> Liste des catégories </option>
+ {% for cat in cat_list %}
+ <option value="{{ cat.cat_id }}"> {{ cat.cat_label }} </option>
+ {% endfor %}
+ </select>
+ <input type="button" value="Ajouter propriété" onClick="CatEditScripts.addProperty('properties','property_table_body');" class="btn btn-default" {{ readonly }}>
+ </div>
+ <div class="alert alert-warning hidden" role="alert" id="uriref-category-field-text">
+ </div>
+ <div id="properties" class="row">
+ <div class="row">
+ <div class="col-md-6">
+ <br>
+ <table id="property_table" class="table table-condensed">
+ <tbody id="property_table_body">
+ {% set property_count=1 %}
+ {% for (predicate, object) in cat_properties %}
+ <tr id="property_tr{{property_count}}">
+ {% 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 %}
+ <input type="hidden" id="property_predicate{{ property_count }}" name="property_predicate" value="{{predicate}}"/>
+ <input type="hidden" id="property_object{{ property_count }}" name="property_object" value="{{cat.cat_id}}"/>
+ <td id="predicate_td{{ property_count }}">
+ <strong>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</strong>
+ </td>
+ <td id="object_td{{ property_count }}">
+ {{ cat.cat_label }}
+ </td>
+ <td id="delete_button_td{{ property_count }}" class="text-center">
+ <input type="button" id="property_delete_button{{ property_count }}" class="btn btn-default property-delete-button" onClick="CatEditScripts.removeProperty({{ property_count }}, 'properties')" value="Supprimer">
+ </td>
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+ {% else %}
+ <input type="hidden" id="property_predicate{{ property_count }}" name="property_predicate" value="{{predicate}}"/>
+ <input type="hidden" id="property_object{{ property_count }}" name="property_object" value="{{object}}"/>
+ <td id="predicate_td{{ property_count }}">
+ <strong>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</strong>
+ </td>
+ <td id="object_td{{ property_count }}">
+ {% if config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %}
+ <a href="{{ object }}">{{ object }}</a>
+ {% else %}
+ {{ object }}
+ {% endif %}
+ </td>
+ <td id="delete_button_td{{ property_count }}">
+ <input type="button" id="property_delete_button{{ property_count }}" class="btn btn-default property-delete-button" onClick="CatEditScripts.removeProperty({{ property_count }}, 'properties')" value="Supprimer">
+ </td>
+ {% endif %}
+ {% set property_count=property_count+1 %}
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div><br><br>
+ <input type="submit" value="Sauvegarder" class="btn btn-default">
+ <a href="{{ url_for('cat_recap', repository=current_repository)}}"class="btn btn-default">Annuler</a>
+ </form>
+ {% if readonly %} </fieldset> {% endif %}
+{% endblock page_content %}
--- 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 %}
-<!DOCTYPE html>
-<html lang="fr">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Page d'accueil</title>
- <link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
- <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
- <script src="{{ url_for('static', filename='js/jquery-1.11.1.min.js') }}" language="Javascript" type="text/javascript"></script>
- <script>
- $(document).ready(function(){
- {% for cat in cat_list %}
- $("#properties_{{cat.cat_id}}").hide();
- $("#info_button_{{cat.cat_id}}").click(function(){
- $("#properties_{{cat.cat_id}}").slideToggle();
- });
- {% endfor %}
- });
- </script>
- </head>
- <body>
- <div class="navbar navbar-inverse" role="navigation">
- <div class="container">
- <div class="navbar-header">
- <a class="navbar-brand" href="{{ url_for('cat_index') }}">
- <img alt="Brand" src="{{ url_for('static', filename='img/catedit_brand.png') }}" class="navbar-img" width="32" height="32">
- </a>
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- </button>
- </div>
- <div class="collapse navbar-collapse">
- <ul class="nav navbar-nav">
- <li class="active"><a>Page d'accueil</a></li>
- </ul>
- <div class="navbar-text navbar-right">
- {% if not session.get("user_logged", None)%}Non authentifié - <a href="{{ url_for('github_login') }}" class="navbar-link">S'authentifier</a>
- {% else %} Authentifié: {{ session["user_login"] }} - <a href="{{ url_for('logout') }}" class="navbar-link">Quitter</a>{% endif %}
- </div>
- {% if session["user_login"] %}
- <form class="navbar-form navbar-right">
- <select class="form-control select-repo" name="navrepo" onchange="window.location.href=this.form.navrepo.options[this.form.navrepo.selectedIndex].value">
- <option value="" selected="selected">Sélectionner ensemble...</option>
- {% for repo in config["REPOSITORY_LIST"] %}
- <option value="{{url_for('cat_recap', repository=repo)}}">{{repo}}</option>
- {% endfor %}
- </select>
- </form>
- {% endif %}
- </div>
- </div>
- </div>
- <div class="container">
- <h2> <b>CatEdit</b>: Editeur de Catégories</h2>
- <h3> Mode d'emploi </h3>
- <div class="col-md-8">
- <p>
- CatEdit est un outil permettant de créer et d'éditer des catégories.
- Vous aurez besoin d'un compte Github pour utiliser CatEdit:
- <a href="https://github.com/">s'inscrire sur Github</a>
- </p>
- <p>
- 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.
- </p>
- <p>
- 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.
- </p>
- <h4><b>La liste de catégories</b></h4>
- <p>
- 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.
- </p>
- <ul>
- <li>
- Une ligne de tableau <b>blanche</b> représente une catégorie de l'état courant
- que vous n'avez ni modifié ni supprimé.
- </li>
- <li>
- Une ligne de tableau <b class="text-success">verte</b> 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.
- </li>
- <li>
- Une ligne de tableau <b class="text-warning">orange</b> représente une catégorie qui existait
- initialement et que vous avez modifié.
- </li>
- <li>
- Une ligne de tableau <b class="text-danger">rouge</b> représente une catégorie de l'état courant que
- vous avez supprimé.
- </li>
- </ul>
- </p>
- <p>
- 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.
- </p>
- <p>
- Vous devez obligatoirement renseigner une explication de vos changements avant soumission.
- </p>
- </div>
- </div>
- </body>
-</html>
+{% block title %}Page d'accueil{% endblock title %}
+{% block head %}
+ {{ super() }}
+{% endblock head %}
+{% block navbar_items %}
+ <li class="active"><a>Page d'accueil</a></li>
+{% endblock navbar_items %}
+{% block repo_list %}
+ <option value="" selected="selected"> Sélectionnez ensemble... </option>
+ {{ super() }}
+{% endblock repo_list %}
+{% block page_content %}
+ <h2> <b>CatEdit</b>: Editeur de Catégories</h2>
+ <h3> Mode d'emploi </h3>
+ <div class="col-md-8">
+ <p>
+ CatEdit est un outil permettant de créer et d'éditer des catégories.
+ Vous aurez besoin d'un compte Github pour utiliser CatEdit:
+ <a href="https://github.com/">s'inscrire sur Github</a>
+ </p>
+ <p>
+ 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.
+ </p>
+ <p>
+ 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.
+ </p>
+ <h4><b>La liste de catégories</b></h4>
+ <p>
+ 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.
+ </p>
+ <ul>
+ <li>
+ Une ligne de tableau <b>blanche</b> représente une catégorie de l'état courant
+ que vous n'avez ni modifié ni supprimé.
+ </li>
+ <li>
+ Une ligne de tableau <b class="text-success">verte</b> 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.
+ </li>
+ <li>
+ Une ligne de tableau <b class="text-warning">orange</b> représente une catégorie qui existait
+ initialement et que vous avez modifié.
+ </li>
+ <li>
+ Une ligne de tableau <b class="text-danger">rouge</b> représente une catégorie de l'état courant que
+ vous avez supprimé.
+ </li>
+ </ul>
+ </p>
+ <p>
+ 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.
+ </p>
+ <p>
+ Vous devez obligatoirement renseigner une explication de vos changements avant soumission.
+ </p>
+ </div>
+{% endblock page_content %}
--- 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 %}
-<!DOCTYPE html>
-<html lang="fr">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Soumettre mes changements</title>
- <link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
- <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
- <script src="{{ url_for('static', filename='js/jquery-1.11.1.min.js') }}" language="Javascript" type="text/javascript"></script>
- <script>
- $(document).ready(function(){
- {% for cat in cat_list %}
- $("#properties_{{cat.cat_id}}").hide();
- $("#info_button_{{cat.cat_id}}").click(function(){
- $("#properties_{{cat.cat_id}}").slideToggle();
- });
- {% endfor %}
- {% for cat in modified_cat_list %}
- $("#properties_modified_{{cat.cat_id}}").hide();
- $("#info_button_modified_{{cat.cat_id}}").click(function(){
- $("#properties_modified_{{cat.cat_id}}").slideToggle();
- });
- $("#delete_modified_{{cat.cat_id}}").hide();
- $("#remove_modifs_modified_{{cat.cat_id}}").click(function(){
- $("#delete_modified_{{cat.cat_id}}").slideToggle();
- });
- {% endfor %}
- {% for cat in created_cat_list %}
- $("#properties_created_{{cat.cat_id}}").hide();
- $("#info_button_created_{{cat.cat_id}}").click(function(){
- $("#properties_created_{{cat.cat_id}}").slideToggle();
- });
- $("#delete_created_{{cat.cat_id}}").hide();
- $("#remove_modifs_created_{{cat.cat_id}}").click(function(){
- $("#delete_created_{{cat.cat_id}}").slideToggle();
- });
- {% endfor %}
+{% block title %}{{current_repository}}: Soumission{% endblock title %}
+{% block head %}
+ {{ super() }}
+ <script src="{{ url_for('static', filename='js/jquery-1.11.1.min.js') }}" language="Javascript" type="text/javascript"></script>
+ <script>
+ $(document).ready(function(){
+ {% for cat in cat_list %}
+ $("#properties_{{cat.cat_id}}").hide();
+ $("#info_button_{{cat.cat_id}}").click(function(){
+ $("#properties_{{cat.cat_id}}").slideToggle();
+ });
+ {% endfor %}
+ {% for cat in modified_cat_list %}
+ $("#properties_modified_{{cat.cat_id}}").hide();
+ $("#info_button_modified_{{cat.cat_id}}").click(function(){
+ $("#properties_modified_{{cat.cat_id}}").slideToggle();
+ });
+ $("#delete_modified_{{cat.cat_id}}").hide();
+ $("#remove_modifs_modified_{{cat.cat_id}}").click(function(){
+ $("#delete_modified_{{cat.cat_id}}").slideToggle();
+ });
+ {% endfor %}
+ {% for cat in created_cat_list %}
+ $("#properties_created_{{cat.cat_id}}").hide();
+ $("#info_button_created_{{cat.cat_id}}").click(function(){
+ $("#properties_created_{{cat.cat_id}}").slideToggle();
+ });
+ $("#delete_created_{{cat.cat_id}}").hide();
+ $("#remove_modifs_created_{{cat.cat_id}}").click(function(){
+ $("#delete_created_{{cat.cat_id}}").slideToggle();
});
- </script>
- </head>
- <body>
- <div class="navbar navbar-inverse" role="navigation">
- <div class="container">
- <div class="navbar-header">
- <a class="navbar-brand" href="{{ url_for('cat_index') }}">
- <img alt="Brand" src="{{ url_for('static', filename='img/catedit_brand.png') }}" class="navbar-img" width="32" height="32">
- </a>
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- </div>
- <div class="collapse navbar-collapse">
- <ul class="nav navbar-nav">
- <li><a href="{{ url_for('cat_index') }}">Page d'accueil</a></li>
- {% if session.get("user_logged", None) %}
- <li><a href="{{ url_for('cat_recap', repository=current_repository) }}">Atelier</a></li>
- {% endif %}
- <li class="active"><a>Soumission</a></li>
- </ul>
- <div class="navbar-text navbar-right">
- {% if not session.get("user_logged", None)%}Non authentifié - <a href="{{ url_for('github_login') }}" class="navbar-link">S'authentifier</a>
- {% else %} Authentifié: {{ session["user_login"] }} - <a href="{{ url_for('logout') }}" class="navbar-link">Quitter</a>{% endif %}
- </div>
- {% if session["user_logged"] %}
- <form class="navbar-form navbar-right">
- <select class="form-control select-repo" name="navrepo" onchange="window.location.href=this.form.navrepo.options[this.form.navrepo.selectedIndex].value">
- {% for repo in config["REPOSITORY_LIST"] %}
- <option value="{{url_for('cat_recap', repository=repo)}}" {% if repo==current_repository %}selected="selected"{% endif %}>{{repo}}</option>
- {% endfor %}
- </select>
- </form>
- {% endif %}
- </div>
- </div>
- </div>
- <div class="container">
- <h2> <b>CatEdit</b> - <small>{{current_repository}}</small></h2>
- <h3> Catégories existantes </h3>
- <table class="table table-bordered table-condensed">
- <thead>
- <tr class="active">
- <th class="col-md-2"><b>Nom de la catégorie</b></th>
- <th class="col-md-10"><b>Description de la catégorie</b></th>
- </tr>
- </thead>
- <tbody>
- {% if not session["user_logged"] %}
+ {% endfor %}
+ });
+ </script>
+{% endblock head %}
+{% block navbar_items %}
+ {{ super() }}
+ {% if session.get("user_logged", None) %}
+ <li><a class="navbar-decorative">></a></li>
+ <li><a href="{{ url_for('cat_recap', repository=current_repository) }}">Atelier</a></li>
+ <li><a class="navbar-decorative">></a></li>
+ <li class="active"><a>Soumission</a></li>
+ {% endif %}
+{% endblock navbar_items %}
+{% block repo_list %}
+ {{ super() }}
+{% endblock repo_list %}
+{% block page_content %}
+ <h2> <b>CatEdit</b> - <small>{{current_repository}}</small></h2>
+ <h3> Catégories existantes </h3>
+ <table class="table table-bordered table-condensed">
+ <thead>
+ <tr class="active">
+ <th class="col-md-2"><b>Nom de la catégorie</b></th>
+ <th class="col-md-10"><b>Description de la catégorie</b></th>
+ </tr>
+ </thead>
+ <tbody>
+ {% if not session["user_logged"] %}
+ <tr>
+ <td class="col-md-12" colspan="2">
+ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
+ <span class="sr-only">Attention:</span>
+ Veuillez vous identifier pour visualiser les catégories
+ </td>
+ </tr>
+ {% else %}
+ {% if cat_list|length == 0 %}
<tr>
- <td class="col-md-12" colspan="2">
- <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
- <span class="sr-only">Attention:</span>
- Veuillez vous identifier pour visualiser les catégories
- </td>
+ <td class="col-md-12" colspan="2">Aucune catégorie n'a été créée pour l'instant. {% if not readonly %}<a href="{{ url_for('cat_editor', repository=current_repository) }}">Créer une catégorie</a>{% endif %}</td>
</tr>
- {% else %}
- {% if cat_list|length == 0 %}
+ {% else %}
+ {% for cat in cat_list %}
+ <tr>
+ <td class="col-md-2">{{ cat.cat_label }}</td>
+ <td class="col-md-8">{{ cat.cat_description}}</td>
+ <td class="text-center">
+ <a title="Détails catégorie"><button class="btn btn-default" id="info_button_{{ cat.cat_id }}"><span class="glyphicon glyphicon glyphicon-plus-sign"/></button></a>
+ </td>
+ {% if cat.cat_id not in deleted_cat_namelist and cat.cat_id not in modified_cat_namelist %}
+ <td class="text-center">
+ <a href="{{ url_for('cat_editor', cat_id=cat.cat_id, repository=current_repository)}}" title="Editer catégorie" class="btn btn-default"><span class="glyphicon glyphicon glyphicon-pencil"/></a>
+ </td>
+ <td class="text-center">
+ <a title="Supprimer catégorie">
+ <form method="POST" action="{{ url_for('cat_modifs', deleted_cat_id=cat.cat_id, repository=current_repository) }}" class="form-inline form-button">
+ <fieldset {% if readonly %}disabled{% endif %}>
+ <button type="submit" class="btn btn-default">
+ <span class="glyphicon glyphicon-trash" title="Supprimer catégorie"/>
+ </button>
+ </fieldset>
+ </form>
+ </a>
+ </td>
+ {% else %}
+ <td colspan="2">
+ </td>
+ {% endif %}
+ </tr>
<tr>
- <td class="col-md-12" colspan="2">Aucune catégorie n'a été créée pour l'instant. {% if not readonly %}<a href="{{ url_for('cat_editor', repository=current_repository) }}">Créer une catégorie</a>{% endif %}</td>
- </tr>
- {% else %}
- {% for cat in cat_list %}
- <tr>
- <td class="col-md-2">{{ cat.cat_label }}</td>
- <td class="col-md-8">{{ cat.cat_description}}</td>
- <td class="text-center">
- <a title="Détails catégorie"><button class="btn btn-default" id="info_button_{{ cat.cat_id }}"><span class="glyphicon glyphicon glyphicon-plus-sign"/></button></a>
- </td>
- {% if cat.cat_id not in deleted_cat_namelist and cat.cat_id not in modified_cat_namelist %}
- <td class="text-center">
- <a href="{{ url_for('cat_editor', cat_id=cat.cat_id, repository=current_repository)}}" title="Editer catégorie" class="btn btn-default"><span class="glyphicon glyphicon glyphicon-pencil"/></a>
- </td>
- <td class="text-center">
- <a title="Supprimer catégorie">
- <form method="POST" action="{{ url_for('cat_modifs', deleted_cat_id=cat.cat_id, repository=current_repository) }}" class="form-inline form-button">
- <fieldset {% if readonly %}disabled{% endif %}>
- <button type="submit" class="btn btn-default">
- <span class="glyphicon glyphicon-trash" title="Supprimer catégorie"/>
- </button>
- </fieldset>
- </form>
- </a>
- </td>
+ <td colspan="2">
+ <div id="properties_{{cat.cat_id}}">
+ <dl class="dl-horizontal">
+ {% if cat.cat_properties|length == 0 %} <dt></dt><dd>Aucune autre propriété</dd>
{% else %}
- <td colspan="2">
- </td>
+ {% for (predicate, object) in cat.cat_properties %}
+ <dt>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</dt>
+ <dd>
+ {% 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" %}
+ <a href="{{ object }}">{{ object }}</a>
+ {% else %}
+ {{ object }}
+ {% endif %}
+ </dd>
+ {% endfor %}
{% endif %}
- </tr>
- <tr>
- <td colspan="2">
- <div id="properties_{{cat.cat_id}}">
- <dl class="dl-horizontal">
- {% if cat.cat_properties|length == 0 %} <dt></dt><dd>Aucune autre propriété</dd>
- {% else %}
- {% for (predicate, object) in cat.cat_properties %}
- <dt>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</dt>
- <dd>
- {% 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" %}
- <a href="{{ object }}">{{ object }}</a>
- {% else %}
- {{ object }}
- {% endif %}
- </dd>
- {% endfor %}
- {% endif %}
- </dl>
- </div>
- </td>
- </tr>
- {% endfor %}
- {% endif %}
- {% endif %}
- </tbody>
- </table>
+ </dl>
+ </div>
+ </td>
+ </tr>
+ {% endfor %}
+ {% endif %}
+ {% endif %}
+ </tbody>
+ </table>
- <h3> Mes modifications </h3>
- <table class="table table-bordered table-condensed">
- <thead>
- <tr class="active">
- <th class="col-md-2"><b>Nom de la catégorie</b></th>
- <th class="col-md-10" colspan="2"><b>Description de la catégorie</b></th>
- </tr>
- </thead>
- <tbody>
- {% if not session["user_logged"] %}
+ <h3> Mes modifications </h3>
+ <table class="table table-bordered table-condensed">
+ <thead>
+ <tr class="active">
+ <th class="col-md-2"><b>Nom de la catégorie</b></th>
+ <th class="col-md-10" colspan="2"><b>Description de la catégorie</b></th>
+ </tr>
+ </thead>
+ <tbody>
+ {% if not session["user_logged"] %}
+ <tr>
+ <td class="col-md-12" colspan="3">
+ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
+ <span class="sr-only">Attention:</span>
+ Veuillez vous identifier pour visualiser les modifications
+ </td>
+ </tr>
+ {% else %}
+ <tr class="success">
+ <td class="col-md-12" colspan="3">
+ <b> Catégories ajoutées</b>
+ </td>
+ </tr>
+ {% if created_cat_list|length == 0 %}
<tr>
- <td class="col-md-12" colspan="3">
- <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
- <span class="sr-only">Attention:</span>
- Veuillez vous identifier pour visualiser les modifications
- </td>
+ <td class="col-md-12" colspan="3">Aucune catégorie n'a été ajoutée pour l'instant.</td>
</tr>
- {% else %}
+ {% else %}
+ {% for cat in created_cat_list %}
<tr class="success">
- <td class="col-md-12" colspan="3">
- <b> Catégories ajoutées</b>
+ <td class="col-md-2">{{ cat.cat_label }}</td>
+ <td class="col-md-8">{{ cat.cat_description}}</td>
+ <td class="col-md-2 text-center">
+ <a title="Détails catégorie"><button class="btn btn-default" id="info_button_created_{{ cat.cat_id }}"><span class="glyphicon glyphicon-plus-sign"/></button></a>
+ <a href="{{ url_for('cat_editor', cat_id=cat.cat_id, repository=current_repository)}}" title="Editer catégorie" class="btn btn-default"><span class="glyphicon glyphicon glyphicon-pencil"/></a>
+ <a title="Supprimer modifications"><button class="btn btn-default" id="remove_modifs_created_{{ cat.cat_id }}"><span class="glyphicon glyphicon-remove-sign"/></button></a>
</td>
</tr>
- {% if created_cat_list|length == 0 %}
- <tr>
- <td class="col-md-12" colspan="3">Aucune catégorie n'a été ajoutée pour l'instant.</td>
- </tr>
- {% else %}
- {% for cat in created_cat_list %}
- <tr class="success">
- <td class="col-md-2">{{ cat.cat_label }}</td>
- <td class="col-md-8">{{ cat.cat_description}}</td>
- <td class="col-md-2 text-center">
- <a title="Détails catégorie"><button class="btn btn-default" id="info_button_created_{{ cat.cat_id }}"><span class="glyphicon glyphicon-plus-sign"/></button></a>
- <a href="{{ url_for('cat_editor', cat_id=cat.cat_id, repository=current_repository)}}" title="Editer catégorie" class="btn btn-default"><span class="glyphicon glyphicon glyphicon-pencil"/></a>
- <a title="Supprimer modifications"><button class="btn btn-default" id="remove_modifs_created_{{ cat.cat_id }}"><span class="glyphicon glyphicon-remove-sign"/></button></a>
- </td>
- </tr>
- <tr class="success">
- <td colspan="3">
- <div id="properties_created_{{cat.cat_id}}">
- <dl class="dl-horizontal">
- {% if cat.cat_properties|length == 0 %} <dt></dt><dd>Aucune autre propriété</dd>
- {% else %}
- {% for (predicate, object) in cat.cat_properties %}
- <dt>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</dt>
- <dd>
- {% 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" %}
- <a href="{{ object }}">{{ object }}</a>
- {% else %}
- {{ object }}
+ <tr class="success">
+ <td colspan="3">
+ <div id="properties_created_{{cat.cat_id}}">
+ <dl class="dl-horizontal">
+ {% if cat.cat_properties|length == 0 %} <dt></dt><dd>Aucune autre propriété</dd>
+ {% else %}
+ {% for (predicate, object) in cat.cat_properties %}
+ <dt>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</dt>
+ <dd>
+ {% 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 %}
- </dd>
- {% endfor %}
- {% endif %}
- </dl>
- </div>
- <div id="delete_created_{{cat.cat_id}}">
- <form method="POST" action="{{ url_for('cat_modifs', deleted_modifs_id=cat.cat_id, repository=current_repository) }}" class="form-inline align-center">
- <fieldset {% if readonly %}disabled{% endif %}>
- <div class="input-group">
- <div class="input-group-addon">
- Vous allez supprimer les changements faits sur cette catégorie.
- </div>
- <input type="submit" class="btn btn-default" value="Supprimer">
- </div>
- </fieldset>
- </form>
- </div>
- </td>
- </tr>
- {% endfor %}
- {% endif %}
+ {% endfor %}
+ {% elif config["PROPERTY_LIST"][predicate]["object_type"]=="uriref-link" %}
+ <a href="{{ object }}">{{ object }}</a>
+ {% else %}
+ {{ object }}
+ {% endif %}
+ </dd>
+ {% endfor %}
+ {% endif %}
+ </dl>
+ </div>
+ <div id="delete_created_{{cat.cat_id}}">
+ <form method="POST" action="{{ url_for('cat_modifs', deleted_modifs_id=cat.cat_id, repository=current_repository) }}" class="form-inline align-center">
+ <fieldset {% if readonly %}disabled{% endif %}>
+ <div class="input-group">
+ <div class="input-group-addon">
+ Vous allez supprimer les changements faits sur cette catégorie.
+ </div>
+ <input type="submit" class="btn btn-default" value="Supprimer">
+ </div>
+ </fieldset>
+ </form>
+ </div>
+ </td>
+ </tr>
+ {% endfor %}
+ {% endif %}
+ <tr class="warning">
+ <td class="col-md-12" colspan="3">
+ <b> Catégories modifiées</b>
+ </td>
+ </tr>
+ {% if modified_cat_list|length == 0 %}
+ <tr>
+ <td class="col-md-12" colspan="3">Aucune catégorie n'a été modifiée pour l'instant.</td>
+ </tr>
+ {% else %}
+ {% for cat in modified_cat_list %}
<tr class="warning">
- <td class="col-md-12" colspan="3">
- <b> Catégories modifiées</b>
+ <td class="col-md-2">{{ cat.cat_label }}</td>
+ <td class="col-md-8">{{ cat.cat_description}}</td>
+ <td class="col-md-2 text-center">
+ <a title="Détails catégorie"><button class="btn btn-default" id="info_button_modified_{{ cat.cat_id }}"><span class="glyphicon glyphicon-plus-sign"/></button></a>
+ <a href="{{ url_for('cat_editor', cat_id=cat.cat_id, repository=current_repository)}}" title="Editer catégorie" class="btn btn-default"><span class="glyphicon glyphicon glyphicon-pencil"/></a>
+ <a title="Supprimer modifications"><button class="btn btn-default" id="remove_modifs_modified_{{ cat.cat_id }}"><span class="glyphicon glyphicon-remove-sign"/></button></a>
</td>
</tr>
- {% if modified_cat_list|length == 0 %}
- <tr>
- <td class="col-md-12" colspan="3">Aucune catégorie n'a été modifiée pour l'instant.</td>
+ <tr class="warning">
+ <td colspan="3">
+ <div id="properties_modified_{{cat.cat_id}}">
+ <dl class="dl-horizontal">
+ {% if cat.cat_properties|length == 0 %} <dt></dt><dd>Aucune autre propriété</dd>
+ {% else %}
+ {% for (predicate, object) in cat.cat_properties %}
+ <dt>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</dt>
+ <dd>
+ {% 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" %}
+ <a href="{{ object }}">{{ object }}</a>
+ {% else %}
+ {{ object }}
+ {% endif %}
+ </dd>
+ {% endfor %}
+ {% endif %}
+ </dl>
+ </div>
+ <div id="delete_modified_{{cat.cat_id}}">
+ <form method="POST" action="{{ url_for('cat_modifs', deleted_modifs_id=cat.cat_id, repository=current_repository) }}" class="form-inline align-center">
+ <fieldset {% if readonly %}disabled{% endif %}>
+ <div class="input-group">
+ <div class="input-group-addon">
+ Vous allez supprimer les changements faits sur cette catégorie.
+ </div>
+ <input type="submit" class="btn btn-default" value="Supprimer">
+ </div>
+ </fieldset>
+ </form>
+ </div>
+ </td>
</tr>
- {% else %}
- {% for cat in modified_cat_list %}
- <tr class="warning">
- <td class="col-md-2">{{ cat.cat_label }}</td>
- <td class="col-md-8">{{ cat.cat_description}}</td>
+ {% endfor %}
+ {% endif %}
+
+ <tr class="danger">
+ <td class="col-md-12" colspan="3">
+ <b> Catégories supprimées</b>
+ </td>
+ </tr>
+ {% if deleted_cat_namelist|length == 0 %}
+ <tr>
+ <td class="col-md-12" colspan="3">Aucune catégorie n'a été supprimée pour l'instant.</td>
+ </tr>
+ {% else %}
+ {% for deleted_cat in deleted_cat_namelist %}
+ {% for existing_cat in cat_list %}
+ {% if existing_cat.cat_id == deleted_cat %}
+ <tr class="danger">
+ <td class="col-md-2">{{ existing_cat.cat_label }}</td>
+ <td class="col-md-8"><i>Cette catégorie va être supprimée quand vous soumettrez vos modifications.</i></td>
<td class="col-md-2 text-center">
- <a title="Détails catégorie"><button class="btn btn-default" id="info_button_modified_{{ cat.cat_id }}"><span class="glyphicon glyphicon-plus-sign"/></button></a>
- <a href="{{ url_for('cat_editor', cat_id=cat.cat_id, repository=current_repository)}}" title="Editer catégorie" class="btn btn-default"><span class="glyphicon glyphicon glyphicon-pencil"/></a>
- <a title="Supprimer modifications"><button class="btn btn-default" id="remove_modifs_modified_{{ cat.cat_id }}"><span class="glyphicon glyphicon-remove-sign"/></button></a>
+ <form method="POST" action="{{ url_for('cat_modifs', deleted_cat_id=deleted_cat, repository=current_repository) }}">
+ <fieldset {% if readonly %}disabled{% endif %}>
+ <input type="submit" class="btn btn-default" value="Restaurer">
+ </fieldset>
+ </form>
</td>
</tr>
- <tr class="warning">
- <td colspan="3">
- <div id="properties_modified_{{cat.cat_id}}">
- <dl class="dl-horizontal">
- {% if cat.cat_properties|length == 0 %} <dt></dt><dd>Aucune autre propriété</dd>
- {% else %}
- {% for (predicate, object) in cat.cat_properties %}
- <dt>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</dt>
- <dd>
- {% 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" %}
- <a href="{{ object }}">{{ object }}</a>
- {% else %}
- {{ object }}
- {% endif %}
- </dd>
- {% endfor %}
- {% endif %}
- </dl>
- </div>
- <div id="delete_modified_{{cat.cat_id}}">
- <form method="POST" action="{{ url_for('cat_modifs', deleted_modifs_id=cat.cat_id, repository=current_repository) }}" class="form-inline align-center">
- <fieldset {% if readonly %}disabled{% endif %}>
- <div class="input-group">
- <div class="input-group-addon">
- Vous allez supprimer les changements faits sur cette catégorie.
- </div>
- <input type="submit" class="btn btn-default" value="Supprimer">
- </div>
- </fieldset>
- </form>
- </div>
- </td>
- </tr>
- {% endfor %}
- {% endif %}
-
- <tr class="danger">
- <td class="col-md-12" colspan="3">
- <b> Catégories supprimées</b>
- </td>
- </tr>
- {% if deleted_cat_namelist|length == 0 %}
- <tr>
- <td class="col-md-12" colspan="3">Aucune catégorie n'a été supprimée pour l'instant.</td>
- </tr>
- {% else %}
- {% for deleted_cat in deleted_cat_namelist %}
- {% for existing_cat in cat_list %}
- {% if existing_cat.cat_id == deleted_cat %}
- <tr class="danger">
- <td class="col-md-2">{{ existing_cat.cat_label }}</td>
- <td class="col-md-8"><i>Cette catégorie va être supprimée quand vous soumettrez vos modifications.</i></td>
- <td class="col-md-2 text-center">
- <form method="POST" action="{{ url_for('cat_modifs', deleted_cat_id=deleted_cat, repository=current_repository) }}">
- <fieldset {% if readonly %}disabled{% endif %}>
- <input type="submit" class="btn btn-default" value="Restaurer">
- </fieldset>
- </form>
- </td>
- </tr>
- {% endif %}
- {% endfor %}
- {% endfor %}
- {% endif %}
- {% endif %}
- </tbody>
- </table>
- <h3> Soumettre mes changements </h3>
- <div class="col-md-12">
- <form method="POST" action="{{ url_for('cat_modifs', repository=current_repository)}}">
- <fieldset {% if readonly %}disabled{% endif %}>
- {{ commit_form.hidden_tag() }}
- <div class="form-group">
- {{ commit_form.commit_message.label }}
- {{ commit_form.commit_message(size=40, class="form-control", readonly=readonly) }}
- </div>
- <button type="submit" class="btn btn-default">Soumettre modifications</button>
- <a href="{{ url_for('cat_recap', repository=current_repository)}}"class="btn btn-default">Retour</a>
- </fieldset>
- </form><br>
- </div>
- </div>
- </body>
-</html>
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+ {% endif %}
+ {% endif %}
+ </tbody>
+ </table>
+ <h3> Soumettre mes changements </h3>
+ <div class="col-md-12">
+ <form method="POST" action="{{ url_for('cat_modifs', repository=current_repository)}}">
+ <fieldset {% if readonly %}disabled{% endif %}>
+ {{ commit_form.hidden_tag() }}
+ <div class="form-group">
+ {{ commit_form.commit_message.label }}
+ {{ commit_form.commit_message(size=40, class="form-control", readonly=readonly) }}
+ </div>
+ <button type="submit" class="btn btn-default">Soumettre modifications</button>
+ <a href="{{ url_for('cat_recap', repository=current_repository)}}"class="btn btn-default">Retour</a>
+ </fieldset>
+ </form><br>
+ </div>
+{% endblock page_content %}
--- 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 %}
-<!DOCTYPE html>
-<html lang="fr">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Atelier</title>
- <link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
- <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
- <script src="{{ url_for('static', filename='js/jquery-1.11.1.min.js') }}" language="Javascript" type="text/javascript"></script>
- <script>
- $(document).ready(function(){
- {% for cat in cat_list %}
- $("#properties_{{cat.cat_id}}").hide();
- $("#info_button_{{cat.cat_id}}").click(function(){
- $("#properties_{{cat.cat_id}}").slideToggle();
- });
- {% endfor %}
- });
- </script>
- </head>
- <body>
- <div class="navbar navbar-inverse" role="navigation">
- <div class="container">
- <div class="navbar-header">
- <a class="navbar-brand" href="{{ url_for('cat_index') }}">
- <img alt="Brand" src="{{ url_for('static', filename='img/catedit_brand.png') }}" class="navbar-img" width="32" height="32">
- </a>
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- </button>
- </div>
- <div class="collapse navbar-collapse">
- <ul class="nav navbar-nav">
- <li><a href="{{ url_for('cat_index') }}">Page d'accueil</a></li>
- {% if session.get("user_logged", None) %}
- <li class="active"><a>Atelier</a></li>
- {% endif %}
- </ul>
- <div class="navbar-text navbar-right">
- {% if not session.get("user_logged", None)%}Non authentifié - <a href="{{ url_for('github_login') }}" class="navbar-link">S'authentifier</a>
- {% else %} Authentifié: {{ session["user_login"] }} - <a href="{{ url_for('logout') }}" class="navbar-link">Quitter</a>{% endif %}
- </div>
- {% if session["user_logged"] %}
- <form class="navbar-form navbar-right">
- <select class="form-control select-repo" name="navrepo" onchange="window.location.href=this.form.navrepo.options[this.form.navrepo.selectedIndex].value">
- {% for repo in config["REPOSITORY_LIST"] %}
- <option value="{{url_for('cat_recap', repository=repo)}}" {% if repo==current_repository %}selected="selected"{% endif %}>{{repo}}</option>
- {% endfor %}
- </select>
- </form>
- {% endif %}
- </div>
- </div>
- </div>
- <div class="container">
- <h2> <b>CatEdit</b> - <small>{{current_repository}}</small></h2>
- <h3> Créer une catégorie : <a href="{{url_for('cat_editor', repository=current_repository)}}" title="Créer catégorie" class="btn btn-default {% if readonly %}disabled{% endif %}"><span class="glyphicon glyphicon-plus"/></a></h3>
- {% if session["user_logged"] and not session["user_can_edit"] %}
- <div class="alert alert-warning" role="alert">
+{% block title %}{{current_repository}}: Atelier{% endblock title %}
+{% block head %}
+ {{ super() }}
+ <script src="{{ url_for('static', filename='js/jquery-1.11.1.min.js') }}" language="Javascript" type="text/javascript"></script>
+ <script>
+ $(document).ready(function(){
+ {% for cat in cat_list %}
+ $("#properties_{{cat.cat_id}}").hide();
+ $("#info_button_{{cat.cat_id}}").click(function(){
+ $("#properties_{{cat.cat_id}}").slideToggle();
+ });
+ {% endfor %}
+ });
+ </script>
+{% endblock head %}
+{% block navbar_items %}
+ {{ super() }}
+ {% if session.get("user_logged", None) %}
+ <li><a class="navbar-decorative">></a></li>
+ <li class="active"><a>Atelier</a></li>
+ {% endif %}
+{% endblock navbar_items %}
+{% block repo_list %}
+ {{ super() }}
+{% endblock repo_list %}
+{% block page_content %}
+ <h2> <b>CatEdit</b> - <small>{{current_repository}}</small></h2>
+ <h3> Créer une catégorie : <a href="{{url_for('cat_editor', repository=current_repository)}}" title="Créer catégorie" class="btn btn-default {% if readonly %}disabled{% endif %}"><span class="glyphicon glyphicon-plus"/></a></h3>
+ {% if session["user_logged"] and not session["user_can_edit"] %}
+ <div class="alert alert-warning" role="alert">
+ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
+ <span class="sr-only">Attention:</span>
+ Vous n'avez pas accès en écriture au repository contenant les catégories - Vous ne pourrez pas les modifier.
+ </div>
+ {% endif %}
+ <h3>Mes catégories</h3>
+ <table class="table table-bordered table-condensed">
+ <thead>
+ <tr class="active">
+ <th class="col-md-2"><b>Nom de la catégorie</b></th>
+ <th class="col-md-10"><b>Description de la catégorie</b></th>
+ </tr>
+ </thead>
+ <tbody>
+ {% if not session["user_logged"] %}
+ <tr>
+ <td class="col-md-12" colspan="2">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Attention:</span>
- Vous n'avez pas accès en écriture au repository contenant les catégories - Vous ne pourrez pas les modifier.
- </div>
- {% endif %}
- <h3>Mes catégories</h3>
- <table class="table table-bordered table-condensed">
- <thead>
- <tr class="active">
- <th class="col-md-2"><b>Nom de la catégorie</b></th>
- <th class="col-md-10"><b>Description de la catégorie</b></th>
- </tr>
- </thead>
- <tbody>
- {% if not session["user_logged"] %}
+ Veuillez vous identifier pour visualiser les catégories
+ </td>
+ </tr>
+ {% else %}
+ {% if cat_list|length == 0 %}
<tr>
- <td class="col-md-12" colspan="2">
- <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
- <span class="sr-only">Attention:</span>
- Veuillez vous identifier pour visualiser les catégories
- </td>
+ <td class="col-md-12" colspan="2">Aucune catégorie n'a été créée pour l'instant. {% if not readonly %}<a href="{{ url_for('cat_editor', repository=current_repository) }}">Créer une catégorie</a>{% endif %}</td>
</tr>
- {% else %}
- {% if cat_list|length == 0 %}
- <tr>
- <td class="col-md-12" colspan="2">Aucune catégorie n'a été créée pour l'instant. {% if not readonly %}<a href="{{ url_for('cat_editor', repository=current_repository) }}">Créer une catégorie</a>{% endif %}</td>
- </tr>
- {% else %}
- {% for cat in cat_list %}
- <tr
- {% if cat.state == "created" %}
- class="success"
- {% elif cat.state == "modified" %}
- class="warning"
- {% elif cat.state == "deleted" %}
- class="danger"
- {% endif %}>
- <td class="col-md-2">{{ cat.cat_label }}</td>
- <td class="col-md-8">{{ cat.cat_description}}</td>
- <td class="col-md-1 text-center">
- <a title="Détails catégorie">
- <button class="btn btn-default" id="info_button_{{ cat.cat_id }}"><span class="glyphicon glyphicon-plus-sign"/></button>
- </a>
- </td>
- {% if (cat.state != "deleted") %}
- <td class="col-md-1 text-center">
- <a href="{{ url_for('cat_editor', cat_id=cat.cat_id, repository=current_repository)}}" title="Editer catégorie" class="btn btn-default">
- <span class="glyphicon glyphicon glyphicon-pencil"/>
- </a>
- </td>
- {% endif %}
- {% if (cat.state == "untouched") %}
- <td class="col-md-1 text-center">
- <form method="POST" action="{{url_for('cat_recap', deleted_cat_id=cat.cat_id, repository=current_repository)}}" class="form-inline">
- <a title="Supprimer catégorie">
- <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-trash"/></button>
- </a>
- </form>
- </td>
- {% elif (cat.state == "created" or cat.state == "modified") %}
- <td class="col-md-1 text-center">
- <form method="POST" action="{{url_for('cat_recap', deleted_modifs_id=cat.cat_id, repository=current_repository)}}" class="form-inline">
- <a title="Supprimer changements">
- <button class="btn btn-default"><span class="glyphicon glyphicon-remove-sign"/></button>
- </a>
- </form>
- </td>
+ {% else %}
+ {% for cat in cat_list %}
+ <tr
+ {% if cat.state == "created" %}
+ class="success"
+ {% elif cat.state == "modified" %}
+ class="warning"
+ {% elif cat.state == "deleted" %}
+ class="danger"
+ {% endif %}>
+ <td class="col-md-2">{{ cat.cat_label }}</td>
+ <td class="col-md-8">{{ cat.cat_description}}</td>
+ <td class="col-md-1 text-center">
+ <a title="Détails catégorie">
+ <button class="btn btn-default" id="info_button_{{ cat.cat_id }}"><span class="glyphicon glyphicon-plus-sign"/></button>
+ </a>
+ </td>
+ {% if (cat.state != "deleted") %}
+ <td class="col-md-1 text-center">
+ <a href="{{ url_for('cat_editor', cat_id=cat.cat_id, repository=current_repository)}}" title="Editer catégorie" class="btn btn-default">
+ <span class="glyphicon glyphicon glyphicon-pencil"/>
+ </a>
+ </td>
+ {% endif %}
+ {% if (cat.state == "untouched") %}
+ <td class="col-md-1 text-center">
+ <form method="POST" action="{{url_for('cat_recap', deleted_cat_id=cat.cat_id, repository=current_repository)}}" class="form-inline">
+ <a title="Supprimer catégorie">
+ <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-trash"/></button>
+ </a>
+ </form>
+ </td>
+ {% elif (cat.state == "created" or cat.state == "modified") %}
+ <td class="col-md-1 text-center">
+ <form method="POST" action="{{url_for('cat_recap', deleted_modifs_id=cat.cat_id, repository=current_repository)}}" class="form-inline">
+ <a title="Supprimer changements">
+ <button class="btn btn-default"><span class="glyphicon glyphicon-remove-sign"/></button>
+ </a>
+ </form>
+ </td>
+ {% else %}
+ <td colspan="2">
+ <form method="POST" action="{{url_for('cat_recap', deleted_cat_id=cat.cat_id, repository=current_repository)}}" class="form-inline">
+ <a title="Restaurer catégorie">
+ <button class="btn btn-default" type="submit">Restaurer</button>
+ </a>
+ </form>
+ </td>
+ {% endif %}
+ </tr>
+ <tr
+ {% if cat.state == "created" %}
+ class="success"
+ {% elif cat.state == "modified" %}
+ class="warning"
+ {% elif cat.state == "deleted" %}
+ class="danger"
+ {% endif %}>
+ <td colspan="5">
+ <div id="properties_{{cat.cat_id}}">
+ <dl class="dl-horizontal">
+ {% if cat.cat_properties|length == 0 %} <dt></dt><dd>Aucune autre propriété</dd>
{% else %}
- <td colspan="2">
- <form method="POST" action="{{url_for('cat_recap', deleted_cat_id=cat.cat_id, repository=current_repository)}}" class="form-inline">
- <a title="Restaurer catégorie">
- <button class="btn btn-default" type="submit">Restaurer</button>
- </a>
- </form>
- </td>
+ {% for (predicate, object) in cat.cat_properties %}
+ <dt>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</dt>
+ <dd>
+ {% 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" %}
+ <a href="{{ object }}">{{ object }}</a>
+ {% else %}
+ {{ object }}
+ {% endif %}
+ </dd>
+ {% endfor %}
{% endif %}
- </tr>
- <tr
- {% if cat.state == "created" %}
- class="success"
- {% elif cat.state == "modified" %}
- class="warning"
- {% elif cat.state == "deleted" %}
- class="danger"
- {% endif %}>
- <td colspan="5">
- <div id="properties_{{cat.cat_id}}">
- <dl class="dl-horizontal">
- {% if cat.cat_properties|length == 0 %} <dt></dt><dd>Aucune autre propriété</dd>
- {% else %}
- {% for (predicate, object) in cat.cat_properties %}
- <dt>{{ config["PROPERTY_LIST"][predicate]["descriptive_label_fr"] }}</dt>
- <dd>
- {% 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" %}
- <a href="{{ object }}">{{ object }}</a>
- {% else %}
- {{ object }}
- {% endif %}
- </dd>
- {% endfor %}
- {% endif %}
- </dl>
- </div>
- </td>
- </tr>
- {% endfor %}
- {% endif %}
- {% endif %}
- </tbody>
- </table>
- {% if session.get("user_logged") %}
- <form method="POST" action="{{url_for('cat_recap', repository=current_repository)}}" class="form-inline">
- <h4> Annuler tous mes changements actuels :
- <a title="Supprimer changements">
- <button type="submit" class="btn btn-default" {% if readonly %}disabled{% endif %}>
- <span class="glyphicon glyphicon-remove"/>
- </button>
- </a>
- </h4>
- </form>
- <h4> Soumettre mes changements actuels : <a href="{{ url_for('cat_modifs', repository=current_repository)}}" title="Soumettre changements" class="btn btn-default" {% if readonly %}disabled{% endif %}><span class="glyphicon glyphicon-share"/></a>
- </h4>
+ </dl>
+ </div>
+ </td>
+ </tr>
+ {% endfor %}
{% endif %}
- <h3> Consulter l'historique des modifications : <a href="https://github.com/{{config['REPOSITORY_OWNER']}}/{{config['REPOSITORY_NAME']}}/commits/master" title="Aller à l'historique des modifications sur Github" class="btn btn-default"><span class="glyphicon glyphicon-list"/></a></h3>
- </div>
- </body>
-</html>
+ {% endif %}
+ </tbody>
+ </table>
+ {% if session.get("user_logged") %}
+ <form method="POST" action="{{url_for('cat_recap', repository=current_repository)}}" class="form-inline">
+ <h4> Annuler tous mes changements actuels :
+ <a title="Supprimer changements">
+ <button type="submit" class="btn btn-default" {% if readonly %}disabled{% endif %}>
+ <span class="glyphicon glyphicon-remove"/>
+ </button>
+ </a>
+ </h4>
+ </form>
+ <h4> Soumettre mes changements actuels : <a href="{{ url_for('cat_modifs', repository=current_repository)}}" title="Soumettre changements" class="btn btn-default" {% if readonly %}disabled{% endif %}><span class="glyphicon glyphicon-share"/></a>
+ </h4>
+ {% endif %}
+ <h3> Consulter l'historique des modifications : <a href="https://github.com/{{config['REPOSITORY_OWNER']}}/{{config['REPOSITORY_NAME']}}/commits/master" title="Aller à l'historique des modifications sur Github" class="btn btn-default"><span class="glyphicon glyphicon-list"/></a></h3>
+{% endblock page_content %}
--- a/src/catedit/views.py Sat Jan 03 00:15:51 2015 +0100
+++ b/src/catedit/views.py Mon Jan 05 18:03:55 2015 +0100
@@ -46,8 +46,13 @@
@app.route('/', methods=['GET'])
@app.route('/index', methods=['GET'])
def cat_index():
+ """
+ View for index page (for now it's only a readme text so no computing
+ is required)
+ """
return render_template("catindex.html")
+
@app.route('/<string:repository>/catrecap',
defaults={'deleted_cat_id': None, 'deleted_modifs_id': None},
methods=['GET', 'POST'])
@@ -73,30 +78,36 @@
if request.method == "POST":
if (session.get("user_logged", None) is not None and
session.get("user_can_edit", False) is not False):
- if (deleted_modifs_id is None and deleted_cat_id is None):
+ if deleted_modifs_id is None and deleted_cat_id is None:
cat_changes_api_instance.delete(repository=repository)
elif deleted_modifs_id is not None:
logger.debug("Changes for category "
+ deleted_modifs_id
+ " will be deleted.")
- cat_changes_api_instance.delete(repository=repository, modified_cat_id=deleted_modifs_id)
+ cat_changes_api_instance.delete(
+ repository=repository,
+ modified_cat_id=deleted_modifs_id
+ )
# We identify if we want to delete a category
elif deleted_cat_id is not None:
logger.debug("Category "
+ deleted_cat_id
+ " will be deleted.")
- cat_api_instance.delete(repository=repository, deleted_cat_id=deleted_cat_id)
- return redirect(url_for('cat_recap',repository=repository))
+ cat_api_instance.delete(
+ repository=repository,
+ deleted_cat_id=deleted_cat_id
+ )
+ return redirect(url_for('cat_recap', repository=repository))
elif request.method == "GET":
- deleted_cat_list = []
- modified_cat_list = []
+ deleted_cat_dict = {}
+ modified_cat_dict = {}
serialized_cat_list = []
if session.get("user_logged", None) is not None:
serialized_cat_list = cat_api_instance.get(repository=repository)
cat_changes = cat_changes_api_instance.get(repository=repository)
- modified_cat_list = cat_changes[0]["modified_categories"]
- deleted_cat_list = cat_changes[0]["deleted_categories"]
+ modified_cat_dict = cat_changes[0]["modified_categories"]
+ deleted_cat_dict = cat_changes[0]["deleted_categories"]
# logger.debug(serialized_cat_list)
cat_list = []
original_cat_list = []
@@ -107,18 +118,20 @@
original_cat_list.append(Category(graph=cat_rdf_graph))
edited_cat_list = []
- for modified_cat in modified_cat_list:
+ for modified_cat_name in modified_cat_dict.keys():
new_cat_rdf_graph = Graph()
- new_cat_rdf_graph.parse(source=StringIO(
- modified_cat["content"]
- ),
- format='turtle')
+ new_cat_rdf_graph.parse(
+ source=StringIO(
+ modified_cat_dict[modified_cat_name]
+ ),
+ format='turtle'
+ )
edited_cat_list.append(Category(graph=new_cat_rdf_graph))
# first we find the untouched, edited and deleted categories
- cat_state=""
+ cat_state = ""
for category in original_cat_list:
- if category.cat_id not in [category["name"] for category in modified_cat_list]:
- if category.cat_id in [cat["name"] for cat in deleted_cat_list]:
+ if category.cat_id not in modified_cat_dict.keys():
+ if category.cat_id in deleted_cat_dict.keys():
cat_state = "deleted"
else:
cat_state = "untouched"
@@ -130,13 +143,17 @@
"state": cat_state})
# now we must find the not yet submitted categories that were created
- cat_state=""
- logger.debug("Edited cat list: "+str(edited_cat_list)+" - Original cat list: "+str(original_cat_list))
+ cat_state = ""
+ logger.debug("Edited cat list: "
+ + str(edited_cat_list)
+ + " - Original cat list: "
+ + str(original_cat_list))
for category in edited_cat_list:
- if category.cat_id not in [cat.cat_id for cat in original_cat_list]:
- cat_state="created"
+ if category.cat_id not in [cat.cat_id for
+ cat in original_cat_list]:
+ cat_state = "created"
else:
- cat_state="modified"
+ cat_state = "modified"
cat_list.append({"cat_label": category.label,
"cat_description": category.description,
"cat_id": category.cat_id,
@@ -144,11 +161,12 @@
"state": cat_state})
# logger.debug(c.properties)
- cat_list = sorted(cat_list, key=lambda cat: cat['cat_id'])
+ cat_list = sorted(cat_list, key=lambda cat: cat['cat_id'])
return render_template('catrecap.html',
cat_list=cat_list,
current_repository=repository)
+
@app.route('/<string:repository>/catmodifs/delete-modifs-<deleted_modifs_id>',
defaults={'deleted_cat_id': None},
methods=['POST'])
@@ -170,6 +188,7 @@
logger.debug(repository)
cat_list = []
+ changes_list = []
modified_cat_list = []
created_cat_list = []
deleted_cat_namelist = []
@@ -185,8 +204,12 @@
# display the changes
if request.method == "GET":
if session.get("user_logged", None) is not None:
- serialized_cat_list = cat_api_instance.get(repository=repository)
- changes_list = cat_changes_api_instance.get(repository=repository)[0]
+ serialized_cat_list = cat_api_instance.get(
+ repository=repository
+ )
+ changes_list = cat_changes_api_instance.get(
+ repository=repository
+ )[0]
# Creating existing cat list
for serialized_cat in serialized_cat_list:
@@ -201,12 +224,13 @@
"cat_properties": cat.properties})
# Creating modified and created cat lists
- for modified_category in \
- changes_list.get("modified_categories", []):
+ for modified_cat_name in \
+ changes_list.get("modified_categories", {}).keys():
modified_cat_rdf_graph = Graph()
modified_cat_rdf_graph.parse(
source=StringIO(
- modified_category["content"]
+ changes_list["modified_categories"]
+ [modified_cat_name]
),
format='turtle'
)
@@ -227,14 +251,12 @@
"cat_properties": modified_cat.properties})
# Creating deleted cat list
- deleted_cat_namelist = [
- element["name"] for element in
- changes_list.get("deleted_categories", [])
- ]
- modified_cat_namelist = [
- element["name"] for element in
- changes_list.get("modified_categories", [])
- ]
+ deleted_cat_namelist = list(
+ changes_list["deleted_categories"].keys()
+ )
+ modified_cat_namelist = list(
+ changes_list["modified_categories"].keys()
+ )
return render_template('catmodifs.html',
cat_list=cat_list,
created_cat_list=created_cat_list,
@@ -249,26 +271,34 @@
if commit_form.validate_on_submit():
cat_api_instance.put(repository=repository)
cat_changes_api_instance.delete(repository=repository)
- return redirect(url_for('cat_recap',repository=repository))
+ return redirect(url_for('cat_recap', repository=repository))
# One of the ids is not None (either deleting a category or a modification)
else:
# We only do that if we have a POST
if request.method == "POST":
# We identify if we want to delete a change
- if (session.get("user_logged", None) is not None and
- session.get("user_can_edit", False) is not False):
+ if (session.get("user_logged", None) is not None) \
+ and \
+ (session.get("user_can_edit", False) is not False):
if deleted_modifs_id is not None:
- cat_changes_api_instance.delete(repository=repository,
- modified_cat_id=deleted_modifs_id)
+ cat_changes_api_instance.delete(
+ repository=repository,
+ modified_cat_id=deleted_modifs_id
+ )
# We identify if we want to delete a category
elif deleted_cat_id is not None:
- cat_api_instance.delete(repository=repository, deleted_cat_id=deleted_cat_id)
+ cat_api_instance.delete(
+ repository=repository,
+ deleted_cat_id=deleted_cat_id
+ )
return redirect(url_for('cat_modifs', repository=repository))
-@app.route('/<string:repository>/cateditor', methods=['GET', 'POST'])
-@app.route('/<string:repository>/cateditor/<string:cat_id>', methods=['GET', 'POST'])
+@app.route('/<string:repository>/cateditor',
+ methods=['GET', 'POST'])
+@app.route('/<string:repository>/cateditor/<string:cat_id>',
+ methods=['GET', 'POST'])
def cat_editor(repository, cat_id=None):
"""
View that handles creation and edition of categories. Template is
@@ -282,16 +312,13 @@
cat_list = []
deleted_cat_list = []
+ modified_cat_dict = {}
serialized_cat_list = []
if session.get("user_logged", None) is not None:
serialized_cat_list = cat_api_instance.get(repository)
- cat_changes=cat_changes_api_instance.get(repository)
- deleted_cat_list = [
- category["name"] for category in cat_changes[0]["deleted_categories"]
- ]
- modified_cat_list = [
- category for category in cat_changes[0]["modified_categories"]
- ]
+ cat_changes = cat_changes_api_instance.get(repository)
+ deleted_cat_list = list(cat_changes[0]["deleted_categories"].keys())
+ modified_cat_dict = cat_changes[0]["modified_categories"]
for serialized_cat in serialized_cat_list:
cat_rdf_graph = Graph()
cat_rdf_graph.parse(source=StringIO(serialized_cat),
@@ -303,11 +330,11 @@
"cat_id": cat.cat_id,
"cat_properties": cat.properties})
- for modified_cat in modified_cat_list:
- if modified_cat["name"] not in [cat["cat_id"] for cat in cat_list]:
+ for modified_cat_name in modified_cat_dict.keys():
+ if modified_cat_name not in [cat["cat_id"] for cat in cat_list]:
modified_cat_rdf_graph = Graph()
modified_cat_rdf_graph.parse(
- source=StringIO(modified_cat["content"]),
+ source=StringIO(modified_cat_dict[modified_cat_name]),
format='turtle'
)
modified_cat = Category(graph=modified_cat_rdf_graph)
@@ -318,15 +345,22 @@
if cat_id is not None:
specific_serialized_cat = ""
- changes_response = cat_changes_api_instance.get(repository=repository, modified_cat_id=cat_id)
+ changes_response = cat_changes_api_instance.get(
+ repository=repository,
+ modified_cat_id=cat_id
+ )
# that means the category was modified or deleted
if changes_response != 404:
logger.debug(changes_response)
if changes_response[0]["type"] is not "deleted":
- specific_serialized_cat = changes_response[0]["category"] \
- ["content"]
+ specific_serialized_cat = changes_response[0] \
+ ["category"] \
+ [cat_id]
else:
- specific_serialized_cat = cat_api_instance.get(repository=repository, cat_id=cat_id)
+ specific_serialized_cat = cat_api_instance.get(
+ repository=repository,
+ cat_id=cat_id
+ )
logger.debug(specific_serialized_cat)
cat_rdf_graph = Graph()
cat_rdf_graph.parse(source=StringIO(specific_serialized_cat),
@@ -362,8 +396,7 @@
# PUT + cat_id = Submit edited cat, only if cat is not already
# in deleted categories
if cat_form.validate_on_submit() and cat.cat_id not in \
- [element["name"] for element in
- cat_changes[0]["deleted_categories"]]:
+ cat_changes[0]["deleted_categories"].keys():
if (session.get("user_logged", None) is not None and
session.get("user_can_edit", False) is not False):
cat_api_instance.put(repository=repository, cat_id=cat_id)
@@ -425,11 +458,18 @@
if getattr(catedit.persistence,
app.config["PERSISTENCE_METHOD"])().session_compliant is True:
session["save_user_changes"] = True
- session["modified_categories"] = {repo: [] for repo in app.config["REPOSITORY_LIST"]}
- session["deleted_categories"] = {repo: [] for repo in app.config["REPOSITORY_LIST"]}
+ session["modified_categories"] = {
+ repo: {} for repo in app.config["REPOSITORY_LIST"]
+ }
+ session["deleted_categories"] = {
+ repo: {} for repo in app.config["REPOSITORY_LIST"]
+ }
if app.config["PERSISTENCE_METHOD"] == "PersistenceToGithub":
logger.debug(str(github.get("rate_limit")["resources"]))
- return github.authorize(scope="repo", redirect_uri=url_for('github_callback', _external=True))
+ return github.authorize(
+ scope="repo",
+ redirect_uri=url_for('github_callback', _external=True)
+ )
elif app.config["PERSISTENCE_METHOD"] == "PersistenceToFile":
session["user_logged"] = True
session["user_can_edit"] = True
@@ -469,7 +509,7 @@
except GitHubError as ghe:
logger.debug(
"GitHubError trying to get the list of repository for user "
- +session["user_login"]
+ + session["user_login"]
)
logger.debug(ghe.request.text)
return redirect(url_for('cat_index'))
@@ -500,6 +540,10 @@
session["user_login"] = None
session["user_can_edit"] = None
session["save_user_changes"] = None
- session["modified_categories"] = {repo: [] for repo in app.config["REPOSITORY_LIST"]}
- session["deleted_categories"] = {repo: [] for repo in app.config["REPOSITORY_LIST"]}
+ session["modified_categories"] = {
+ repo: {} for repo in app.config["REPOSITORY_LIST"]
+ }
+ session["deleted_categories"] = {
+ repo: {} for repo in app.config["REPOSITORY_LIST"]
+ }
return redirect(url_for('cat_index'))