From 784bd265106f1cb3ed2a0fef47ed93d94d81738c Mon Sep 17 00:00:00 2001 From: Rocky Duan Date: Sun, 22 Jul 2012 19:05:32 -0400 Subject: [PATCH] forum view for discussions --- .../lib/xmodule/xmodule/discussion_module.py | 3 +- lms/djangoapps/django_comment_client | 1 + lms/lib/datehelper | 1 + lms/static/coffee/src/discussion.coffee | 12 +++++- lms/static/sass/_discussion.scss | 7 ++++ lms/templates/course_navigation.html | 2 +- lms/templates/discussion/accordion.html | 26 +++++++++++++ lms/templates/discussion/index.html | 39 +++++++++++++++++++ .../inline.html} | 0 9 files changed, 88 insertions(+), 3 deletions(-) create mode 120000 lms/djangoapps/django_comment_client create mode 120000 lms/lib/datehelper create mode 100644 lms/templates/discussion/accordion.html create mode 100644 lms/templates/discussion/index.html rename lms/templates/{discussion.html => discussion/inline.html} (100%) diff --git a/common/lib/xmodule/xmodule/discussion_module.py b/common/lib/xmodule/xmodule/discussion_module.py index 1def043503..3e9c133002 100644 --- a/common/lib/xmodule/xmodule/discussion_module.py +++ b/common/lib/xmodule/xmodule/discussion_module.py @@ -16,13 +16,14 @@ class DiscussionModule(XModule): 'parse': dateutil.parser.parse, 'commentable_id': self.discussion_id, } - return self.system.render_template('discussion.html', context) + return self.system.render_template('discussion/inline.html', context) def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs): XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs) xml_data = etree.fromstring(definition['data']) self.discussion_id = xml_data.attrib['id'] self.title = xml_data.attrib['for'] + self.category = xml_data.attrib['category'] class DiscussionDescriptor(RawDescriptor): module_class = DiscussionModule diff --git a/lms/djangoapps/django_comment_client b/lms/djangoapps/django_comment_client new file mode 120000 index 0000000000..7ff5047e93 --- /dev/null +++ b/lms/djangoapps/django_comment_client @@ -0,0 +1 @@ +/Users/dementrock/coding/cs_comments_client_python/djangoapp \ No newline at end of file diff --git a/lms/lib/datehelper b/lms/lib/datehelper new file mode 120000 index 0000000000..bef380425d --- /dev/null +++ b/lms/lib/datehelper @@ -0,0 +1 @@ +/Users/dementrock/coding/datehelper \ No newline at end of file diff --git a/lms/static/coffee/src/discussion.coffee b/lms/static/coffee/src/discussion.coffee index fb8bfbef24..dbe3f14e89 100644 --- a/lms/static/coffee/src/discussion.coffee +++ b/lms/static/coffee/src/discussion.coffee @@ -3,6 +3,16 @@ $ -> #DEBUG = true DEBUG = false + if $('#accordion').length + active = $('#accordion ul:has(li.active)').index('#accordion ul') + $('#accordion').bind('accordionchange', @log).accordion + active: if active >= 0 then active else 1 + header: 'h3' + autoHeight: false + $('#open_close_accordion a').click @toggle + + $('#accordion').show() + $(".discussion-title").click -> $thread = $(this).parent().children(".thread") if $thread.css("display") == "none" @@ -103,7 +113,7 @@ $ -> return $edit = $div.children(".discussion-content").find(".comment-edit") body = $edit.val() - $.post url, {body: body}, handleAnchorAndReload(response, textStatus) -> + $.post url, {body: body}, (response, textStatus) -> if textStatus == "success" handleAnchorAndReload(response) console.log response diff --git a/lms/static/sass/_discussion.scss b/lms/static/sass/_discussion.scss index e8f2d2b951..270ad9f40c 100644 --- a/lms/static/sass/_discussion.scss +++ b/lms/static/sass/_discussion.scss @@ -16,6 +16,13 @@ $discussion_input_width: 60%; } } +.course-content { + .discussion { + margin-left: 40px; + margin-top: 15px; + } +} + .discussion { .discussion-title { @include discussion-font; diff --git a/lms/templates/course_navigation.html b/lms/templates/course_navigation.html index 8bda22148d..9ab9be598e 100644 --- a/lms/templates/course_navigation.html +++ b/lms/templates/course_navigation.html @@ -15,7 +15,7 @@ def url_class(url):
  • Course Info
  • % if user.is_authenticated():
  • Textbook
  • -
  • Discussion
  • +
  • Discussion
  • % endif
  • Wiki
  • % if user.is_authenticated(): diff --git a/lms/templates/discussion/accordion.html b/lms/templates/discussion/accordion.html new file mode 100644 index 0000000000..61cb3f6774 --- /dev/null +++ b/lms/templates/discussion/accordion.html @@ -0,0 +1,26 @@ +<%! from django.core.urlresolvers import reverse %> + +<% +def url_for(board): + if board['category'] == 'General': + return reverse('django_comment_client.forum.views.forum_form_discussion', args=[course.id.replace('/', '-'), 'general']) + else: + return reverse('django_comment_client.forum.views.forum_form_discussion', args=[course.id.replace('/', '-'), board['discussion_id']]) +%> + +<%def name="make_category(category, boards)"> +

    ${category}

    + + + + +% for category, boards in discussion_info.items(): + ${make_category(category, boards)} +% endfor diff --git a/lms/templates/discussion/index.html b/lms/templates/discussion/index.html new file mode 100644 index 0000000000..85f611ee38 --- /dev/null +++ b/lms/templates/discussion/index.html @@ -0,0 +1,39 @@ +<%inherit file="../main.html" /> +<%namespace name='static' file='../static_content.html'/> +<%block name="bodyclass">courseware discussion +<%block name="title">Discussion – MITx 6.002x + +<%block name="headextra"> + + + +<%block name="js_extra"> + + + + +<%include file="../course_navigation.html" args="active_page='discussion'" /> + +
    +
    +
    +
    +

    Discussion Boards

    + close +
    + + +
    + +
    + ${content} +
    +
    +
    diff --git a/lms/templates/discussion.html b/lms/templates/discussion/inline.html similarity index 100% rename from lms/templates/discussion.html rename to lms/templates/discussion/inline.html