diff --git a/anonticket/templates/anonticket/note_pending.html b/anonticket/templates/anonticket/note_pending.html
new file mode 100644
index 0000000000000000000000000000000000000000..6531a14a1c71f41f00eaad67e75680e69206f0ce
--- /dev/null
+++ b/anonticket/templates/anonticket/note_pending.html
@@ -0,0 +1,49 @@
+{% extends 'shared/layout.html' %}
+{% load static %}
+
+{% load custom_filters %}
+
+{% load markdownify %}
+
+{% block extra_links %}
+ {% include 'shared/extend_sidebar.html' %}
+{% endblock %}
+
+{% block h3 %}
+
+
+
{{note.linked_project}}
+
Created by {{note.linked_user.user_identifier}}
+
+
+
Milestone: NA, Note Pending Mod Approval.
+
+
+ Labels: NA, Note Pending Mod Approval
+
+
+
+
+
You have created the following notes:
+
+ {% url 'issue-search' results.user_identifier as search_url %}
+ {% url 'project-list' results.user_identifier as project_list_url%}
+
(To create a new note,
+ search for the issue you want to comment on, or look at the
+ project's detail view to find an issue.
+ Notes marked with *** have not been approved by moderators
+ and therefore have not been posted to GitLab.)
+ {% if results.linked_notes %}
+
+ {% for note in results.linked_notes %}
+
+ {% if note.gitlab_id %}
+ {% url 'issue-detail-view' results.user_identifier note.linked_project.slug note.issue_iid as issue_url %}
+ - Posted on {{note.linked_project.name_with_namespace}} > {{note.gitlab_issue_title}}:
+ "{{note.body|truncatewords:20}}"
+
+ {% else %}
+ {% url 'pending-note' results.user_identifier note.linked_project.slug note.issue_iid note.pk as note_url %}
+ - (Pending) on {{note.linked_project.name_with_namespace}} > {{note.gitlab_issue_title}}:
+ "{{note.body|capfirst|truncatewords:20}}" ***
+ {% endif %}
+ {% endfor %}
+
+
+ {% else %}
+
+
You have not created any Notes.
+ {% endif %}
+
+
{% endblock %}
\ No newline at end of file
diff --git a/anonticket/tests.py b/anonticket/tests.py
index b9595ef7c27bd9a535a950c24a0cc768d84844dd..cdf0875c86681d03c7cd362b325ec7db061cf23f 100644
--- a/anonticket/tests.py
+++ b/anonticket/tests.py
@@ -11,6 +11,8 @@ from anonticket.forms import (
Anonymous_Ticket_Base_Search_Form,
Anonymous_Ticket_Project_Search_Form,
CreateIssueForm)
+import pprint
+pp = pprint.PrettyPrinter(indent=4)
# Create your tests here.
@@ -655,8 +657,11 @@ class TestModeratorViews(TestCase):
# will allow test group permissions to exactly match those from file.
from anonticket.management.commands.create_groups import GROUPS
from anonticket.management.commands.create_groups import Command as create_groups
+ # Add a bad permission call so that you can test this part of the code.
+ GROUPS["Account Approvers"]["user identifier"].append("smash")
create_groups.handle(create_groups)
self.Moderators = Group.objects.get(name="Moderators")
+ self.AccountApprovers = Group.objects.get(name="Account Approvers")
# Set up users to test the staff decorator and is_mod decorator.
UserStaffNoGroup = User.objects.create(
@@ -682,6 +687,14 @@ class TestModeratorViews(TestCase):
self.UserGroupAndStaff = UserGroupAndStaff
self.Moderators.user_set.add(UserGroupAndStaff)
+ UserAccountApprover = User.objects.create(
+ username='UserAccountApprover',
+ password='IAmATestPassword',
+ is_staff=True,
+ )
+ self.UserAccountApprover = UserAccountApprover
+ self.AccountApprovers.user_set.add(UserAccountApprover)
+
# set the login redirect url for views testing
from anonticket.views import login_redirect_url as login_redirect_url
self.login_redirect_url = login_redirect_url
@@ -711,7 +724,15 @@ class TestModeratorViews(TestCase):
self.assertEqual(self.UserGroupAndStaff.username, "UserGroupAndStaff")
self.assertTrue(self.UserGroupAndStaff.is_staff)
self.assertTrue(self.UserGroupAndStaff.groups.filter(name="Moderators").exists())
-
+
+ def test_user_account_approver_created_successfully(self):
+ """Tese that the username exists, that the user is staff, and that
+ the user is part of the Account Approvers group."""
+ self.assertEqual(self.UserAccountApprover.username, "UserAccountApprover")
+ self.assertTrue(self.UserAccountApprover.is_staff)
+ self.assertTrue(
+ self.UserAccountApprover.groups.filter(name="Account Approvers").exists())
+
def test_moderator_view_GET_not_logged_in(self):
"""Test that the moderator view redirects to a login form
if there is no logged in user."""
@@ -741,7 +762,22 @@ class TestModeratorViews(TestCase):
url = reverse('moderator')
response = self.client.get(url)
self.assertTemplateNotUsed(response, 'anonticket/moderator.html')
- # print(response)
+
+ def test_moderator_view_GET_account_approver(self):
+ """Test that the moderator view loads if a user is an account
+ approver."""
+ current_user = self.UserAccountApprover
+ self.client.force_login(current_user)
+ url = reverse('moderator')
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+ # Assert that the correct template loaded
+ self.assertTemplateUsed(response, 'anonticket/moderator.html')
+ # But that users in Account Approvers Group and not in Moderators
+ # Group do not have access to pending issues.
+ self.assertInHTML(
+ "You do not have permission to view pending issues at this time.",
+ 'You do not have permission to view pending issues at this time.
')
def test_moderator_view_GET_valid_moderator(self):
"""Test that the moderator view displays correctly if
diff --git a/anonticket/urls.py b/anonticket/urls.py
index b6b6b1fe07d7ef1d96d97a6d69d1b7b7dffdbe6b..415395813938384788d826903c6f769dfe439286 100644
--- a/anonticket/urls.py
+++ b/anonticket/urls.py
@@ -22,6 +22,7 @@ urlpatterns = [
path('user/login/', views.login_view, name='login'),
path('user/