Parcourir la source

de-illysification of html templates, using available information from isp_database.ISPInfo

Conflicts:
	coin/templates/base.html
Jocelyn Delande il y a 10 ans
Parent
commit
2884ef98a3

+ 4 - 2
coin/billing/models.py

@@ -15,7 +15,7 @@ from coin.offers.models import OfferSubscription
 from coin.members.models import Member
 from coin.html2pdf import render_as_pdf
 from coin.utils import private_files_storage, start_of_month, end_of_month
-
+from coin.isp_database.context_processors import branding
 
 def next_invoice_number():
     """Détermine un numéro de facture aléatoire"""
@@ -103,7 +103,9 @@ class Invoice(models.Model):
         """
         Make and store a pdf file for the invoice
         """
-        pdf_file = render_as_pdf('billing/invoice_pdf.html', {"invoice": self})
+        context = {"invoice": self}
+        context.update(branding(None))
+        pdf_file = render_as_pdf('billing/invoice_pdf.html', context)
         self.pdf.save('%s.pdf' % self.number, pdf_file)
 
     def validate(self):

+ 13 - 11
coin/billing/templates/billing/invoice_pdf.html

@@ -21,7 +21,7 @@
 		    body {
 		    	font-size: 9pt;
 		    }
-		    #coordonnees_illyse {
+		    #coordonnees_isp {
 		    	font-size:9pt;
 		    }
 		    #coordonnees_client {
@@ -56,7 +56,7 @@
 	<div id="header_content">
 		<table widht="100%">
 			<tr>
-				<td><img id="logo" src="{% static "billing/invoice_logo.jpg" %}" height="70" /></td>
+				<td><img id="logo" src="{{ branding.logoURL }}" height="70" /></td>
 				<td><h1>Facture N°{{ invoice.number }}</h1>
 					Le {{ invoice.date }}</td>
 			</tr>
@@ -66,8 +66,8 @@
 		<hr />
 		<table widht="100%">
 			<tr>
-				<td width="50"><img id="logo" src="{% static "billing/invoice_logo.jpg" %}" height="20" /></td>
-				<td>ILLYSE, association loi de 1901 à but non lucratif - SIRET : 539 453 191 00014</td>
+				<td width="50"><img id="logo" src="{{ branding.logoURL }}" height="20" /></td>
+				<td>{{ branding.shortName|upper }}, association loi de 1901 à but non lucratif - SIRET : 539 453 191 00014</td>
 				<td width="20"><pdf:pagenumber>
 					/<pdf:pagecount>
 				</td>
@@ -76,14 +76,16 @@
 	</div>
 	<table>
 		<tr>
-			<td id="coordonnees_illyse">
+			<td id="coordonnees_isp">
+            {% with address=branding.registeredoffice %}
 				<p>
-				Association ILLYSE<br />
-				c/o Jean-François MOURGUES<br />
-				225 route de Genas<br />
-				69100 Villeurbanne</p>
-				<p>conctact@illyse.org<br/>
-				<a href="http://www.illyse.net">http://www.illyse.net</a></p>
+				Association {{ branding.short_name|upper }}<br />
+				{{ address.extended_address }}<br />
+				{{ address.street_address }}<br />
+				{{ address.postal_code }}</p>
+				<p>{{ branding.email }}<br/>
+				<a href="{{ branding.website }}">{{ branding.website }}</a></p>
+            {% endwith %}
 			</td>
 			<td id="coordonnees_client">
 				<strong>Facturé à :</strong><br/>

+ 4 - 2
coin/billing/templates/billing/payment_howto.html

@@ -2,11 +2,13 @@
 
 <p>
 <strong>Virement</strong><br />
-Titulaire du compte : ILLYSE<br/>
+Titulaire du compte : {{ branding.short_name|upper }}<br/>
 RIB : 42559 00012 41020023285 19<br/>
 IBAN : FR76 4255 9000 1241 0200 2328 519<br />
 Merci de faire figurer le code suivant sur votre virement : <strong>#{{ invoice.member.id }}</strong>
 <br /><br />
 <strong>Chèque</strong><br />
-Paiement par chèque à l'ordre de "Association ILLYSE" envoyé à l'adresse : Association ILLYSE, c/o Jean-François MOURGUES, 225 route de Genas, 69100 Villeurbanne
+{% with address=branding.registeredoffice %}
+Paiement par chèque à l'ordre de "Association {{ branding.short_name|upper }}" envoyé à l'adresse : Association {{ branding.short_name|upper }}, {{ address.extended_address }}, {{ address.street_address }}, {{ address.postal_code }} {{ address.locality }}
+{% endwith %}
 </p>

+ 2 - 0
coin/html2pdf.py

@@ -27,6 +27,8 @@ def link_callback(uri, rel):
         path = os.path.join(mRoot, uri.replace(mUrl, ""))
     elif uri.startswith(sUrl):
         path = os.path.join(sRoot, uri.replace(sUrl, ""))
+    else:
+        return uri # handle the absolute URIs
 
     # If file doesn't exist try to find it in app static folder
     # This case occur in developpement env

+ 9 - 0
coin/isp_database/context_processors.py

@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from coin.isp_database.models import ISPInfo
+
+def branding(request):
+    """ Just a shortcut to get the ISP object in templates
+    """
+    return {'branding': ISPInfo.objects.first()}

+ 10 - 0
coin/isp_database/models.py

@@ -7,6 +7,7 @@ from django.core.exceptions import ValidationError
 
 from coin.members.models import count_active_members
 from coin.offers.models import count_active_subscriptions
+from coin import utils
 
 # API version, see http://db.ffdn.org/format
 API_VERSION = 0.1
@@ -86,6 +87,15 @@ class ISPInfo(SingleInstanceMixin, models.Model):
         """Version of the API"""
         return API_VERSION
 
+    @property
+    def lists_url(self):
+        return self.otherwebsite_set.filter(name__iexact='listes.url')
+
+    @property
+    def main_chat_verbose(self):
+        m = utils.re_chat_url.match(self.chatroom_set.first().url)
+        return '{channel} sur {server}'.format(**(m.groupdict()))
+
     def get_absolute_url(self):
         return '/isp.json'
 

+ 2 - 2
coin/members/templates/members/contact.html

@@ -6,9 +6,9 @@
         <h2>Contact / Support</h2>
         <div class="panel">
             <h3>Courriel</h3>
-            <p><a href="mailto:contact@illyse.org">contact@illyse.org</a></p>
+            <p><a href="mailto:{{ branding.email }}">{{ branding.email }}</a></p>
             <h3>IRC</h3>
-            <p><a href="irc://irc.geeknode.net/illyse">#illyse sur irc.geeknode.net</a></p>
+            <p><a href="{{ branding.chatroom_set.first.url }}">{{ branding.main_chat_verbose }}</a></p>
         </div>
     </div>
 </div>

+ 1 - 1
coin/members/templates/members/detail.html

@@ -46,7 +46,7 @@
 
     <div class="large-6 columns">
         <div class="panel">
-            <h3>Je suis membre d'Illyse</h3>
+            <h3>Je suis membre d'{{ branding.shortname|capfirst }}</h3>
             <p>et ma cotisation est :
                 {% if user.is_paid_up %}
                     <span class="label success">à jour !</span>

+ 4 - 4
coin/members/templates/members/emails/welcome_email.html

@@ -1,6 +1,6 @@
 <p>Bonjour {{ member.first_name }},</p>
 
-<p>Ce courriel confirme que ton adhésion à l'association Illyse a bien été
+<p>Ce courriel confirme que ton adhésion à l'association {{ branding.shortname|capfirst }} a bien été
 prise en compte.  Bienvenue à toi !</p>
 
 <p>Avant toute chose, il faut initialiser ton mot de passe d'accès à
@@ -17,9 +17,9 @@ https://{{ domain }}{% url 'home' %}</p>
 étant entièrement développé par nos soins.  Tu peux le faire par exemple
 en répondant à ce courriel.</p>
 
-<p>Par ailleurs, Illyse dispose de plusieurs listes de discussions dont tu
+<p>Par ailleurs, {{ branding.shortname|capfirst }} dispose de plusieurs listes de discussions dont tu
 peux gérer tes abonnements depuis cette interface :<br />
-https://listes.illyse.org/wws/</p>
+{{ branding.lists_url }}</p>
 
 
-<p>L'équipe d'Illyse</p>
+<p>L'équipe d'{{ branding.shortname|capfirst }}</p>

+ 1 - 1
coin/members/templates/members/registration/password_reset_email.html

@@ -10,6 +10,6 @@ Pour rappel, voici votre nom d'utilisateur : {{ user.get_username }}
 
 Si vous n'êtes pas à l'initiative de cette demande, merci d'ignorer ce message.
 
-L'équipe d'ILLYSE
+L'équipe d'{{ branding.shortname }}
 
 {% endautoescape %}

+ 1 - 0
coin/settings.py

@@ -218,6 +218,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
     "django.core.context_processors.static",
     "django.core.context_processors.tz",
     "django.core.context_processors.request",
+    "coin.isp_database.context_processors.branding",
     "django.contrib.messages.context_processors.messages")
 
 AUTH_USER_MODEL = 'members.Member'

+ 1 - 1
coin/templates/base.html

@@ -4,7 +4,7 @@
 <head>
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>{% block title %}COIN - Illyse SI{% endblock %}</title>
+    <title>{% block title %}COIN - {{ branding.shortname|capfirst }} SI{% endblock %}</title>
     <link rel="stylesheet" href="{% static "css/foundation.css"%}" />
     <link rel="stylesheet" href="{% static "css/font-awesome.min.css"%}" />
     <link rel="stylesheet" href="{% static "css/illyse.css" %}" />

+ 4 - 1
coin/utils.py

@@ -6,6 +6,7 @@ import hashlib
 import binascii
 import base64
 import html2text
+import re
 from datetime import date, timedelta
 
 from django.core.mail import EmailMultiAlternatives
@@ -19,6 +20,8 @@ from django.contrib.sites.models import Site
 # Stockage des fichiers privés (comme les factures par exemple)
 private_files_storage = FileSystemStorage(location=settings.PRIVATE_FILES_ROOT)
 
+# regexp which matches for ex irc://irc.example.tld/#channel
+re_chat_url = re.compile(r'(?P<protocol>\w+://)(?P<server>[\w\.]+)/(?P<channel>.*)')
 
 def str_or_none(obj):
     return str(obj) if obj else None
@@ -84,7 +87,7 @@ def send_templated_email(to, subject_template, body_template, context={}, attach
 
 
 def delete_selected(modeladmin, request, queryset):
-    """Overrides QuerySet's delete() function to remove objects one by one 
+    """Overrides QuerySet's delete() function to remove objects one by one
     so, that they are deleted in the LDAP (Redmine issue #195)."""
     for obj in queryset:
         obj.delete()