Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Unit Level Epub Export #1977

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 64 additions & 40 deletions gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/lms.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% block body_content %}
{% check_is_gstaff group_id request.user as is_gstaff %}


<!-- LMS.html -->
{% comment %}
{% include "ndf/buddy.html" %}
Expand All @@ -26,47 +26,42 @@
{% get_group_object group_id as group_object %}
<div class="lms_page">
<div class="lms_banner">

{% include 'ndf/widget_photo_upload.html' with url_name='course_about' widget_for="group_banner" is_banner=True no_update_btn=True node=group_obj %}

<div class="small-12 columns lms_heading">
<div class="left unit_name"> {% firstof group_object.altnames group_object.name %}
</div>

</div>
</div>
</div>
{% with group_object.member_of_names_list as group_object_member_of_names_list %}
<div class="lms_secondary_header">
<div class="small-10 medium-10 large-10 columns lms-menu-header">
<ul class="nav_menu_1">
<div class="small-10 medium-10 large-10 columns" style="border-bottom: 1px solid #00000029; background-color:#ffffff;">

<ul class="nav_menu_1" style="width:50%; display:inline">
<li>

<a href="{% url 'course_content' group_name %}" {% if title == 'course content' or title == 'unit_authoring' %}class="selected"{% endif %} tabindex="2" title="List of all the lessons"><i class="fi-list-thumbnails"></i>
<a href="{% url 'course_content' group_name %}" {% if title == 'course content' or title == 'unit_authoring' %}class="selected"{% endif %} tabindex="2" title="List of all the lessons"><i class="fi-list-thumbnails"></i>
{% if not group_object.project_config.tab_name %}{% trans "Lessons" %}{% else %}{{group_object.project_config.tab_name}} {% endif %}</a>

{% if is_gstaff %}
{% if request.author.agency_type != 'Teacher' or "Author" in group_object_member_of_names_list %}
<a href="{% url 'unit_detail' group_name %}" title="Edit Structure" style="background-color:#713558; border-radius:4px; margin-left:-13px; width:0px;"><i class="fa fa-pencil" style="margin-left:-7px; color:white;"></i></a>{% endif %}{% endif %}

{% if is_gstaff and request.author.agency_type != 'Teacher' %}<a href="{% url 'unit_detail' group_name %}" title="Edit Structure" style="background-color:#6f0859; border-radius:4px; margin-left:-13px; width:0px;"><i class="fa fa-pencil" style="margin-left:-7px; color:white;"></i>{% endif %}</a>
</li>

<li> <a href="{% url 'course_raw_material' group_name %}" {% if title == 'raw material' or title == "raw_material_detail" %}class="selected"{% endif %} tabindex="3" title="Contains useful files such as images, audios, videos etc."><i class="fi-folder "></i>
<li> <a href="{% url 'course_raw_material' group_name %}" {% if title == 'raw material' or title == "raw_material_detail" %}class="selected"{% endif %} tabindex="3" title="Contains useful files such as images, audios, videos etc."><i class="fi-folder "></i>
{% if not group_object.project_config.resource_name %}{% trans "Resources" %}{% else %}{{group_object.project_config.resource_name}} {% endif %}</a> </li>
<li>
<a href="{% url 'course_gallery' group_name %}" {% if title == 'gallery' or title == "asset_gallery_detail" %} class="selected" {% endif %} tabindex="4" title="Upload and share your files such as images, audios, videos, spreadsheets"> <i class="fi-photo "></i>{% if 'Group' in group_object_member_of_names_list %} {% trans "E-Library" %} {% else %} {% trans "Gallery" %}{% endif %}</a>
<a href="{% url 'course_gallery' group_name %}" {% if title == 'gallery' or title == "asset_gallery_detail" %} class="selected" {% endif %} tabindex="4" title="Upload and share your files such as images, audios, videos, spreadsheets"> <i class="fi-photo "></i>{% if 'Group' in group_object_member_of_names_list %} {% trans "E-Library" %} {% else %} {% trans "Gallery" %}{% endif %}</a>
</li>
<li>
<a href="{% url 'course_notebook' group_name %}" {% if title == 'notebook' %}class="selected"{% endif %} tabindex="5" title="Create and share notes, read notes shared by all students"><i class="fa fa-edit header_icon"></i> {% if not group_object.project_config.blog_name %}{% trans "e-Notes" %}{% else %} {{group_object.project_config.blog_name}} {% endif %}
</a>
</li>
{% if request.user.is_authenticated %}
<li>
<a {% if is_gstaff %} href="{% url 'course_analytics_admin' group_name %}" {% else %} href="{% url 'course_analytics' group_id request.user.pk %}" {% endif %}{% if title == 'course_analytics' %} class="selected" {% endif %} tabindex="6" title="See how you have done, how many comments have you received." > <i class="fa fa-line-chart"></i>
{% if 'Group' in group_object_member_of_names_list or 'Author' in group_object_member_of_names_list %}
{% trans "Stats" %}
{% else %}
<a {% if is_gstaff %} href="{% url 'course_analytics_admin' group_name %}" {% else %} href="{% url 'course_analytics' group_id request.user.pk %}" {% endif %}{% if title == 'course_analytics' %} class="selected" {% endif %} tabindex="6" title="See how you have done, how many comments have you received." > <i class="fa fa-line-chart"></i>
{% if 'Group' in group_object_member_of_names_list %}
{% trans "Stats" %}{% else %}
{% if is_gstaff %}
{% trans "Group Progress" %}
{% else %}
Expand All @@ -81,53 +76,80 @@
<a href="{% url 'curriculum_list' groupid %}" tabindex="6"> <i class="fa fa-sitemap "> </i> {% trans "Topic Map" %}</a>
</li>
{% endif %}
{% comment %}
<li>
<a href="{% url 'gtask' group_id %}" tabindex="7" > <i class="fa fa-list-alt"></i> {% trans "Task" %}</a>
</li>


<li>
<a href="{% url 'course_about' group_id %}" {% if title == 'about' %}class="selected"{% endif %} tabindex="1" title="Course Summary"><i class="fi-eye"></i> {% trans "Overview" %} </a>
</li>
<li>
<a href="{% url 'course_content' group_id %}" {% if title == 'course content' or title == 'unit_authoring' %}class="selected"{% endif %} tabindex="2" title="List of all the lessons"><i class="fi-list-thumbnails"></i>
{% if not group_object.project_config.tab_name %}{% trans "Lessons" %}{% else %}{{group_object.project_config.tab_name}} {% endif %}</a>
{% if is_gstaff %}<a href="{% url 'unit_detail' groupid %}" title="Edit Structure" style="background-color:#6f0859; border-radius:4px; margin-left:-13px; width:0px;"><i class="fa fa-pencil" style="margin-left:-7px; color:white;"></i>{% endif %}</a>
</li>
{% if 'Group' not in group_object_member_of_names_list or 'base_unit' in group_object_member_of_names_list %}
<li> <a href="{% url 'course_raw_material' group_id %}" {% if title == 'raw material' or title == "raw_material_detail" %}class="selected"{% endif %} tabindex="3" title="Contains useful files such as images, audios, videos etc."><i class="fi-folder "></i> {% trans "Resources" %}</a> </li>
{% endif %}
<li>
<li> <a href="{% url 'course_gallery' group_id %}" {% if title == 'gallery' or title == "asset_gallery_detail" %} class="selected" {% endif %} tabindex="4" title="Upload and share your files such as images, audios, videos, spreadsheets"> <i class="fi-photo "></i>{% if 'Group' in group_object_member_of_names_list and 'base_unit' not in group_object_member_of_names_list %} {% trans "E-Library" %} {% else %} {% trans "Gallery" %}{% endif %}</a> </li>
<li>
<a href="{% url 'course_notebook' group_id %}" {% if title == 'notebook' %}class="selected"{% endif %} tabindex="5" title="Create and share notes, read notes shared by all students"><i class="fi-book "></i>
{% if 'Group' in group_object_member_of_names_list and 'base_unit' not in group_object_member_of_names_list %}
{% trans "Blog" %}
{% else %}
{% trans "e-Notes" %}
{% endif %}
</a>
</li>
</li>
{% endcomment %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this code is not needed, remove it.
If needed in near future, add developers note/comments in it.

</ul>
<ul class="nav_menu_1 authoring-tab">
{% if is_gstaff %}
{% if request.author.agency_type != 'Teacher' or group_object.agency_type == 'School' or "Author" in group_object_member_of_names_list %}
<ul class="nav_menu_1 authoring-tab" style="width:50%; display:inline">

{% if is_gstaff and request.author.agency_type != 'Teacher' or group_object.agency_type == 'School' %}
<li>
<a href="{% url 'course_pages' group_name %}" {% if title == 'course_pages' or title == 'create_course_pages' %}class="selected"{% endif %}><i class="fi-page-filled "></i> {% trans "Activities" %}</a>
</li>
<li>
<a href="{% url 'asset_list' group_name %}" {% if title == 'asset_list' or title == 'asset_detail' or title == 'asset_content_detail'%}class="selected"{% endif %}><i class="fi-folder-lock"></i> {%trans "Assets" %}</a>
</li>
{% if group_object.agency_type != 'School' and "Author" not in group_object_member_of_names_list %}
{% if group_object.agency_type != 'School' %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While making changes in any of the logical conditions, test it with following use users:

  1. Anonymous
  2. Normal
  3. Group Admin
  4. Super

<li>
<a href="https://assessments-clix.tiss.edu/" target="_blank" {% if title == 'Assessments' %}class="selected"{% endif %}><i class="fi-graph-trend"></i> {% trans "Assessments" %}</a>
</li>
{% endif %}
{% if group_object.agency_type == 'School' or "Author" in group_object_member_of_names_list %}
<li>
<a href="/h5p" target="_blank" {% if title == 'Assessments' %}class="selected"{% endif %}><i class="fi-graph-trend"></i> {% trans "Assessments" %}</a>
</li>
{% endif %}
{% endif %}
{% endif %}

</ul>
</div>
<div class="small-2 medium-2 large-2 columns lms-menu-header">
<div class="small-2 medium-2 large-2 columns" style="border-bottom: 1px solid #00000029; background-color:#ffffff; height: 53px;">
{% if is_gstaff %}
<div class="small-3 medium-6 large-6 columns course_actions">
<span data-dropdown="course-settings-drop" class="orange-button" aria-controls="course-settings-drop" aria-expanded="false" data-options="align:left">
<div class="small-3 medium-6 large-6 columns course_actions" style="color:#164a7b;">
<span data-dropdown="course-settings-drop" aria-controls="course-settings-drop" aria-expanded="false" data-options="align:left">
<i class="icon-widget fi-widget"></i>
</span>
<ul id="course-settings-drop" class="f-dropdown" data-dropdown-content aria-hidden="true" tabindex="-1">
{% if request.author.agency_type != 'Teacher' or "Author" in group_object_member_of_names_list or group_object.agency_type == 'School' %}
{% if request.author.agency_type != 'Teacher' or group_object.agency_type == 'School' %}


<li>
<a href="{% url 'unit_detail' group_name %}" class="fi-pencil"> {% trans "Edit Structure" %} </a>
</li>

<li>
<a class="fi-photo group-banner-change" data-reveal-id="group_banner_prof_pic_prop">{% trans "Change image" %}</a>
<a class="fi-photo" style="position: relative;top: -3px;left: 2px;" data-reveal-id="group_banner_prof_pic_prop">
{% trans "Change image" %}</a>
</li>
{% if 'Group' not in group_object_member_of_names_list and 'announced_unit' in group_object_member_of_names_list or "base_unit" in group_object_member_of_names_list %}
<li>
<a href="{% url 'create_event_group' group_id 'CourseEventGroup' %}" class="fi-volume"> {% trans "Announce" %}</a>
</li>
{% endif %}



<li>
<a href="{% url 'unit_edit' group_name group_object.pk %}" class="fi-pencil"> {% trans "Edit Metadata" %}</a>
</li>
Expand All @@ -144,23 +166,25 @@ <h3>{% trans "Delete Unit:" %} {% firstof group_object.altnames group_object.nam
</div>
{% endif %}
{% endif %}
{% if "Author" not in group_object_member_of_names_list %}

<li>
<a data-reveal-id="manage_users_modal" href="{% url 'manage_users' group_id %}" class="fi-torsos"> {% trans "Manage Users" %}</a>
<div id="manage_users_modal" class="reveal-modal large" data-reveal>
<div id="manage_users_modal" class="reveal-modal large" data-reveal style="position:absolute;">
<div id="group_drawer">
{% include "ndf/widget_user_search.html" with subscription_status=True %}
</div>
<a class="close-reveal-modal">&#215;</a>
</div>
</li>
{% endif %}


{% get_lessons group_object as lessons_list %}
{% include 'ndf/epub_export_widget.html' with exp_collection=lessons_list %}
<li class="lesson_name_in_export">
<a href="#" data-reveal-id='exportLesson' class="export_lesson fi-archive" title="Export Content into distinct ePubs"> {% trans "Export Content into ePubs" %}</a>
</li>
<li class="unit_name_in_export">
<a href="{% url 'export_unit_to_epub' group_id %}" class="fi-archive" title="Export unit into ePub(testing)"> {% trans "Export Unit into ePub" %}</a>
</li>
</ul>
</div>
{% endif %}
Expand Down Expand Up @@ -220,7 +244,7 @@ <h3>{% trans "Delete Unit:" %} {% firstof group_object.altnames group_object.nam
{% if title == "raw material" %}
{% include "ndf/assets.html" with title=title %}
{% endif %}

{% if title == "gallery" %}
{% include "ndf/assets.html" with title=title %}
{% endif %}
Expand Down Expand Up @@ -321,7 +345,7 @@ <h3>{% trans "Delete Unit:" %} {% firstof group_object.altnames group_object.nam
$('.lms_banner').backstretch(imgSrc);

// setTimeout(function(){

// }, 1000);
</script>

Expand Down
1 change: 1 addition & 0 deletions gnowsys-ndf/gnowsys_ndf/ndf/urls/ajax-urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
url(r'^save_metadata', 'save_metadata', name='save_metadata'),
url(r'^save_interactions', 'save_interactions', name='save_interactions'),
url(r'^export_to_epub/(?P<node_id>[\w-]+)', 'export_to_epub', name='export_to_epub'),
url(r'^export_unit_to_epub','export_unit_to_epub',name='export_unit_to_epub'),#Added by Gargi Balasubramaniam
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary because git keeps details for each and every line:

  • creator
  • timestamp
  • commit no
  • commit msg

url(r'^remove_related_oc/', 'remove_related_doc', name='remove_related_doc'),
url(r'^get_admin_page_form', 'get_admin_page_form', name='get_admin_page_form'),
url(r'^get_help_page_form', 'get_help_page_form', name='get_help_page_form'),
Expand Down
22 changes: 22 additions & 0 deletions gnowsys-ndf/gnowsys_ndf/ndf/views/ajax_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6759,6 +6759,7 @@ def add_asset(request,group_id):
except:
group_name, group_id = get_group_name_id(group_id)
group_obj = Group.get_group_name_id(group_id, get_obj=True)

topic_gst = node_collection.one({'_type': 'GSystemType', 'name': 'Topic'})
topic_nodes = node_collection.find({'member_of': {'$in': [topic_gst._id]}})
context_variables = {'group_id':group_id, 'groupid':group_id,'edit': False}
Expand All @@ -6780,6 +6781,7 @@ def create_edit_asset(request,group_id):
group_id = ObjectId(group_id)
except:
group_name, group_id = get_group_name_id(group_id)

group_obj = Group.get_group_name_id(group_id, get_obj=True)
selected_topic = request.POST.get("topic_list", '')
# selected_topic_list = request.POST.getlist("coll_arr[]", '')
Expand Down Expand Up @@ -7086,6 +7088,26 @@ def export_to_epub(request, group_id, node_id):
pass
return HttpResponseRedirect(reverse('unit_detail', kwargs={'group_id': group_id}))



def export_unit_to_epub(request,group_id):

from gnowsys_ndf.ndf.views.export_unit_to_epub import *
response_dict = {'success': False}
try:
group_obj = node_collection.one({'_id': ObjectId(group_id)})
epub_loc = create_epub(group_obj)
print 'hey!'
zip_file = open(epub_loc, 'rb')
response = HttpResponse(zip_file.read(), content_type="application/epub+zip")
response['Content-Disposition'] = 'attachment; filename="' + slugify(group_obj.name) + '.epub"'
return response
except Exception as export_fail:
print "\n export_fail: ", export_fail
pass
return HttpResponseRedirect(reverse('unit_detail', kwargs={'group_id': group_id}))


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use the existing method and make it more versatile. Method behavior should be decided by args.

def remove_related_doc(request, group_id):
node = request.POST.get('node', None)
selected_obj = request.POST.get('sel_file', None)
Expand Down
Loading