src/catedit/views/utils.py
author ymh <ymh.work@gmail.com>
Tue, 14 Apr 2015 12:31:07 +0200
changeset 91 59450d864881
parent 53 0acc8b2adcb9
child 97 fe8782a67fcf
permissions -rw-r--r--
add task indicator + some cleaning tasks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53
0acc8b2adcb9 fixed error when creating discussion + adjusted readme on homepage to reflect discussion interface changes
durandn
parents: 47
diff changeset
     1
#!/usr/bin/env python
91
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
     2
# -*- coding: utf-8 -*-
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
     3
"""
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
     4
utils.py:
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
     5
Module that groups utility functions and classes that are used by views,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
     6
partly because most of them do requests to the Github API and as such must
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
     7
be cached
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
     8
"""
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
     9
91
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
    10
from catedit import app, github, cache, log_api_rate, save_links, celery
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    11
from catedit.models import Category
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    12
from catedit.resources import CategoryAPI, CategoryChangesAPI
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    13
from flask import redirect, url_for, session
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    14
from flask.ext.github import GitHubError
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    15
from datetime import datetime
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    16
from rdflib import Graph
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    17
from base64 import b64decode
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    18
from io import StringIO
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    19
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    20
logger = app.logger
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    21
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    22
class Pagination(object):
43
6d0e2523e17d Pep8/Pylint small changes
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 42
diff changeset
    23
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    24
    def __init__(self, page, per_page, last_page):
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    25
        self.page = page
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    26
        self.last_page = last_page
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    27
        self.per_page = per_page
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    28
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    29
    @property
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    30
    def pages(self):
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    31
        return self.last_page
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    32
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    33
    @property
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    34
    def has_prev(self):
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    35
        return self.page > 1
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    36
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    37
    @property
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    38
    def has_next(self):
46
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    39
        return self.page < self.pages
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    40
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    41
    def iter_pages(self, left_edge=2, left_current=2,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    42
                   right_current=5, right_edge=2):
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    43
        last = 0
46
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    44
        for num in range(1, self.pages+1):
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    45
            if num <= left_edge or \
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    46
               (num > self.page - left_current - 1 and \
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    47
                num < self.page + right_current) or \
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    48
               num > self.pages+1 - right_edge:
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    49
                if last + 1 != num:
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    50
                    yield None
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    51
                yield num
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
    52
                last = num
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    53
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    54
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    55
def check_user_status_and_repo_access(repository):
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    56
    """
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    57
        Function to call at the beginning of every view that would require
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    58
        authentication and editing privilege to work properly (basically
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    59
        everything save login and index page)
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    60
    """
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    61
    if repository not in app.config["PERSISTENCE_CONFIG"]["REPOSITORY_LIST"]:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    62
        return redirect(url_for("home.index"))
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    63
    if not session.get("user_logged", None):
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    64
        return redirect(url_for("home.index"))
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    65
    if not session.get("user_can_edit", {}).get(repository, False):
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    66
        return redirect(url_for("home.index"))
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    67
43
6d0e2523e17d Pep8/Pylint small changes
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 42
diff changeset
    68
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    69
def get_comments(repository, thread_type, thread_id, page=1, per_page=30):
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    70
    """
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    71
        Function that takes the following args:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    72
            * repository: the repository from which to get comments from
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    73
            * type: either "issues" or "commits"
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    74
            * id: the id of the issue of commit to get comments from
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    75
            * page: the page of comments to get
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
    76
            * per_page: the number of comments per page
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    77
        then builds a comment list with each comment being a dict with the
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    78
        following format:
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    79
        {
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    80
            "author": author of the comment
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    81
            "body": body of the comment
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    82
            "date": date of the comment format dd/mm/yy hh:mm
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    83
        }
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    84
    """
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    85
    cache_key = "get_comments_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    86
                + repository + "_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    87
                + thread_type + "_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    88
                + thread_id + "_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    89
                + str(page) + "_" + str(per_page)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    90
    if cache.get(cache_key) is None:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    91
        github_comments_data = []
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
    92
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    93
        try:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    94
            github_comments_data = github.get(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    95
                "repos/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    96
                + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"] + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    97
                + repository + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    98
                + thread_type + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
    99
                + thread_id
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   100
                + "/comments?per_page=" + str(per_page)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   101
                + "&page=" + str(page),
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   102
                hooks=dict(response=save_links)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   103
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   104
        except GitHubError as ghe:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   105
            logger.error(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   106
                "Error trying to get comments with following data:"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   107
                + " - repository : " + repository
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   108
                + " - thread_type : " + thread_type
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   109
                + " - thread_id : " + thread_id
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   110
                + " - page : " + page
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   111
                + " - per_page : " + per_page
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   112
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   113
            logger.error(ghe.response.text)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   114
        pagination = None
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   115
        if session.get("pagination_links", None) is not None:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   116
            # If there are multiple pages we create a pagination class that
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   117
            # will be sent to the template
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   118
            pagination = Pagination(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   119
                page=session["pagination_links"]["current_page"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   120
                per_page=per_page,
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   121
                last_page=session["pagination_links"]["last_page"]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   122
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   123
            session.pop("pagination_links", None)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   124
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   125
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   126
        comment_list = []
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   127
        for comment in github_comments_data:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   128
            comment_dict = {
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   129
                "author": comment["user"]["login"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   130
                "body": comment["body"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   131
                "date": convert_github_date(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   132
                    comment["created_at"]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   133
                )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   134
            }
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   135
            comment_list.append(comment_dict)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   136
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   137
        discussion_data = {}
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   138
        try:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   139
            discussion_data = github.get(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   140
                "repos/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   141
                + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"] + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   142
                + repository + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   143
                + thread_type + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   144
                + thread_id,
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   145
                hooks=dict(response=log_api_rate)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   146
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   147
        except GitHubError as ghe:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   148
            logger.error(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   149
                "Error trying to get the commit or issue of id " + thread_id
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   150
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   151
            logger.error(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   152
                "endpoint: " + "repos/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   153
                + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"] + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   154
                + repository + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   155
                + thread_type + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   156
                + thread_id
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   157
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   158
            logger.error(ghe.response.text)
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   159
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   160
        thread_author = ""
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   161
        thread_opening_date = ""
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   162
        thread_title = ""
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   163
        thread_opening_post = ""
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   164
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   165
        if thread_type == "commits":
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   166
            thread_author = discussion_data.get("author", {}).get("login", "")
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   167
            thread_opening_date = convert_github_date(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   168
                discussion_data.get(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   169
                    "commit",
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   170
                    {}
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   171
                ).get(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   172
                    "author",
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   173
                    {}
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   174
                ).get("date", "")
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   175
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   176
            thread_title = discussion_data.get("commit", {}).get("message", "")
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   177
        elif thread_type == "issues":
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   178
            thread_author = discussion_data.get("user", {}).get("login", "")
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   179
            thread_opening_date = convert_github_date(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   180
                discussion_data.get("created_at", "0001-01-01T00:00:00Z")
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   181
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   182
            thread_title = discussion_data.get("title", "")
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   183
            thread_opening_post = discussion_data.get("body", "")
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   184
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   185
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   186
        thread_dict = {
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   187
            "author": thread_author,
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   188
            "title": thread_title,
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   189
            "opening_date": thread_opening_date,
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   190
            "comment_list": comment_list,
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   191
            "opening_post": thread_opening_post,
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   192
            "per_page": per_page
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   193
        }
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   194
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   195
        cache.set(cache_key, (thread_dict, pagination), timeout=3600)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   196
        return (thread_dict, pagination)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   197
    else:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   198
        return cache.get(cache_key)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   199
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   200
def post_comment(repository, thread_type, thread_id,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   201
                 comment_body, thread_title=""):
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   202
    """
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   203
        Function that posts a given comment to github.
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   204
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   205
        * repository is the repository to post in
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   206
        * type is either "issues" or "commits"
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   207
        * thread_id is the id of the issue or the commit to comment
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   208
        * thread_title is the title of the new issue, if we're posting a new
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   209
        issue
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   210
        * comment_body is the content of the comment
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   211
    """
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   212
    comment_data = {
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   213
        "body": comment_body
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   214
    }
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   215
    return_id = ""
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   216
    if thread_id != "new":
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   217
        try:
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   218
            github_response = github.post(
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   219
                "repos/"
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   220
                + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"] + "/"
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   221
                + repository + "/"
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   222
                + thread_type + "/"
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   223
                + thread_id
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   224
                + "/comments",
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   225
                data=comment_data,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   226
                hooks=dict(response=log_api_rate)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   227
            )
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   228
            return_id = thread_id
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   229
        except GitHubError as ghe:
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   230
            logger.error(
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   231
                "Error posting comment with following data: "
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   232
                + " - repository : " + repository
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   233
                + " - thread_id : " + thread_id
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   234
                + " - thread_type : " + thread_type
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   235
                + " - comment_body : " + comment_body
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   236
            )
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   237
            logger.error(ghe.response.text)
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   238
    else:
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   239
        # We're posting a new issue
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   240
        comment_data["title"] = thread_title
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   241
        try:
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   242
            github_response = github.post(
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   243
                "repos/"
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   244
                + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"] + "/"
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   245
                + repository + "/"
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   246
                + thread_type,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   247
                data=comment_data,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   248
                hooks=dict(response=log_api_rate)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   249
            )
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   250
            return_id = str(github_response["number"])
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   251
        except GitHubError as ghe:
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   252
            logger.error(
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   253
                "Error posting new issue with following data: "
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   254
                + " - repository : " + repository
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   255
                + " - thread_id : " + thread_id
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   256
                + " - thread_type : " + thread_type
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   257
                + " - thread_title : " + thread_title
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   258
                + " - comment_body : " + comment_body
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   259
            )
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   260
            logger.error(ghe.response.text)
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   261
    cache.clear()
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   262
    return return_id
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   263
43
6d0e2523e17d Pep8/Pylint small changes
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 42
diff changeset
   264
46
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   265
def get_commits(repository, per_page, page):
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   266
    """
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   267
        Fuction that get the list of commits for a given repository. Returns a
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   268
        list of dict with the format:
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   269
        {
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   270
            id : commit id
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   271
            title : commit message
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   272
            author : commit author
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   273
            comment_count : commit comments count
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   274
        }
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   275
    """
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   276
    cache_key = "get_commits_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   277
                + repository + "_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   278
                + str(page) + "_" + str(per_page)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   279
    if cache.get(cache_key) is None:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   280
        commits_data = []
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   281
        try:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   282
            commits_data = github.get(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   283
                "repos/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   284
                + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"] + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   285
                + repository
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   286
                + "/commits?per_page=" + str(per_page) + "&page=" + str(page),
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   287
                hooks=dict(response=save_links)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   288
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   289
        except GitHubError as ghe:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   290
            logger.error("Error getting commits for repo " + repository)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   291
            logger.error(ghe.response.text)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   292
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   293
        commits_pagination = None
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   294
        if session.get("pagination_links", None) is not None:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   295
            commits_pagination = Pagination(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   296
                page=session["pagination_links"]["current_page"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   297
                per_page=per_page,
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   298
                last_page=session["pagination_links"]["last_page"]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   299
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   300
            session.pop("pagination_links", None)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   301
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   302
        changeset_list = [
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   303
            {
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   304
                "id": commit["sha"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   305
                "title": commit["commit"]["message"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   306
                "date": convert_github_date(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   307
                    commit["commit"]["committer"]["date"]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   308
                ),
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   309
                "author": commit["commit"]["committer"]["name"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   310
                "comment_count": commit["commit"]["comment_count"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   311
            }
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   312
            for commit in commits_data
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   313
        ]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   314
        cache.set(cache_key, (changeset_list, commits_pagination), timeout=3600)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   315
        return (changeset_list, commits_pagination)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   316
    else:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   317
        return cache.get(cache_key)
43
6d0e2523e17d Pep8/Pylint small changes
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 42
diff changeset
   318
46
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   319
def get_issues(repository, per_page=30, page=1):
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   320
    """
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   321
        Fuction that get the list of issues for a given repository. Returns a
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   322
        list of dict with the format:
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   323
        {
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   324
            id: issue id
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   325
            title: issue title
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   326
            author: issue author
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   327
            opening_date: issue opening date
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   328
            last_updated: last update date
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   329
            comment_count: comments count
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   330
        }
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   331
    """
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   332
    cache_key = "get_issues_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   333
                + repository + "_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   334
                + str(page) + "_" + str(per_page)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   335
    if cache.get(cache_key) is None:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   336
        issues_data = []
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   337
        try:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   338
            issues_data = github.get(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   339
                "repos/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   340
                + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"] + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   341
                + repository
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   342
                + "/issues?per_page=" + str(per_page) + "&page=" + str(page),
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   343
                hooks=dict(response=save_links)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   344
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   345
        except GitHubError as ghe:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   346
            logger.error("Error getting issues for repo " + repository)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   347
            logger.error(ghe.response.text)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   348
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   349
        discussions_pagination = None
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   350
        if session.get("pagination_links", None) is not None:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   351
            discussions_pagination = Pagination(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   352
                page=session["pagination_links"]["current_page"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   353
                per_page=per_page,
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   354
                last_page=session["pagination_links"]["last_page"]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   355
            )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   356
            session.pop("pagination_links", None)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   357
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   358
        discussion_list = [
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   359
            {
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   360
                "id": str(issue["number"]),
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   361
                "title": issue["title"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   362
                "author": issue["user"]["login"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   363
                "opening_date": convert_github_date(issue["created_at"]),
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   364
                "last_updated": convert_github_date(issue["updated_at"]),
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   365
                "comment_count": issue["comments"],
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   366
            }
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   367
            for issue in issues_data
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   368
        ]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   369
        cache.set(cache_key, (discussion_list, discussions_pagination), timeout=3600)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   370
        return (discussion_list, discussions_pagination)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   371
    else:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   372
        return cache.get(cache_key)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   373
43
6d0e2523e17d Pep8/Pylint small changes
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 42
diff changeset
   374
46
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   375
def get_category_list_for_commit(repository, changeset_id, get_parent=False):
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   376
    """
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   377
        Get the category list as it was following the changeset of
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   378
        id changeset_id
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   379
    """
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   380
    cache_key = "get_category_list_for_commit_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   381
                + repository + "_" \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   382
                + changeset_id + "_parent_" + str(get_parent)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   383
    if cache.get(cache_key) is None:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   384
        # First step
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   385
        commit_data = {}
46
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   386
        try:
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   387
            commit_data = github.get(
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   388
                "repos/"
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   389
                + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"] + "/"
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   390
                + repository + "/commits/"
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   391
                + changeset_id
46
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   392
            )
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   393
        except GitHubError as ghe:
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   394
            logger.error(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   395
                "Error trying to get the commit of id " + changeset_id
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   396
            )
46
5bd3fb023396 Added pagination to commit list and issue list + changeset page now display categories before and after modifications
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 45
diff changeset
   397
            logger.error(ghe.response.text)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   398
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   399
        parent_sha = ""
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   400
        if get_parent:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   401
            parents = commit_data.get("parents", [])
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   402
            if parents != []:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   403
                parent_sha = parents[0].get("sha", "")
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   404
            try:
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   405
                commit_data = github.get(
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   406
                    "repos/"
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   407
                    + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"]
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   408
                    + "/" + repository + "/commits/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   409
                    + parent_sha
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   410
                )
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   411
            except GitHubError as ghe:
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   412
                logger.error(
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   413
                    "Error trying to get the commit of id " + parent_sha
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   414
                )
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   415
                logger.error(ghe.response.text)
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   416
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   417
        tree_sha = commit_data.get("commit", {}).get("tree", {}).get("sha", "")
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   418
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   419
        # Second step
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   420
        tree_data = {}
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   421
        try:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   422
            tree_data = github.get(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   423
                "repos/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   424
                + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"] + "/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   425
                + repository + "/git/trees/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   426
                + commit_data["commit"]["tree"]["sha"]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   427
                + "?recursive=1"
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   428
            )
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   429
        except GitHubError as ghe:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   430
            logger.error("Error trying to get the tree of sha " + tree_sha)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   431
            logger.error(ghe.response.text)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   432
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   433
        # Third step and fourth step
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   434
        cat_list = []
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   435
        for blob in tree_data.get("tree", []):
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   436
            if app.config["PERSISTENCE_CONFIG"]["CATEGORIES_PATH"] \
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   437
            in blob["path"]:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   438
                blob_data = {}
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   439
                try:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   440
                    blob_data = github.get(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   441
                        "repos/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   442
                        + app.config["PERSISTENCE_CONFIG"]["REPOSITORY_OWNER"]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   443
                        + "/" + repository + "/git/blobs/"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   444
                        + blob["sha"]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   445
                    )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   446
                except GitHubError as ghe:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   447
                    logger.error(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   448
                        "Error trying to get the blob of sha " + blob["sha"]
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   449
                    )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   450
                    logger.error(ghe.response.text)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   451
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   452
                cat_graph = Graph()
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   453
                cat_graph.parse(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   454
                    source=StringIO(
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   455
                        str(b64decode(blob_data["content"]), "utf-8")
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   456
                    ),
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   457
                    format="turtle"
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   458
                )
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   459
                category = Category(graph=cat_graph)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   460
                cat_list.append(category)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   461
        cache.set(cache_key, cat_list, timeout=3600)
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   462
        return cat_list
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   463
    else:
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   464
        return cache.get(cache_key)
42
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   465
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   466
def convert_github_date(date):
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   467
    """
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   468
        Function that converts github date format to a
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   469
        "dd/mm/yyyy à hh:mm" format
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   470
    """
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   471
    return datetime.strptime(
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   472
        date,
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   473
        "%Y-%m-%dT%H:%M:%SZ"
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   474
    ).strftime(
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   475
        "%d/%m/%Y à %H:%M"
dac9b1248e0f V0.1.4: Implemented github social functions into CatEdit: refactored template and views hierarchy, names, views submodule, created macro to generate category tables + small esthetic changes (buttons to display categories/tables switch state, possibility to hide tables) + views modules have been converted into Flask Blueprints
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents:
diff changeset
   476
    )
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   477
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   478
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   479
def get_current_category_list(repository, with_local_changes=True):
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   480
    """
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   481
        Shortcut function that generates the list of category to use for
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   482
        view templates.
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   483
        Each category is a dict with the following format:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   484
        {
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   485
            "cat_label": category label,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   486
             "cat_description": category description,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   487
             "cat_id": category id,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   488
             "cat_properties": category properties,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   489
             "state": category state (one of {"untouched", "created",
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   490
             "edited", "deleted"})
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   491
        }
47
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   492
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   493
        Caching it is unecessary because the API call to get the list is
ddba4624d661 Added cache support for getting issues, commits and comments + reworked workshop page, now displaying latest changes and latest opened issues and links to changeset and issues list + changeset page now displays a change summary
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 46
diff changeset
   494
        already cached
45
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   495
    """
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   496
    cat_api_instance = CategoryAPI()
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   497
    cat_changes_api_instance = CategoryChangesAPI()
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   498
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   499
    deleted_cat_dict = {}
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   500
    modified_cat_dict = {}
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   501
    serialized_cat_list = []
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   502
    if session.get("user_logged", None) is not None:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   503
        serialized_cat_list = cat_api_instance.get(repository=repository) \
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   504
                                                  [0]
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   505
        cat_changes = cat_changes_api_instance.get(repository=repository) \
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   506
                                                  [0]
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   507
        modified_cat_dict = cat_changes["modified_categories"]
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   508
        deleted_cat_dict = cat_changes["deleted_categories"]
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   509
    # logger.debug(serialized_cat_list)
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   510
    cat_list = []
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   511
    original_cat_list = []
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   512
    for serialized_cat in serialized_cat_list:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   513
        cat_rdf_graph = Graph()
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   514
        cat_rdf_graph.parse(source=StringIO(serialized_cat),
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   515
                            format='turtle')
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   516
        original_cat_list.append(Category(graph=cat_rdf_graph))
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   517
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   518
    if with_local_changes:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   519
        # We want the categories updated with the changes current user made
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   520
        edited_cat_list = []
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   521
        for modified_cat_name in modified_cat_dict.keys():
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   522
            new_cat_rdf_graph = Graph()
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   523
            new_cat_rdf_graph.parse(
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   524
                source=StringIO(
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   525
                    modified_cat_dict[modified_cat_name]
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   526
                ),
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   527
                format='turtle'
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   528
            )
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   529
            edited_cat_list.append(Category(graph=new_cat_rdf_graph))
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   530
        # first we find the untouched, edited and deleted categories
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   531
        cat_state = ""
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   532
        for category in original_cat_list:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   533
            if category.cat_id not in modified_cat_dict.keys():
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   534
                if category.cat_id in deleted_cat_dict.keys():
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   535
                    cat_state = "deleted"
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   536
                else:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   537
                    cat_state = "untouched"
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   538
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   539
                cat_list.append(
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   540
                    {
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   541
                        "cat_label": category.label,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   542
                        "cat_description": category.description,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   543
                        "cat_id": category.cat_id,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   544
                        "cat_properties": category.properties,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   545
                        "state": cat_state
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   546
                    }
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   547
                )
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   548
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   549
        # now we must find the not yet submitted categories that were created
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   550
        cat_state = ""
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   551
        for category in edited_cat_list:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   552
            if category.cat_id not in [cat.cat_id for
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   553
                                       cat in original_cat_list]:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   554
                cat_state = "created"
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   555
            else:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   556
                cat_state = "modified"
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   557
            cat_list.append({"cat_label": category.label,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   558
                             "cat_description": category.description,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   559
                             "cat_id": category.cat_id,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   560
                             "cat_properties": category.properties,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   561
                             "state": cat_state})
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   562
    else:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   563
        # We only want the categories
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   564
        for category in original_cat_list:
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   565
            cat_list.append(
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   566
                {
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   567
                    "cat_label": category.label,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   568
                    "cat_description": category.description,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   569
                    "cat_id": category.cat_id,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   570
                    "cat_properties": category.properties,
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   571
                    "state": "original"
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   572
                }
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   573
            )
1506da593f40 Caching fix (now works on views.categories submodule) and config (dict CACHE_CONFIG, see Flask-cache doc for expected values) + Pagination for comments (changeset & issues) + Hooks to log API rate consumption and get pagination info
Nicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
parents: 43
diff changeset
   574
    return cat_list
91
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   575
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   576
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   577
def get_tasks_status(task_ids_list, delete_task_from_session, repository) :
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   578
    logger.debug("get_tasks_status : %r " % task_ids_list)
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   579
    res = { 'states' : {} }
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   580
    running_tasks_nb = 0
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   581
    for task_id in task_ids_list:
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   582
        a_res = celery.AsyncResult(task_id)
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   583
        res['states'][task_id] = a_res.state
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   584
        if a_res.ready():
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   585
            a_res.forget()
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   586
            if delete_task_from_session:
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   587
                session.get('tasks',{}).get(repository, []).remove(task_id)
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   588
        else:
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   589
            running_tasks_nb += 1
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   590
    res['running_tasks_nb'] = running_tasks_nb
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   591
59450d864881 add task indicator + some cleaning tasks
ymh <ymh.work@gmail.com>
parents: 53
diff changeset
   592
    return res