Commit e575e4e0 authored by MariaV's avatar MariaV
Browse files

Merge branch 'fix_templates' into 'master'

Fixed several issues with templates and template styling

See merge request !71
parents 14961248 f2661b93
Loading
Loading
Loading
Loading
+59 −24
Original line number Diff line number Diff line
@@ -14,23 +14,40 @@
  {% if results.issue %}
  </h3>
  <div class="row justify-content-between">
      <p class="col-auto mb-0 small pb-0 pt-0">{{results.project.name_with_namespace}} ({{results.project.id}}) > issues > #{{results.issue.iid}}</p>
      <p class="col-auto text-muted small mb-0 pb-0 pt-0 text-right">Created {{results.issue.created_at|pretty_datetime}} by @{{results.issue.author.username}}</p>
    <p class="col-auto mb-0 small pb-0 pt-0">
      <a href="{{results.go_back_url}}">
        {{results.project.name_with_namespace}}
      </a> 
      ({{results.project.id}}) / issues / #{{results.issue.iid}}
    </p>
    <p class="col-auto text-muted small mb-0 pb-0 pt-0 text-right">
      Created {{results.issue.created_at|pretty_datetime}} by @{{results.issue.author.username}}
    </p>
  </div>
  <hr class="mb-0 mt-0">
  <div class="row justify-content-between">
    <div class="col-auto"><p class="mb-0 small pb-0 pt-0">
    <div class="col-auto">
      <p class="mb-0 small pb-0 pt-0">
      {% if results.issue.milestone.title %}
      Milestone: {{results.issue.milestone.title}}.
      {% else %}
      Milestone: <span class="text-muted">(None Assigned.)</span>
      {% endif %}
    </p></div>
      </p>
    </div>
  <!-- Generate Links Badges and Labels Pill-Badges -->
    <div class="col-auto">
      <p class="text-muted small mb-0 pb-0 pt-0 text-right">
        {% for label in results.issue.labels %}
        <span class="badge-pill badge-primary ml-1">{{label}}</mark></span>
        {% endfor %}</p>
        <span class="badge-pill badge-primary mr-1 mt-1">{{label}}</mark></span>
        {% endfor %}
        <!-- Back to Project Badge -->
        <a class="btn btn-sm btn-outline-primary ml-4 px-1 py-0" href="{{results.go_back_url}}">Back To Project</a>
        <!-- Generate See on Gitlab button   -->
        <a class="btn btn-sm btn-outline-primary ml-2 px-1 py-0" href="{{results.issue.web_url}}" target="__blank">See on Gitlab</a>
        <!-- Create Note Badge -->
        <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>
  </div>
  <div class="row  mt-5">
@@ -56,9 +73,10 @@
{% endblock %}

{% block content %}

<!-- Issue Summary Block -->
{% if results.issue %}
  <div class="row">
  <div class="row mt-3">
    <div class="col-12">
      <h4 class="card-title">Issue Summary</h4>
      <ul>
@@ -78,14 +96,18 @@
    <a href="{{results.new_note_link}}">create a new note</a> for this issue.
  </p>
</div>

<!-- Notes Block -->
{% if results.notes %}
<div class="row">
<!-- Note Header Block -->
<div class="row mt-5">
  <div class="col-12 p-2">
    <h4 class="card-title">Project Notes</h4>
  </div>
</div>

<!-- If notes, iterate through them and display cards. -->
<div class="p2 bg-light">
  {% if results.notes %}
  {% for note in results.notes %}
  <div class="row">
    <div class="col-12 p-2">
@@ -101,6 +123,19 @@
    </div>
  </div>
  {% endfor %}
  {% else %}
  <!-- If no notes, generate a "No notes block". -->
  <div class="row">
    <div class="col-12 p-2">
      <div class="card mb-2">
        <div class="card-body">
          <p class="card-text text-muted">
            There are no notes for this issue at this time.
          </p>
        </div>
      </div>
    </div>
  </div>
  {% endif %}
</div>
{% endblock %}
 No newline at end of file
+31 −20
Original line number Diff line number Diff line
@@ -15,8 +15,12 @@
<!-- 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}} ({{object.gitlab_id}})</p>
    <p class="col-auto text-muted small mb-0 pb-0 pt-0 text-right"><a href="{{object.url}}">View this project on Gitlab</a></p>
    <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 -->
@@ -34,7 +38,7 @@
{% endblock %}

{% block content %}
<!-- Generate a user-actiosn block -->
<!-- Create the user-actions block -->
<div class="row">
  <div class="col-12">
    <p>
@@ -49,11 +53,16 @@
</div>

<!-- Create the Issues List Block For Open Issues-->
<div class="row mb-3">
  <div class="col-12">
    <p>Open Issues:</p>
<div class="row">
  <div class="col-12 mt-5">
    <h4 class="text-primary"> Open Issues
      <!-- Create New Issue badge link -->
      <a href="{{create_url}}" class="badge btn btn-outline-primary ml-2">
        Create New
      </a>
    </h4> 
    {% if issues_list %}
      <table class="table table-sm">
      <table class="table table-sm mt-3">
        {% for issue in issues_list %}
          {% if issue.state == "opened" %}
          <tr>
@@ -85,8 +94,9 @@
          {% endif %}
        {% endfor %}
      </table>
    {% else %}
      <p> No open issues at this time. </p>      
    {% endif %}
    {% if open_issues_flag == False %}
      <p class="ml-3 text-muted"> No open issues at this time. </p>      
    {% endif %}
  </div>
</div>
@@ -94,9 +104,9 @@
<!-- Create the Issues List Block for closed issues-->
<div class="row mt-5">
  <div class="col-12">
    <p>Closed Issues:</p>
    <h4 class="text-primary">Closed Issues:</h4>
    {% if issues_list %}
      <table class="table table-sm">
      <table class="table table-sm mt-3">
        {% for issue in issues_list %}
          {% if issue.state == "closed" %}
          <tr>
@@ -124,8 +134,9 @@
          {% endif %}
        {% endfor %}
      </table>
    {% else %}
      <p> No open issues at this time. </p>      
    {% endif %}
    {% if closed_issues_flag == False %}
    <p class="ml-3 text-muted"> No closed issues at this time. </p>      
    {% endif %}
  </div>
</div>
+24 −22
Original line number Diff line number Diff line
@@ -87,26 +87,6 @@ def check_user(user_identifier):
def validate_user(view_func):
    """A decorator that calls check_user validator."""
    @functools.wraps(view_func)
    # def validate_user_identifier(request, user_identifier, *args, **kwargs):
    #     user_string = user_identifier
    #     id_to_test = user_string.split('-')
    # # Check that code-phrase length is equal to settings.DICE_ROLLS
    #     if len(id_to_test) != settings.DICE_ROLLS:
    #         return redirect('user-login-error', user_identifier=user_string)
    # # Check that all words in code-phrase are unique
    #     set_id_to_test = set(id_to_test)
    #     if len(set_id_to_test) != len(id_to_test):
    #         return redirect('user-login-error', user_identifier=user_string)
    # # Grab the word_list from the path specified in settings.py
    #     wordlist_as_list = get_wordlist()
    # # Check that all words are in the dictionary.
    #     check_all_words  = all(item in wordlist_as_list for item in id_to_test)
    #     if check_all_words == False:
    #         return redirect('user-login-error', user_identifier=user_string)
    #     else:
    #         response = view_func(request, user_identifier, *args, **kwargs)
    #     return response
    # return validate_user_identifier
    def validate_user_identifier(request, user_identifier, *args, **kwargs):
        get_user_identifier = check_user(user_identifier)
        if get_user_identifier == False:
@@ -333,8 +313,26 @@ class ProjectDetailView(DetailView):
        context['gitlab_project'] = gitlab_project.attributes
        issues_list = gitlab_project.issues.list()
        context['issues_list'] = issues_list
        context['open_issues_flag'] = self.check_if_open_issues(issues_list)
        context['closed_issues_flag'] = self.check_if_closed_issues(issues_list)
        return context

    def check_if_open_issues(self, issues_list):
        open_issues = False
        for issue in issues_list:
            if issue.state == 'opened':
                open_issues = True
                return open_issues
        return open_issues
    
    def check_if_closed_issues(self, issues_list):
        closed_issues = False
        for issue in issues_list:
            if issue.state == 'closed':
                closed_issues = True
                return closed_issues
        return closed_issues
    
# -------------------------ISSUE VIEWS----------------------------------
# Views related to creating/looking up issues.
# ----------------------------------------------------------------------
@@ -401,6 +399,8 @@ def issue_detail_view(request, user_identifier, project_slug, gitlab_iid):
    gitlab_id = database_project.gitlab_id
    working_project = gitlab_get_project(project=gitlab_id)
    results['project'] = working_project.attributes
    go_back_url = reverse('project-detail', args=[user_identifier, project_slug])
    results['go_back_url'] = go_back_url
    working_issue = gitlab_get_issue(project=gitlab_id, issue=gitlab_iid)
    results['issue'] = working_issue.attributes
    # Get the notes list, and then for every note in the list, grab that
@@ -412,7 +412,9 @@ def issue_detail_view(request, user_identifier, project_slug, gitlab_iid):
        results['notes'].append(note_dict)
    results['notes'].reverse()
    # Generate notes link.
    new_note_link = reverse('create-note', args=[user_identifier, project_slug, gitlab_iid])
    new_note_link = reverse('create-note', args=[
        user_identifier, project_slug, gitlab_iid
        ])
    results['new_note_link'] = new_note_link
    return render(request, 'anonticket/issue_detail.html', {'results': results})