Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
Completed the respond to selected page
Browse files Browse the repository at this point in the history
  • Loading branch information
dbreedt committed Apr 24, 2015
1 parent 03b8d77 commit 90eb523
Show file tree
Hide file tree
Showing 5 changed files with 484 additions and 0 deletions.
262 changes: 262 additions & 0 deletions oneplus/templates/misc/discussion_response_selected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
<!DOCTYPE html>
<html>
<head>
<title>Respond to Selected</title>

<link href="/static/grappelli/jquery/ui/css/custom-theme/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" type="text/css" media="screen">
<link href="/static/grappelli/stylesheets/screen.css" rel="stylesheet" type="text/css" media="screen">
<link href="/static/grappelli/stylesheets/mueller/grid/output.css" rel="stylesheet" type="text/css" media="screen">

<script type="text/javascript">window.__admin_media_prefix__ = "/static/grappelli/";</script>
<script type="text/javascript">window.__admin_utc_offset__ = "0";</script>
<script type="text/javascript" charset="utf-8">
var grappelli = {},
ADMIN_URL = "/admin/",
DATE_FORMAT = "%Y-%m-%d",
TIME_FORMAT = "%H:%M:%S",
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S";
</script>
<script src="/static/grappelli/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/static/grappelli/jquery/ui/js/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
<script src="/static/grappelli/js/grappelli.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" charset="utf-8">
(function($) {
$(document).ready(function() {
grappelli.initDateAndTimePicker();
});
})(grp.jQuery);
</script>
</head>
<body>
<header id="grp-header" class="">
<!-- NAVIGATION -->
<div id="grp-navigation">
<h1 id="grp-admin-title">OnePlus Admin</h1>

<ul id="grp-user-tools">
<!-- Userlinks -->
<!-- Username -->
<li class="grp-user-options-container grp-collapse grp-closed ">
<a href="javascript://" class="user-options-handler grp-collapse-handler grp-switch-user-is-original">admin</a>
<ul class="grp-user-options">
<!-- Change Password -->
<li><a href="/admin/password_change/" class="grp-change-password">Change password</a></li>

<!-- Logout -->
<li><a href="/admin/logout/" class="grp-logout">Log out</a></li>
<!-- Switch -->
</ul>
</li>
<!-- Documentation -->
</ul>

<!-- Nav-Global -->

<ul id="grp-user-tools">
<li class="grp-user-options-container grp-collapse grp-closed">
<a href="javascript://" class="user-options-handler grp-collapse-handler grp-switch-user-is-original">Extras</a>
<ul id="grp-user-options">
<li>
<a href="/dashboard">Dashboard</a>
<a href="/reports">Reports</a>
</li>
</ul>
</li>
</ul>

</div>

<!-- CONTEXT NAVIGATION -->
<div id="grp-context-navigation">
<nav id="grp-breadcrumbs" class="">
<header style="display:none"><h1>Breadcrumbs</h1></header>
<ul>
<li><a href="/admin/">Home</a></li>
<li><a href="/admin/communication/">Communication</a></li>
<li><a href="/admin/communication/discussion/">Discussions</a></li>
<li>Respond to Selected</li>
</ul>
</nav>
</div>
</header>
<article id="grp-content">

<h1>Respond to Selected</h1>
{% if no_discs %}
<h2>All the selected Discussions have been responded too</h2>
{% else %}
<form enctype="multipart/form-data" action="" method="post" id="discussion_response_form">
{% csrf_token %}
<div id="grp-content-container">
<fieldset class="grp-module ">
<div class="l-2c-fluid l-d-4">
<h2>Selected Discussions</h2>
</div>
<table>
<thead>
<tr>
<th scope="col" class="column-id">
<div class="grp-text">ID</div>
</th>
<th scope="col" class="column-get_question">
<div class="grp-text">Question</div>
</th>
<th scope="col" class="column-module">
<div class="grp-text">Module</div>
</th>
<th scope="col" class="column-course">
<div class="grp-text">Course</div>
</th>
<th scope="col" class="column-get_content">
<div class="grp-text">Content</div>
</th>
<th scope="col" class="column-author">
<div class="grp-text">Author</div>
</th>
<th scope="col" class="column-publishdate">
<div class="grp-text">Publish Date</div>
</th>
<th scope="col" class="column-get_response_posted">
<div class="grp-text">Response Posted</div>
</th>
<th scope="col" class="column-moderated">
<div class="grp-text">Moderated</div>
</th>
</tr>
</thead>
<tbody>
{% for disc in discs %}
<tr class="grp-row grp-row-even">
<td class="nowrap">
<a href="/admin/communication/discussion/{{ disc.id }}" target="_blank">{{ disc.id }}</a>
</td>
<td>
<a href="/admin/content/testingquestion/{{ disc.question.id }}" target="_blank">{{ disc.question.name }}</a>
<br>
<a href="/preview/{{ disc.question.id }}" target="_blank">View Question</a>
</td>
<td class="nowrap">
{{ disc.module }}
</td>
<td class="nowrap">
{{ disc.course }}
</td>
<td>
{{ disc.content|safe }}
</td>
<td class="nowrap">
{{ disc.author }}
</td>
<td class="nowrap">
{{ disc.publishdate }}
</td>
<td>
{{ disc.response }}
</td>
<td>
{% if disc.moderated %}
<img src="/static/admin/img/icon-yes.gif" alt="True">
{% else %}
<img src="/static/admin/img/icon-no.gif" alt="True">
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</fieldset>
</div>
<div id="grp-content-container">
<fieldset class="grp-module ">
<h2 class="grp-collapse-handler">Response</h2>
<div class="grp-row grp-cells-1">
<div class="l-2c-fluid l-d-4">
<div class="c-1">
<label class="required">Title</label>
</div>
<div class="c-2">
{% if ro %}
<label>{{ disc.title }}</label>
{% else %}
<input class="vTextField" id="id_title" maxlength="50" name="title" type="text" value="{{ v_title }}">
{% if title_error %}
<ul class="errorlist">
<li>This field is required.</li>
</ul>
{% endif %}
{% endif %}
</div>
</div>
</div>
<div class="grp-row grp-cells-1">
<div class="l-2c-fluid l-d-4">
<div class="c-1">
<label class="required" >Publish Date</label>
</div>
<div class="c-2">
{% if ro %}
<label>{{ disc.publish_date }}</label>
{% else %}
<p class="datetime">
<input class="vDateField" id="id_publishdate_0" name="publishdate_0" size="10" type="text" value="{{ v_date }}">
<br>
<input class="vTimeField" id="id_publishdate_1" name="publishdate_1" size="8" type="text" value="{{ v_time }}">
</p>

{% if dt_error %}
<ul class="errorlist">
<li>Please enter a valid date and time.</li>
</ul>
{% endif %}
{% endif %}
</div>
</div>
</div>
<div class="grp-row grp-cells-1">
<div class="l-2c-fluid l-d-4">
<div class="c-1">
<label class="required" for="id_content">Response Content</label>
</div>
<div class="c-2">
{% if ro %}
<label>{{ disc.content }}</label>
{% else %}
<textarea cols="40" hidden="true" id="id_content" name="content" rows="10">{{ v_content }}</textarea>
<script>
var settings_id_content = {
"lang": "en-US",
"url": {
"upload_attachment": "/summernote/upload_attachment/"
},
"airMode": false,
"height": "400",
"styleWithSpan": true,
"toolbar": [["style", ["style"]], ["style", ["bold", "italic", "underline", "clear"]], ["para", ["ul", "ol", "paragraph"]], ["table", ["table"]]]
};
</script>

<iframe id="id_content_iframe" src="/summernote/editor/id_content/" frameborder="0" cols="40" rows="10" width="100%" height="400"></iframe>

{% if content_error %}
<ul class="errorlist">
<li>This field is required.</li>
</ul>
{% endif %}
{% endif %}
</div>
</div>
</div>
</fieldset>
<footer class="grp-module grp-submit-row grp-fixed-footer">
<header style="display:none"><h1>Submit Options</h1></header>
<ul>
<li><input type="submit" value="Save" class="grp-button grp-default" name="_save"></li>
</ul>
</footer>
</div>
</form>
{% endif %}
</article>
</body>
</html>
87 changes: 87 additions & 0 deletions oneplus/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,93 @@ def test_admin_discussion_response(self):
self.assertEquals(disc.response.moderated, True)
self.assertEquals(disc.response.author, self.admin_user)

def test_admin_discussion_response_selected(self):
c = Client()
c.login(username=self.admin_user.username, password=self.admin_user_password)

question = self.create_test_question('q9', self.module)

resp = c.get('/discussion_response_selected/1000')
self.assertContains(resp, 'All the selected Discussions have been responded too')

learner = self.create_learner(
self.school,
first_name="jan",
username="+27223456888",
mobile="+27223456888",
country="country",
area="Test_Area",
unique_token='abc123',
unique_token_expiry=datetime.now() + timedelta(days=30),
is_staff=True
)

disc = Discussion.objects.create(
name='Test',
description='Test',
content='Test content',
author=learner,
publishdate=datetime.now(),
course=self.course,
module=self.module,
question=question
)

disc2 = Discussion.objects.create(
name='Test',
description='Test',
content='Test content again',
author=learner,
publishdate=datetime.now(),
course=self.course,
module=self.module,
question=question
)

participant = self.create_participant(
learner=learner,
classs=self.classs,
datejoined=datetime(2014, 3, 18, 1, 1)
)

resp = c.get('/discussion_response_selected/%s,%s' % (disc.id, disc2.id))
self.assertContains(resp, 'Respond to Selected')

resp = c.post('/discussion_response_selected/%s,%s' % (disc.id, disc2.id),
data={'title': '',
'publishdate_0': '',
'publishdate_1': '',
'content': ''
})
self.assertContains(resp, 'This field is required.')

resp = c.post('/discussion_response_selected/%s,%s' % (disc.id, disc2.id),
data={'title': '',
'publishdate_0': '2015-33-33',
'publishdate_1': '99:99:99',
'content': ''
})
self.assertContains(resp, 'Please enter a valid date and time.')

resp = c.post('/discussion_response_selected/%s,%s' % (disc.id, disc2.id))
self.assertContains(resp, 'This field is required.')

resp = c.post('/discussion_response_selected/%s,%s' % (disc.id, disc2.id),
data={'title': 'test',
'publishdate_0': '2014-01-01',
'publishdate_1': '00:00:00',
'content': '<p>Test</p>'
})

disc = Discussion.objects.get(pk=disc.id)
disc2 = Discussion.objects.get(pk=disc2.id)
self.assertIsNotNone(disc.response)
self.assertEquals(disc.response.moderated, True)
self.assertEquals(disc.response.author, self.admin_user)
self.assertIsNotNone(disc2.response)
self.assertEquals(disc2.response.moderated, True)
self.assertEquals(disc2.response.author, self.admin_user)


@override_settings(VUMI_GO_FAKE=True)
class LearnerStateTest(TestCase):
Expand Down
3 changes: 3 additions & 0 deletions oneplus/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
url(r"^sms_response/(?P<sms>\d+)$",
views.sms_response,
name="com.smsresp"),
url(r"^discussion_response_selected/(?P<disc>(\d+)(,\s*\d+)*)$",
views.discussion_response_selected,
name="com.discrespsel"),

# Progress
url(r"^ontrack$", views.ontrack, name="prog.ontrack"),
Expand Down
Loading

0 comments on commit 90eb523

Please sign in to comment.