13 Commits 001436bf3b ... 524549235a

Auteur SHA1 Message Date
  jocelyn 524549235a Merge branch 'ed-fix-readme' of milouse/transparency into master il y a 6 ans
  Étienne Deparis b36405eeb5 Remind user to activate the previously created virtualenv il y a 6 ans
  Étienne Deparis 9ac86efc66 Inform the naive user about the DEBUG parameter il y a 6 ans
  Étienne Deparis ae3e36be8b Fix a typo, which prevent the chosen organization name to be displayed il y a 6 ans
  Étienne Deparis aac960caea Explain how to create the first user account il y a 6 ans
  Étienne Deparis c1ef58cde1 Don't depend on virtualenvwrapper il y a 6 ans
  Jocelyn Delalande b786047025 Clarifie le bouton « éditer ». il y a 6 ans
  Jocelyn Delalande eb97c98f09 Passe en brouillon un rapport copié il y a 6 ans
  Jocelyn Delalande 5fb0eee519 Renommage « Document » → « Rapport » il y a 6 ans
  Jocelyn Delalande e80970ad4d Masquer la case description HTML de l'admin des coûts il y a 6 ans
  Jocelyn Delalande c9ad73b50b Parler de brouillon plutôt que de « étude ou estimation » il y a 6 ans
  jocelyn c5dd96653b Merge branch 'fix-7' of capslock/transparency into master il y a 6 ans
  CapsLock bbae318472 Fix #7 : erreur interne sur le site public lors de la consultation d'une installation fraiche il y a 6 ans

+ 12 - 4
README.md

@@ -9,8 +9,11 @@ Install it
 ----------
 ----------
 Be sure to use python3.
 Be sure to use python3.
 
 
-    sudo apt-get install python virtualenvwrapper
-    mkvirtualenv transparency
+    sudo apt-get install python virtualenv
+    virtualenv transparency_venv
+    git clone https://code.ffdn.org/jocelyn/transparency
+    cd transparency
+    source ../transparency_venv/bin/activate
     pip install -r requirements.txt
     pip install -r requirements.txt
 
 
 Generate a secret key:
 Generate a secret key:
@@ -19,18 +22,23 @@ Generate a secret key:
 
 
 Set your organization name :
 Set your organization name :
 
 
-    echo 'ORGANISATION_NAME="ACME Charity"' >> transparency/local_settings.py
+    echo 'ORGANIZATION_NAME="ACME Charity"' >> transparency/local_settings.py
 
 
 Create database:
 Create database:
 
 
     ./manage.py migrate
     ./manage.py migrate
 
 
+Create administrator account:
+
+    ./manage.py createsuperuser
+
 Run it
 Run it
 ------
 ------
 
 
 Run development server
 Run development server
 
 
-    workon transparency
+    source ../transparency_venv/bin/activate # if it is not already done
+    echo 'DEBUG=True' >> transparency/local_settings.py
     ./manage.py runserver
     ./manage.py runserver
 
 
 Use it
 Use it

+ 4 - 2
costs/admin.py

@@ -54,7 +54,7 @@ class DocumentAdmin(admin.ModelAdmin):
             edit_url = reverse('admin:costs_document_change', args=(new.pk,))
             edit_url = reverse('admin:costs_document_change', args=(new.pk,))
             self.message_user(
             self.message_user(
                 request, mark_safe(
                 request, mark_safe(
-                    "{} copié, pensez à <a href=\"{}\">L'éditer</a>".format(
+                    "{} a été créé, en tant que brouillon, pensez à <a href=\"{}\">l'éditer</a>.".format(
                         new, edit_url)))
                         new, edit_url)))
     copy.short_description = 'Copier'
     copy.short_description = 'Copier'
 
 
@@ -87,7 +87,7 @@ class ServiceUseInline(AbstractUseInline):
 
 
 
 
 class DirectDocumentFilter(admin.SimpleListFilter):
 class DirectDocumentFilter(admin.SimpleListFilter):
-    title = 'Document'
+    title = 'Rapport'
 
 
     parameter_name = 'document'
     parameter_name = 'document'
 
 
@@ -167,8 +167,10 @@ class ServiceAdmin(admin.ModelAdmin):
 @admin.register(Good)
 @admin.register(Good)
 class GoodAdmin(admin.ModelAdmin):
 class GoodAdmin(admin.ModelAdmin):
     list_filter = [DirectDocumentFilter]
     list_filter = [DirectDocumentFilter]
+    exclude = ['description_html']
 
 
 
 
 @admin.register(Cost)
 @admin.register(Cost)
 class CostAdmin(admin.ModelAdmin):
 class CostAdmin(admin.ModelAdmin):
     list_filter = [DirectDocumentFilter]
     list_filter = [DirectDocumentFilter]
+    exclude = ['description_html']

+ 7 - 5
costs/models.py

@@ -13,8 +13,8 @@ import markdown
 class Document(models.Model):
 class Document(models.Model):
     """ A document is a scenario or a record from facts, on 1 month.
     """ A document is a scenario or a record from facts, on 1 month.
     """
     """
-    TYPE_FACT = 'fact'
-    TYPE_PLAN = 'plan'
+    TYPE_PUBLIC = 'fact'
+    TYPE_DRAFT = 'plan'
 
 
     name = models.CharField('Nom', max_length=130)
     name = models.CharField('Nom', max_length=130)
     comment = models.TextField(
     comment = models.TextField(
@@ -25,12 +25,13 @@ class Document(models.Model):
         default=datetime.datetime.now,
         default=datetime.datetime.now,
         help_text="Date de création du document")
         help_text="Date de création du document")
     type = models.CharField(max_length=10, choices=(
     type = models.CharField(max_length=10, choices=(
-        (TYPE_FACT, 'rapport de transparence'),
-        (TYPE_PLAN, 'estimation ou étude'),
-    ))
+        (TYPE_PUBLIC, 'Rapport public'),
+        (TYPE_DRAFT, 'Rapport brouillon'),
+    ), help_text="Un rapport brouillon n'est pas visible publiquement")
 
 
     class Meta:
     class Meta:
         ordering = ['-date']
         ordering = ['-date']
+        verbose_name = 'Rapport'
 
 
     def __str__(self):
     def __str__(self):
         return self.name
         return self.name
@@ -51,6 +52,7 @@ class Document(models.Model):
             new_doc = Document.objects.get(pk=self.pk)
             new_doc = Document.objects.get(pk=self.pk)
             new_doc.pk = None
             new_doc.pk = None
             new_doc.name = 'COPIE DE {}'.format(new_doc.name)
             new_doc.name = 'COPIE DE {}'.format(new_doc.name)
+            new_doc.type = Document.TYPE_DRAFT
             new_doc.save()
             new_doc.save()
 
 
             new_services, new_costs, new_goods = {}, {}, {}
             new_services, new_costs, new_goods = {}, {}, {}

+ 3 - 4
costs/templates/costs/document_detail.html

@@ -19,7 +19,7 @@
 {% if request.user.is_staff %}
 {% if request.user.is_staff %}
 <a href="{% url 'admin:costs_document_change' document.id %}" class="item">
 <a href="{% url 'admin:costs_document_change' document.id %}" class="item">
   <i class="edit icon"></i>
   <i class="edit icon"></i>
-    Éditer
+    Éditer dans l'admin
 </a>
 </a>
 {% endif %}
 {% endif %}
 
 
@@ -41,13 +41,12 @@
 
 
 
 
 {% block content %}
 {% block content %}
-{% if document.type == document.TYPE_PLAN %}
+{% if document.type == document.TYPE_DRAFT %}
 <div class="ui yellow icon message">
 <div class="ui yellow icon message">
       <i class="warning icon"></i>
       <i class="warning icon"></i>
       <div class="content">
       <div class="content">
         <p>
         <p>
-          Ce document est un document de travail, exposant un scénario, et non
-un relevé.
+          Ce rapport est un brouillon, il n'est pas visible publiquement.
         </p>
         </p>
       </div>
       </div>
 </div>
 </div>

+ 4 - 8
costs/templates/costs/documents_list.html

@@ -25,7 +25,7 @@ Afin que tout un chacun puisse <strong>choisir son prix d'abonnement de manière
 <section class="ui row">
 <section class="ui row">
   <h2>Rapports de transparence</h2>
   <h2>Rapports de transparence</h2>
   <p class="ui text container">
   <p class="ui text container">
-    Ces documents correspondent à des relevés effectués en début de chaque
+    Ces rapports correspondent à des relevés effectués en début de chaque
   mois, ils peuvent être utilisés comme base au calcul du <strong>prix
   mois, ils peuvent être utilisés comme base au calcul du <strong>prix
   libre</strong>.
   libre</strong>.
   </p>
   </p>
@@ -36,15 +36,11 @@ Afin que tout un chacun puisse <strong>choisir son prix d'abonnement de manière
     ({{ doc.service_set.count }} service{{ doc.service_set.count|pluralize }})
     ({{ doc.service_set.count }} service{{ doc.service_set.count|pluralize }})
     </li>
     </li>
     {% empty %}
     {% empty %}
-    <li>Pas de documents pour l'heure.</li>
+    <li>Pas de rapport pour l'heure.</li>
     {% endfor %}
     {% endfor %}
   </ul>
   </ul>
 
 
-  <h2>Estimations et études</h2>
-  <p class="ui text container">
-    Ces documents ne sont pas issus de relevés mais servent d'outils pour
-  établir des budgets prévisionnels pour des services à venir.
-  </p>
+  <h2>Rapports brouillons</h2>
   <ul class="ui text container">
   <ul class="ui text container">
 {% for doc in planning_documents %}
 {% for doc in planning_documents %}
     <li>
     <li>
@@ -52,7 +48,7 @@ Afin que tout un chacun puisse <strong>choisir son prix d'abonnement de manière
     ({{ doc.date|date:"M Y" }}, {{ doc.service_set.count }} service{{ doc.service_set.count|pluralize }})
     ({{ doc.date|date:"M Y" }}, {{ doc.service_set.count }} service{{ doc.service_set.count|pluralize }})
     </li>
     </li>
     {% empty %}
     {% empty %}
-    <li>Pas de documents pour l'heure.</li>
+    <li>Pas de rapport pour l'heure.</li>
     {% endfor %}
     {% endfor %}
   </ul>
   </ul>
 
 

+ 1 - 1
costs/templates/costs/service_detail.html

@@ -11,7 +11,7 @@
 
 
     </div>
     </div>
     <br>
     <br>
-  {% if document.type == document.TYPE_PLAN %}
+  {% if document.type == document.TYPE_DRAFT %}
   <a class="ui label orange" title="Ce document se base sur des estimations">
   <a class="ui label orange" title="Ce document se base sur des estimations">
     {{ document.get_type_display }}
     {{ document.get_type_display }}
   </a>
   </a>

+ 6 - 6
costs/views.py

@@ -20,7 +20,7 @@ def format_to_content_type(_format):
 @login_required
 @login_required
 def list_documents(request):
 def list_documents(request):
     breadcrumbs = (
     breadcrumbs = (
-        ('Documents', reverse('list-documents')),
+        ('Rapports', reverse('list-documents')),
     )
     )
     docs = Document.objects.all()\
     docs = Document.objects.all()\
                            .prefetch_related('service_set')\
                            .prefetch_related('service_set')\
@@ -29,8 +29,8 @@ def list_documents(request):
     return render(
     return render(
         request, 'costs/documents_list.html', {
         request, 'costs/documents_list.html', {
             'documents': docs,
             'documents': docs,
-            'planning_documents': docs.filter(type=Document.TYPE_PLAN),
-            'factual_documents': docs.filter(type=Document.TYPE_FACT),
+            'planning_documents': docs.filter(type=Document.TYPE_DRAFT),
+            'factual_documents': docs.filter(type=Document.TYPE_PUBLIC),
             'breadcrumbs': breadcrumbs,
             'breadcrumbs': breadcrumbs,
         })
         })
 
 
@@ -40,7 +40,7 @@ def detail_document(request, pk):
     doc = get_object_or_404(Document, pk=pk)
     doc = get_object_or_404(Document, pk=pk)
 
 
     breadcrumbs = (
     breadcrumbs = (
-        ('Documents', reverse('list-documents')),
+        ('Rapports', reverse('list-documents')),
         (str(doc), doc.get_absolute_url())
         (str(doc), doc.get_absolute_url())
     )
     )
     return render(
     return render(
@@ -63,7 +63,7 @@ def compare_document(request, pk, other_pk):
     other_doc = Document.objects.get(pk=other_pk)
     other_doc = Document.objects.get(pk=other_pk)
 
 
     breadcrumbs = (
     breadcrumbs = (
-        ('Documents', reverse('list-documents')),
+        ('Rapports', reverse('list-documents')),
         (str(doc), doc.get_absolute_url()),
         (str(doc), doc.get_absolute_url()),
         ('Variations depuis {}'.format(other_doc), request.path),
         ('Variations depuis {}'.format(other_doc), request.path),
     )
     )
@@ -89,7 +89,7 @@ def detail_service(request, pk):
 
 
     doc = service.document
     doc = service.document
     breadcrumbs = (
     breadcrumbs = (
-        ('Documents', reverse('list-documents')),
+        ('Rapports', reverse('list-documents')),
         (str(doc), doc.get_absolute_url()),
         (str(doc), doc.get_absolute_url()),
         (service.name, service.get_absolute_url())
         (service.name, service.get_absolute_url())
     )
     )

+ 4 - 2
publicsite/templates/publicsite/public_document_detail.html

@@ -21,8 +21,10 @@
     {% endfor %}
     {% endfor %}
       </tbody>
       </tbody>
     </table>
     </table>
-    <a href="{% url "detail-document" pk=document.pk %}">Coûts détaillés</a>
-(adhérents seulement).
+    {% if document %}
+      <a href="{% url "detail-document" pk=document.pk %}">Coûts détaillés</a>
+      (adhérents seulement).
+    {% endif %}
   </section>
   </section>
 
 
   <section class="column">
   <section class="column">

+ 1 - 1
publicsite/views.py

@@ -4,7 +4,7 @@ from costs.models import Document
 
 
 def public_document_detail(request, pk=None):
 def public_document_detail(request, pk=None):
     docs = Document.objects\
     docs = Document.objects\
-                   .filter(type=Document.TYPE_FACT)\
+                   .filter(type=Document.TYPE_PUBLIC)\
                    .order_by('-date')
                    .order_by('-date')
 
 
     if pk is None:
     if pk is None: