Commit b5342122 authored by MariaV's avatar MariaV
Browse files

Merge branch 'git_fail_gracefully' into 'master'

Git Fail Gracefully + gl_bot (major change)

See merge request !86
parents 382bfee4 e64b703e
......@@ -15,17 +15,23 @@
</h3>
<div class="row justify-content-between">
<p class="col-auto mb-0 small pb-0 pt-0">
{% if results.issue.created_at %}
<a href="{{results.go_back_url}}">
{{results.project.name_with_namespace}}
</a>
({{results.project.id}}) / issues / #{{results.issue.iid}}
{% endif %}
</p>
<p class="col-auto text-muted small mb-0 pb-0 pt-0 text-right">
{% if results.issue.created_at %}
Created {{results.issue.created_at|pretty_datetime}} by @{{results.issue.author.username}}
{% else %}
{% endif %}
</p>
</div>
<hr class="mb-0 mt-0">
<div class="row justify-content-between">
{% if results.issue.created_at %}
<div class="col-auto">
<p class="mb-0 small pb-0 pt-0">
{% if results.issue.milestone.title %}
......@@ -49,6 +55,7 @@
<a class="btn btn-sm btn-primary bg success ml-2 px-1 py-0" href="{{results.new_note_link}}">New Note</a>
</p>
</div>
{% endif %}
</div>
<div class="row mt-5">
<div class="col-12">
......@@ -75,7 +82,7 @@
{% block content %}
<!-- Issue Summary Block -->
{% if results.issue %}
{% if results.issue.updated_at %}
<div class="row mt-3">
<div class="col-12">
<h4 class="card-title">Issue Summary</h4>
......@@ -86,14 +93,18 @@
</ul>
</div>
</div>
{% else %}
{% endif %}
<!-- Generate a Back to Landing URL Link -->
{% url 'user-landing' results.user_identifier as go_back_url %}
<div>
<p>
You can <a href="{{go_back_url}}">go back to your landing page</a> or
You can <a href="{{go_back_url}}">go back to your landing page</a>
{% if results.issue.updated_at%}
or
<!-- New_note_link is generated in views.py. -->
<a href="{{results.new_note_link}}">create a new note</a> for this issue.
{% else %}.{% endif %}
</p>
</div>
......@@ -101,7 +112,7 @@
<!-- Note Header Block -->
<div class="row mt-5">
<div class="col-12 p-2">
<h4 class="card-title">Project Notes</h4>
<h4 class="card-title">Issue Notes</h4>
</div>
</div>
......@@ -113,10 +124,14 @@
<div class="col-12 p-2">
<div class="card mb-2">
<div class="card-body">
<p class="card-text text-muted">{{note.noteable_type|title}}
{% if note.author %}
<p class="card-text text-muted">
{{note.noteable_type|title}}
note by @{{note.author.username}},
Created: {{note.created_at|pretty_datetime}},
Last Updated: {{note.updated_at|pretty_datetime}}</p>
Last Updated: {{note.updated_at|pretty_datetime}}
</p>
{% else %}{% endif %}
<p class="card-text">{{note.body|markdownify}}</p>
</div>
</div>
......
......@@ -12,23 +12,23 @@
{% block h3 %}
{% if object %}
<!-- Close out the h3 block from extended template to make smaller text on top first. -->
</h3>
<div class="row justify-content-between">
<p class="col-auto mb-0 small pb-0 pt-0">{{object.name_with_namespace}} (Project # {{object.gitlab_id}})</p>
<p class="col-auto text-muted small mb-0 pb-0 pt-0 text-right">
<a href="{{object.url}}" class="btn btn-sm btn-outline-primary mb-1 ml-4 px-1 py-0" target="__blank">
View this project on Gitlab
</a>
{% if gitlab_project.id != 'NA' %}
<div class="row justify-content-between">
<p class="col-auto mb-0 small pb-0 pt-0">{{object.name_with_namespace}} (Project # {{object.gitlab_id}})</p>
<p class="col-auto text-muted small mb-0 pb-0 pt-0 text-right">
<a href="{{object.url}}" class="btn btn-sm btn-outline-primary mb-1 ml-4 px-1 py-0" target="__blank">
View this project on Gitlab
</a>
</p>
</div>
<hr class="mt-0">
<!-- Make a true header -->
<h4>{{object.name}}</h4>
<!--Mimic commit/branch/tags/files/storage data.-->
<p class="small">
{{object.description}}
</p>
</div>
<hr class="mt-0">
<!-- Make a true header -->
<h4>{{object.name}}</h4>
<!--Mimic commit/branch/tags/files/storage data.-->
<p class="small">
{{object.description}}
</p>
{% endif %}
{% else %}
Project Not Found
{% endif %}
......@@ -39,36 +39,41 @@
{% block content %}
<!-- Create the user-actions block -->
<div class="row">
<div class="col-12">
<p>
You can either
{% url 'create-issue' results.user_identifier as create_url %}
<a href="{{create_url}}">create a new issue</a>
or
{% url 'user-landing' results.user_identifier as go_back_url %}
<a href="{{go_back_url}}">go back to your landing page.</a>
</p>
{% if gitlab_project.id != 'NA' %}
<div class="row">
<div class="col-12">
<p>
You can either
{% url 'create-issue' results.user_identifier as create_url %}
<a href="{{create_url}}">create a new issue</a>
or
{% url 'user-landing' results.user_identifier as go_back_url %}
<a href="{{go_back_url}}">go back to your landing page.</a>
</p>
</div>
</div>
</div>
{% endif %}
<!-- Create the Issues List Block For Open Issues-->
<div class="row">
<div class="col-12 mt-5">
<h4 class="text-primary"> Open Issues
{% if open_issues.total_issues %}
<span class="badge badge-primary">{{open_issues.total_issues}} Total</span>
{% endif %}
<!-- Create New Issue badge link -->
<a href="{{create_url}}" class="badge btn btn-outline-primary ml-2">
Create New
</a>
</h4>
<!-- Add a gitlab_project.id != NA call in case gitlab down -->
{% if gitlab_project.id != 'NA' %}
<h4 class="text-primary"> Open Issues
{% if open_issues.total_issues %}
<span class="badge badge-primary">{{open_issues.total_issues}} Total</span>
{% endif %}
<!-- Create New Issue badge link -->
<a href="{{create_url}}" class="badge btn btn-outline-primary ml-2">
Create New
</a>
</h4>
{% endif %}
{% if open_issues.issues %}
<table class="table table-sm mt-3">
{% for issue, detail_url in open_issues.issues.items %}
<tr>
<td>
{% if issue.created_at %}
<a href="{{detail_url}}"><strong>{{issue.title}}</strong></a><br>
# {{issue.iid}} | Opened {{issue.created_at|pretty_datetime}} by {{issue.author.username}}.
{% if issue.milestone.title %}
......@@ -79,7 +84,12 @@
<span class="badge-pill badge-primary ml-1 small">{{label}}</span>
{% endfor %}
{% endif %}
{% else %}
<p class="p-3"><strong>{{issue.title}}</strong><p>
<p class="p-3"><em>{{issue.attributes.description}}</em></p>
{% endif %}
</td>
{% if issue.created_at %}
<td class="text-right small" style="width:25%">
{% if issue.assignee.name %}
Assigned to {{issue.assignee.name}}.
......@@ -91,6 +101,7 @@
</span><br>
Updated {{issue.updated_at|pretty_datetime}}
</td>
{% endif %}
</tr>
{% endfor %}
</table>
......@@ -99,193 +110,208 @@
{% endif %}
</div>
</div>
<!-- Render the Pagination Block -->
<div class="row px-3">
<div class="col-12 bg-light p-2">
<nav aria-label="...">
<ul class="pagination m-0 p-0 justify-content-center">
<!-- Make the previous button -->
{% if open_issues.prev_url %}
<li class="page-item">
<a href="{{open_issues.prev_url}}" class="page-link">Previous</a>
</li>
{% else %}
<li class="page-item-disabled">
<span class="page-link">Previous</span>
</li>
{% endif %}
<!-- Make first link if called for -->
{% if open_issues.first_url %}
<li class="page-item">
<a href="{{open_issues.first_url}}" class="page-link">1</a>
</li>
<li class="page-item-disabled">
<span class="page-link text-muted">...</span></a>
{% if gitlab_project.id != 'NA' %}
<!-- Render the Pagination Block -->
<div class="row px-3">
<div class="col-12 bg-light p-2">
<nav aria-label="...">
<ul class="pagination m-0 p-0 justify-content-center">
<!-- Make the previous button -->
{% if open_issues.prev_url %}
<li class="page-item">
<a href="{{open_issues.prev_url}}" class="page-link">Previous</a>
</li>
{% else %}
<li class="page-item-disabled">
<span class="page-link">Previous</span>
</li>
{% endif %}
<!-- Make first link if called for -->
{% if open_issues.first_url %}
<li class="page-item">
<a href="{{open_issues.first_url}}" class="page-link">1</a>
</li>
<li class="page-item-disabled">
<span class="page-link text-muted">...</span></a>
</li>
{% endif %}
<!-- Make the previous links -->
{% if open_issues.prev_pages %}
{% for page_number, url in open_issues.prev_pages.items %}
<li class="page-item">
<a href="{{url}}" class="page-link">{{page_number}}</a>
</li>
{% endfor %}
{% endif %}
<!-- Make the current page indicator -->
<li class="page-item active">
<span class="page-link">
{{page_number}}
</span>
</li>
{% endif %}
<!-- Make the previous links -->
{% if open_issues.prev_pages %}
{% for page_number, url in open_issues.prev_pages.items %}
<!-- Make the next links -->
{% if open_issues.post_pages %}
{% for page_number, url in open_issues.post_pages.items %}
<li class="page-item">
<a href="{{url}}" class="page-link">{{page_number}}</a>
</li>
{% endfor %}
{% endif %}
<!-- Make last link if called for -->
{% if open_issues.last_page %}
<li class="page-item-disabled">
<span class="page-link text-muted">...</span>
</li>
<li class="page-item">
<a href="{{url}}" class="page-link">{{page_number}}</a>
<a href="{{open_issues.last_page.url}}" class="page-link">
{{open_issues.last_page.page_number}}
</a>
</li>
{% endfor %}
{% endif %}
<!-- Make the current page indicator -->
<li class="page-item active">
<span class="page-link">
{{page_number}}
</span>
</li>
<!-- Make the next links -->
{% if open_issues.post_pages %}
{% for page_number, url in open_issues.post_pages.items %}
{% endif %}
<!-- Make the next button -->
{% if open_issues.next_url %}
<li class="page-item">
<a href="{{url}}" class="page-link">{{page_number}}</a>
<a href="{{open_issues.next_url}}" class="page-link">
Next
</a>
</li>
{% endfor %}
{% endif %}
<!-- Make last link if called for -->
{% if open_issues.last_page %}
{% else %}
<li class="page-item-disabled">
<span class="page-link text-muted">...</span>
</li>
<li class="page-item">
<a href="{{open_issues.last_page.url}}" class="page-link">
{{open_issues.last_page.page_number}}
</a>
</li>
{% endif %}
<!-- Make the next button -->
{% if open_issues.next_url %}
<li class="page-item">
<a href="{{open_issues.next_url}}" class="page-link">
Next
</a>
<span class="page-link">Next</span>
</li>
{% else %}
<li class="page-item-disabled">
<span class="page-link">Next</span>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
</ul>
</nav>
</div>
</div>
</div>
<!-- Create the Issues List Block for closed issues-->
<div class="row mt-5">
<div class="col-12">
<h4 class="text-primary">Closed Issues:
{% if closed_issues.total_issues %}
<span class="badge badge-primary">{{closed_issues.total_issues}} Total</span>
{% endif %}
</h4>
{% if closed_issues.issues %}
<table class="table table-sm mt-3">
{% for issue, detail_url in closed_issues.issues.items %}
<tr>
<td>
<a href="{{detail_url}}"><strong>{{issue.title}}</strong></a><br>
# {{issue.iid}} | Opened {{issue.created_at|pretty_datetime}} by {{issue.author.username}}.
{% if issue.milestone.title %}
<span class="badge">Milestone: {{issue.milestone.title}}</span>
{% endif %}
{% if issue.labels %}
{% for label in issue.labels %}
<span class="badge-pill badge-primary ml-1 small">{{label}}</span>
{% endfor %}
{% endif %}
</td>
<td class="text-right small" style="width:25%">
CLOSED
<span class="ml-2">
(<a href="{{detail_url}}">{{issue.user_notes_count}} Notes</a>)
</span><br>
Updated {{issue.updated_at|pretty_datetime}}
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p class="ml-3 text-muted"> No closed issues at this time. </p>
{% endif %}
{% endif %}
<!-- Create the Issues List Block for closed issues-->
{% if gitlab_project.id != 'NA' %}
<div class="row mt-5">
<div class="col-12">
<h4 class="text-primary">Closed Issues:
{% if closed_issues.total_issues %}
<span class="badge badge-primary">{{closed_issues.total_issues}} Total</span>
{% endif %}
</h4>
{% if closed_issues.issues %}
<table class="table table-sm mt-3">
{% for issue, detail_url in closed_issues.issues.items %}
<tr>
<td>
<a href="{{detail_url}}"><strong>{{issue.title}}</strong></a><br>
# {{issue.iid}} | Opened {{issue.created_at|pretty_datetime}} by {{issue.author.username}}.
{% if issue.milestone.title %}
<span class="badge">Milestone: {{issue.milestone.title}}</span>
{% endif %}
{% if issue.labels %}
{% for label in issue.labels %}
<span class="badge-pill badge-primary ml-1 small">{{label}}</span>
{% endfor %}
{% endif %}
</td>
<td class="text-right small" style="width:25%">
CLOSED
<span class="ml-2">
(<a href="{{detail_url}}">{{issue.user_notes_count}} Notes</a>)
</span><br>
Updated {{issue.updated_at|pretty_datetime}}
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p class="ml-3 text-muted"> No closed issues at this time. </p>
{% endif %}
</div>
</div>
</div>
<!-- Render the Pagination Block -->
<div class="row px-3">
<div class="col-12 bg-light p-2">
<nav aria-label="...">
<ul class="pagination m-0 p-0 justify-content-center">
<!-- Make the previous button -->
{% if closed_issues.prev_url %}
<li class="page-item">
<a href="{{closed_issues.prev_url}}" class="page-link">Previous</a>
</li>
{% else %}
<li class="page-item-disabled">
<span class="page-link">Previous</span>
</li>
{% endif %}
<!-- Make first link if called for -->
{% if closed_issues.first_url %}
<li class="page-item">
<a href="{{closed_issues.first_url}}" class="page-link">1</a>
</li>
<li class="page-item-disabled">
<span class="page-link text-muted">...</span></a>
{% endif %}
<!-- Render the Pagination Block -->
{% if gitlab_project.id != 'NA' %}
<div class="row px-3">
<div class="col-12 bg-light p-2">
<nav aria-label="...">
<ul class="pagination m-0 p-0 justify-content-center">
<!-- Make the previous button -->
{% if closed_issues.prev_url %}
<li class="page-item">
<a href="{{closed_issues.prev_url}}" class="page-link">Previous</a>
</li>
{% else %}
<li class="page-item-disabled">
<span class="page-link">Previous</span>
</li>
{% endif %}
<!-- Make first link if called for -->
{% if closed_issues.first_url %}
<li class="page-item">
<a href="{{closed_issues.first_url}}" class="page-link">1</a>
</li>
<li class="page-item-disabled">
<span class="page-link text-muted">...</span></a>
</li>
{% endif %}
<!-- Make the previous links -->
{% if closed_issues.prev_pages %}
{% for page_number, url in closed_issues.prev_pages.items %}
<li class="page-item">
<a href="{{url}}" class="page-link">{{page_number}}</a>
</li>
{% endfor %}
{% endif %}
<!-- Make the current page indicator -->
<li class="page-item active">
<span class="page-link">
{{page_number}}
</span>
</li>
{% endif %}
<!-- Make the previous links -->
{% if closed_issues.prev_pages %}
{% for page_number, url in closed_issues.prev_pages.items %}
<!-- Make the next links -->
{% if closed_issues.post_pages %}
{% for page_number, url in closed_issues.post_pages.items %}
<li class="page-item">
<a href="{{url}}" class="page-link">{{page_number}}</a>
</li>
{% endfor %}
{% endif %}
<!-- Make last link if called for -->
{% if closed_issues.last_page %}
<li class="page-item-disabled">
<span class="page-link text-muted">...</span>
</li>
<li class="page-item">
<a href="{{url}}" class="page-link">{{page_number}}</a>
<a href="{{closed_issues.last_page.url}}" class="page-link">
{{closed_issues.last_page.page_number}}
</a>
</li>
{% endfor %}
{% endif %}
<!-- Make the current page indicator -->
<li class="page-item active">
<span class="page-link">
{{page_number}}
</span>
</li>
<!-- Make the next links -->
{% if closed_issues.post_pages %}
{% for page_number, url in closed_issues.post_pages.items %}
{% endif %}
<!-- Make the next button -->
{% if closed_issues.next_url %}
<li class="page-item">
<a href="{{url}}" class="page-link">{{page_number}}</a>
<a href="{{closed_issues.next_url}}" class="page-link">
Next
</a>
</li>
{% endfor %}
{% endif %}
<!-- Make last link if called for -->
{% if closed_issues.last_page %}
{% else %}
<li class="page-item-disabled">
<span class="page-link text-muted">...</span>
</li>
<li class="page-item">
<a href="{{closed_issues.last_page.url}}" class="page-link">
{{closed_issues.last_page.page_number}}
</a>
<span class="page-link">Next</span>
</li>
{% endif %}
<!-- Make the next button -->
{% if closed_issues.next_url %}
<li class="page-item">
<a href="{{closed_issues.next_url}}" class="page-link">
Next
</a>
</li>
{% else %}
<li class="page-item-disabled">
<span class="page-link">Next</span>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
</ul>
</nav>
</div>
</div>
</div>
{% endif %}
{% if gitlab_project.id == 'NA' %}
<!-- Render this block in case of gitlab down (gitlab_project.id == NA) -->
<div class="row mt-4">
<div class="col-12">
<p>
{% url 'user-landing' results.user_identifier as go_back_url %}
Sorry for the inconvenience. Please click <a href="{{go_back_url}}">
here to go back to your landing page</a>.
</p>
</div>
</div>
{% endif %}
{% endblock %}
\ No newline at end of file
......@@ -15,13 +15,51 @@ import pprint
pp = pprint.PrettyPrinter(indent=4)
from django.core.cache import cache
# Note: If you run tests with --tag prefix, you can test a small suite
#--------------------------TESTING NOTES -----------------------------
# LOCATIONS:
#
# Tests of views relating to when GitLab is down ('fail gracefully')
# are in gl_bot > tests.py; however, these do not need to be called
# separately. Django will run all properly configured test.py files when
# tests are called with manage.py test (with or without 'coverage run' prefix.)
#
# COVERAGE:
#
# To get coverage report through python-coverage, run the following:
#
# $ coverage erase
# $ coverage run manage.py test
# $ coverage html ****OR**** coverage report
#
# "coverage report" generates a report in terminal. "coverage html"
# generates an easy to parse html report in html_cov > index.html
# PREFIXES: