3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-12-23 07:23:47 +00:00

Add command gencontributors and fix about page

This commit is contained in:
Yoann Pétri 2019-08-28 12:34:11 +02:00
parent b26b304672
commit d442545d17
4 changed files with 26 additions and 9 deletions

1
.gitignore vendored
View file

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

View file

@ -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)

View file

@ -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 = []
try:
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")
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:

View file

@ -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 %}