export ticket list (#77825)
This commit is contained in:
parent
e7ba87844c
commit
4f12a61dd5
|
@ -0,0 +1,39 @@
|
|||
<html>
|
||||
<body>
|
||||
<h4>Nouveautés</h4>
|
||||
|
||||
<ul>
|
||||
{% spaceless %}
|
||||
{% for issue in issues %}
|
||||
{% if issue.info.issue_type == 'NEW' %}
|
||||
<li>{{ issue.subject }} (<a href="{{ issue.url }}">#{{ issue.id }}</a>)</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endspaceless %}
|
||||
</ul>
|
||||
|
||||
<h4>Corrections</h4>
|
||||
|
||||
<ul>
|
||||
{% spaceless %}
|
||||
{% for issue in issues %}
|
||||
{% if issue.info.issue_type == 'BUGFIX' %}
|
||||
<li>{{ issue.subject }} (<a href="{{ issue.url }}">#{{ issue.id }}</a>)</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endspaceless %}
|
||||
</ul>
|
||||
|
||||
<h4>Développement</h4>
|
||||
|
||||
<ul>
|
||||
{% spaceless %}
|
||||
{% for issue in issues %}
|
||||
{% if issue.info.issue_type == 'DEV' %}
|
||||
<li>{{ issue.subject }} (<a href="{{ issue.url }}">#{{ issue.id }}</a>)</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endspaceless %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -11,7 +11,13 @@
|
|||
{% for day in history %}
|
||||
<div data-issues-url-content="{% url 'issues-snippet' %}">
|
||||
{% if day.modules %}
|
||||
<h3>{{ day.day|date:"d/m/Y" }}{% if day.day == 'future' %}À venir{% endif %}</h3>
|
||||
{% if day.day == 'future' %}
|
||||
<h3>À venir</h3>
|
||||
<a href="{% url 'project-summary-history-future' slug=object.slug %}">Exporter</a>
|
||||
{% else %}
|
||||
<h3>{{ day.day|date:"d/m/Y" }}</h3>
|
||||
<a href="{% url 'project-summary-history-day' slug=object.slug year=day.day.year month=day.day.month day=day.day.day %}">Exporter</a>
|
||||
{% endif %}
|
||||
<p>
|
||||
{% for module in day.modules.values %}
|
||||
<span data-module-name="{{ module.name }}"
|
||||
|
|
|
@ -9,6 +9,7 @@ from .views import (
|
|||
ModulesView,
|
||||
ProjectDetailView,
|
||||
ProjectHistoryView,
|
||||
ProjectSummaryHistoryDayView,
|
||||
ProjectSummaryHistoryView,
|
||||
api_issues_json,
|
||||
module_deployments_json,
|
||||
|
@ -20,6 +21,16 @@ urlpatterns = [
|
|||
re_path(
|
||||
r'^(?P<slug>[\w,-]+)/history$', ProjectSummaryHistoryView.as_view(), name='project-summary-history'
|
||||
),
|
||||
re_path(
|
||||
r'^(?P<slug>[\w,-]+)/history/(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)$',
|
||||
ProjectSummaryHistoryDayView.as_view(),
|
||||
name='project-summary-history-day',
|
||||
),
|
||||
re_path(
|
||||
r'^(?P<slug>[\w,-]+)/history/future$',
|
||||
ProjectSummaryHistoryDayView.as_view(),
|
||||
name='project-summary-history-future',
|
||||
),
|
||||
re_path(r'^(?P<slug>[\w,-]+)/detailed-history$', ProjectHistoryView.as_view(), name='project-history'),
|
||||
re_path(
|
||||
r'^modules/(?P<name>[\w,-]+)/diff/(?P<commit1>[\w,\.-]+)/(?P<commit2>[\w,\.-]+)$',
|
||||
|
|
|
@ -3,7 +3,8 @@ import json
|
|||
import re
|
||||
|
||||
from django import template
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.http import Http404, HttpResponse, JsonResponse
|
||||
from django.shortcuts import render
|
||||
from django.utils import timezone
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.generic import FormView
|
||||
|
@ -94,10 +95,7 @@ class ProjectHistoryView(DetailView):
|
|||
return context
|
||||
|
||||
|
||||
class ProjectSummaryHistoryView(DetailView):
|
||||
model = Project
|
||||
template_name_suffix = '_summary_history'
|
||||
|
||||
class ProjectSummaryHistoryMixin:
|
||||
# XXX: add an 'interesting' attribute to module model?
|
||||
interesting_modules = [
|
||||
'publik-base-theme',
|
||||
|
@ -119,9 +117,7 @@ class ProjectSummaryHistoryView(DetailView):
|
|||
'godo.js',
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
def get_history(self):
|
||||
platforms = list(self.object.platform_set.all())
|
||||
platform = platforms[-1]
|
||||
installed_versions = list(
|
||||
|
@ -193,12 +189,84 @@ class ProjectSummaryHistoryView(DetailView):
|
|||
if future_versions['modules']:
|
||||
versions_sorted_by_day.append(future_versions)
|
||||
|
||||
return versions_sorted_by_day, platform
|
||||
|
||||
|
||||
class IssuesMixin:
|
||||
def get_issues(self, modules):
|
||||
modules_by_name = {m.name: m for m in Module.objects.all()}
|
||||
|
||||
issues = {}
|
||||
for module_info in modules.values():
|
||||
module = modules_by_name[module_info['name']]
|
||||
if not module.repository_url:
|
||||
continue
|
||||
commits = CommitAndIssues.get_for_commits(
|
||||
module, str(module_info.get('previous_version')), str(module_info.get('current_version'))
|
||||
)
|
||||
for commit in commits:
|
||||
for issue in commit.issues:
|
||||
if issue.subject == '---': # private issue
|
||||
continue
|
||||
if not int(issue.id) in issues:
|
||||
issues[int(issue.id)] = issue
|
||||
else:
|
||||
issue = issues[int(issue.id)]
|
||||
if not hasattr(issues[int(issue.id)], 'modules'):
|
||||
issues[int(issue.id)].modules = {}
|
||||
issues[int(issue.id)].modules[module_info['name']] = True
|
||||
|
||||
issues_info = IssueInfo.objects.filter(issue_id__in=issues.keys())
|
||||
for info in issues_info:
|
||||
issues[int(info.issue_id)].info = info
|
||||
|
||||
issues = list(issues.values())
|
||||
issues.sort(key=lambda x: int(x.id))
|
||||
issues.sort(key=lambda x: sorted(x.modules.keys()))
|
||||
return issues
|
||||
|
||||
|
||||
class ProjectSummaryHistoryView(ProjectSummaryHistoryMixin, DetailView):
|
||||
model = Project
|
||||
template_name_suffix = '_summary_history'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
versions_sorted_by_day, platform = self.get_history()
|
||||
|
||||
context['platform'] = platform
|
||||
context['history'] = reversed(versions_sorted_by_day)
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class ProjectSummaryHistoryDayView(ProjectSummaryHistoryMixin, IssuesMixin, DetailView):
|
||||
model = Project
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
day = 'future'
|
||||
if 'year' in kwargs:
|
||||
day = datetime.date(int(kwargs['year']), int(kwargs['month']), int(kwargs['day']))
|
||||
|
||||
versions_sorted_by_day, platform = self.get_history()
|
||||
version = None
|
||||
for _version in versions_sorted_by_day:
|
||||
if _version['day'] == day:
|
||||
version = _version
|
||||
break
|
||||
if not version:
|
||||
raise Http404
|
||||
|
||||
issues = self.get_issues(version['modules'])
|
||||
return render(
|
||||
request,
|
||||
'projects/date_export.html',
|
||||
{'issues': issues},
|
||||
)
|
||||
|
||||
|
||||
class ModulesView(TemplateView):
|
||||
template_name = 'projects/modules.html'
|
||||
|
||||
|
@ -264,7 +332,7 @@ def module_deployments_json(request, name, **kwargs):
|
|||
return response
|
||||
|
||||
|
||||
class IssuesSnippet(TemplateView):
|
||||
class IssuesSnippet(IssuesMixin, TemplateView):
|
||||
template_name = 'projects/issues_snippet.html'
|
||||
|
||||
@csrf_exempt
|
||||
|
@ -278,35 +346,8 @@ class IssuesSnippet(TemplateView):
|
|||
context = super().get_context_data(**kwargs)
|
||||
|
||||
modules = json.loads(self.request.read().decode('utf-8'))
|
||||
modules_by_name = {m.name: m for m in Module.objects.all()}
|
||||
|
||||
issues = {}
|
||||
for module_info in modules.values():
|
||||
module = modules_by_name[module_info['name']]
|
||||
if not module.repository_url:
|
||||
continue
|
||||
commits = CommitAndIssues.get_for_commits(
|
||||
module, str(module_info.get('previous_version')), str(module_info.get('current_version'))
|
||||
)
|
||||
for commit in commits:
|
||||
for issue in commit.issues:
|
||||
if issue.subject == '---': # private issue
|
||||
continue
|
||||
if not int(issue.id) in issues:
|
||||
issues[int(issue.id)] = issue
|
||||
else:
|
||||
issue = issues[int(issue.id)]
|
||||
if not hasattr(issues[int(issue.id)], 'modules'):
|
||||
issues[int(issue.id)].modules = {}
|
||||
issues[int(issue.id)].modules[module_info['name']] = True
|
||||
|
||||
issues_info = IssueInfo.objects.filter(issue_id__in=issues.keys())
|
||||
for info in issues_info:
|
||||
issues[int(info.issue_id)].info = info
|
||||
|
||||
context['issues'] = list(issues.values())
|
||||
context['issues'].sort(key=lambda x: int(x.id))
|
||||
context['issues'].sort(key=lambda x: sorted(x.modules.keys()))
|
||||
issues = self.get_issues(modules)
|
||||
context['issues'] = issues
|
||||
return context
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue