3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-12-23 15:33:45 +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 Pipfile
mediafiles mediafiles
Pipfile.lock 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 A page about the project
""" """
os.system("git -C " + settings.BASE_DIR + " shortlog -n $@ | grep \"):\" | sed 's|:||' >> " + settings.BASE_DIR + "/contributors.txt")
contributors = [] contributors = []
with open(settings.BASE_DIR + "/contributors.txt", "r") as f: try:
for line in f: with open(settings.BASE_DIR + "/contributors.txt", "r") as f:
print(line) for line in f:
print(line.split(" ")[0]) contributors.append((line[:line.find('(')], int(line[(line.find('(') + 1):line.find(')')])))
contributors.append((line.split(" ")[0], int(line.split(" ")[1].replace("(", "").replace(")", "").replace("\n", "")))) except:
os.system("rm " + settings.BASE_DIR + "/contributors.txt") pass
license = [] license = []
with open(settings.BASE_DIR + "/LICENSE", "r") as f: with open(settings.BASE_DIR + "/LICENSE", "r") as f:
for line in f: for line in f:

View file

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