Browse Source

Add command gencontributors and fix about page

pull/14/head
Yoann Piétri 5 years ago
parent
commit
d442545d17
  1. 1
      .gitignore
  2. 15
      coopeV3/management/commands/gencontributors.py
  3. 13
      coopeV3/views.py
  4. 6
      templates/about.html

1
.gitignore

@ -45,3 +45,4 @@ static/
Pipfile
mediafiles
Pipfile.lock
contributors.txt

15
coopeV3/management/commands/gencontributors.py

@ -0,0 +1,15 @@
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
import subprocess
class Command(BaseCommand):
help = 'Generate the git contributors file'
def handle(self, *args, **options):
try:
subprocess.call("rm " + settings.BASE_DIR + "/contributors.txt", shell=True)
except:
pass
subprocess.call("git -C " + settings.BASE_DIR + " shortlog -n $@ | grep \"):\" | sed 's|:||' >> " + settings.BASE_DIR + "/contributors.txt", shell=True)
subprocess.call("cat " + settings.BASE_DIR + "/contributors.txt", shell=True)

13
coopeV3/views.py

@ -44,14 +44,13 @@ def about(request):
"""
A page about the project
"""
os.system("git -C " + settings.BASE_DIR + " shortlog -n $@ | grep \"):\" | sed 's|:||' >> " + settings.BASE_DIR + "/contributors.txt")
contributors = []
with open(settings.BASE_DIR + "/contributors.txt", "r") as f:
for line in f:
print(line)
print(line.split(" ")[0])
contributors.append((line.split(" ")[0], int(line.split(" ")[1].replace("(", "").replace(")", "").replace("\n", ""))))
os.system("rm " + settings.BASE_DIR + "/contributors.txt")
try:
with open(settings.BASE_DIR + "/contributors.txt", "r") as f:
for line in f:
contributors.append((line[:line.find('(')], int(line[(line.find('(') + 1):line.find(')')])))
except:
pass
license = []
with open(settings.BASE_DIR + "/LICENSE", "r") as f:
for line in f:

6
templates/about.html

@ -28,8 +28,6 @@
{% endfor %}
(<a href="https://github.com/nanoy42/coope/blob/master/LICENSE" target="_blank">https://github.com/nanoy42/coope/blob/master/LICENSE</a>).
<br><br>
Version 3.6.2.
</section>
</section>
<section id="third" class="main">
@ -37,12 +35,16 @@
<h2>Contributeurs</h2>
</header>
<section>
{% if contributors %}
Les contributeurs, triés par ordre décroissant de nombre de commits, sont:
<ol>
{% for contributor in contributors %}
<li>{{contributor.0}} ({{contributor.1}} commits)</li>
{% endfor %}
</ol>
{% else %}
Impossible d'afficher la liste des contributeurs
{% endif %}
</section>
</section>
{% endblock %}

Loading…
Cancel
Save