Commit 79473b75 authored by saurabh's avatar saurabh

Merge branch 'mongokit' of https://github.com/gnowledge/gstudio into mongokit

parents 384b32c2 29c4a274
......@@ -45,7 +45,7 @@
</div>
<div class="large-9 columns">
<label>{% trans "Title of File" %}</label>
<input type="text" name="docTitle" id ="docTitle" tabindex=2 placeholder="Enter Title of File" required>
<input type="text" name="docTitle" id ="docTitle" tabindex=2 placeholder="Title of File" required>
<small class="error">Please provide the title of the resource.</small>
</div>
</div>
......@@ -53,12 +53,12 @@
<!-- other details -->
<fieldset style="background:#ccc;">
<legend style="background:#10c1cb">{% trans "Enter Details" %}</legend>
<legend style="background:#10c1cb">{% trans "Details" %}</legend>
<div class ="row">
<div class="large-5 columns">
<b>Add Description</b>
{% include "ndf/add_editor.html" with var_name="content_org" var_placeholder="Please enter question" %}
{% include "ndf/add_editor.html" with var_name="content_org" var_placeholder="Describe the file" %}
<div class="row">
......@@ -100,7 +100,7 @@
<div class="large-7 columns">
<div class ="row">
<div class="large-4 columns">
<b>Set Language</b>
<b>Language</b>
<select name="lan" tabindex=3 required>
<option value="">--- Select Language ---</option>
{% get_language_info_list for LANGUAGES as languages %}
......@@ -118,13 +118,16 @@
<a href="#view-map-edit-widget" data-reveal-id="view-map-edit-widget" title="Click to add location markers" class="tiny secondary button expand"> <i class="fi-marker"></i> &nbsp; {% trans "Add Location" %}
</a>
</div>
<!--
<div class="large-4 columns">
<b>Set Privacy</b><br/>
<input id="PUBLIC" name="login-mode" value="PUBLIC" type="radio" checked>
<label for="PUBLIC" onclick="">{% trans "Public" %} <i class="fi-torsos-all"></i></label>
<input id="PRIVATE" name="login-mode" value="PRIVATE" type="radio">
<label for="PRIVATE" onclick="">{% trans "Private" %} <i class="fi-lock"></i></label>
</div>
</div> -->
<input id="PUBLIC" name="login-mode" value="PUBLIC" type="hidden" >
</div>
<br/>
<div class ="row">
......@@ -171,6 +174,7 @@
{% for opts in v %}
<option>{% trans opts %}</option>
{% endfor %}
<option>Not Sure</option>
</select>
<small class="error">Please select resource Subject</small>
......@@ -188,6 +192,7 @@
{% for opts in v %}
<option>{% trans opts %}</option>
{% endfor %}
<option>Not Sure</option>
</select>
<small class="error">Please select resource audience</small>
......@@ -221,7 +226,7 @@
<b>Source</b>
</div>
<div class="large-10 columns">
<input id="source_id" name="Source" type="text" placeholder="Enter source name" tabindex="8"/>
<input id="source_id" name="Source" type="text" placeholder="Owner of the file" tabindex="8"/>
</div>
</div>
......@@ -230,7 +235,7 @@
<b>Based on url</b>
</div>
<div class="large-9 columns">
<input id="based_on_id" name="based_url" type="text" placeholder="Enter valid url" tabindex="9"/>
<input id="based_on_id" name="based_url" type="text" placeholder="Web Address (url) of the file if you sourced it from a website" tabindex="9"/>
</div>
</div>
......
......@@ -6,10 +6,23 @@
{% block meta_content %}
<!-- This content displayed into the left panel to display the info/hrlp document -->
<h3>{% trans "Uploader Form" %}</h3>
<p class="text-justify subheader">
{% trans "You can upload <b>files</b> of any format to your group library." %}
</p>
<h3>{% trans "Contribute File" %}</h3>
<ul class="text-justify subheader">
<li>
{% trans "You can contribute only Open Educational Resources" %}
({% trans "Copyrighted material cannot be contributed" %})
</li>
<li>
{% trans "You can upload files of any format" %}
</li>
<li>
{% trans "All files get uploaded under the CC-BY-SA licence (This license lets others remix, tweak, and build upon your work even for commercial purposes, as long as they credit you and license their new creations under the identical terms) unless you chose a different licence" %}
</li>
<li>
{% trans "Please visit" %} https://creativecommons.org/licenses/ {% trans "and" %} http://www.gnu.org/licenses/fdl-1.3.en.html {% trans "to learn more about licenses" %}
</li>
</ul>
{% endblock %}
......
......@@ -301,6 +301,18 @@ this template is modified. So for the fields in the template it supports -
<br/>
{% all_gapps as all_gapps %}
{% get_group_gapps node.pk|default:None as group_gapps %}
<div class="row">
<div class="small-12 medium-6 medium-centered columns">
<label>Select Apps:</label>
{% include 'ndf/widget_selector.html' with for='gapps' all_options=all_gapps selected_options=group_gapps %}
</div>
</div>
<div class="row">
<div class="small-12 medium-6 medium-centered columns">
{% if node %}
......@@ -365,7 +377,11 @@ this template is modified. So for the fields in the template it supports -
$("#message").text("Group name cannot be empty.");
event.preventDefault();
}
getSelValuesHiddenElement('apps_to_set', 'create_group');
});
// </script>
{% endblock %}
......@@ -550,11 +550,11 @@
var c = this.getAttribute("data-filetype");
if(educationaluse_stats.hasOwnProperty(c)){
$(this).find("a > span.count:visible").fadeOut().fadeIn().text(educationaluse_stats[c]);
$(this).find("a > span.count:visible").text(educationaluse_stats[c]);
}
else
{
$(this).find("a > span.count:visible").fadeOut().fadeIn().text("0");
$(this).find("a > span.count:visible").text("0");
}
});
......
<style type="text/css">
.selector-widget{
margin-bottom: 2rem;
border: solid thin #efefef;
/*background-color: red;*/
}
#select-search-container{
width: 100%;
background-color: whitesmoke;
padding-right: 5px;
}
#select-search-container > i.fi-play{
position: absolute;
right: 12px;
transform: rotate(90deg);
color: gray;
}
#selected-items > .selection{
float: left;
margin: 0.25rem 0.5rem;
}
.selection > .item{
float: left;
font-size: larger;
padding-top: 2.5px;
}
i.remove-tag{
padding-left: 8px;
font-size: 1.1em;
cursor: pointer;
font-size: large;
}
#search-text{
min-height: 2em;
margin: auto 1em;
padding: 2px;
float: left;
color: gray;
}
#to-be-selected{
max-height: 10rem;
min-height: auto;
background-color: #efefef;
display: block;
overflow-x: hidden;
overflow-y: auto;
position: absolute;
width: 97%;
z-index: 1000;
box-shadow: 0 5px 5px 1px lightgray;
border: solid thin #efefef;
border-top: none;
}
#to-be-selected > .item{
cursor: pointer;
padding: 5px;
border-bottom: solid thin lightgray;
}
#to-be-selected > .item:hover{
background-color: lightgray;
}
.item-title{
text-transform: uppercase;
color: #020;
}
.item-description{
color: gray;
}
</style>
<div class="selector-widget" id="{{for}}-selector-widget">
<div class="row">
<div class="small-12 medium-12 columns">
<div id="select-search-container">
<i class="fi-play"></i>
<div id="selected-items"></div>
<div id="search-text" contenteditable>search</div>
</div>
</div>
</div>
<div class="row">
<div class="small-12 medium-12 medium-centered columns">
<div id="to-be-selected" class="hide">
{% for each_opt in all_options %}
<div class="item" data-title="{{each_opt.name}}" data-description="{{each_opt.content_org|default_if_none:''}}" title="{{each_opt.content_org|default_if_none:each_opt.name}}" data-value="{{each_opt.pk}}">
<div class="row">
<!-- <div class="small-1 columns text-center"> </div> -->
<div class="small-12 columns">
<div class="item-title">
{{each_opt.name}}
</div>
<div class="item-description">
{{each_opt.content_org|default_if_none:''|safe|truncatechars:50}}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<script type="text/javascript">
selected_options = [ {% for each_opt in selected_options %}"{{each_opt.pk|safe}}"{% if not forloop.last %},{% endif %}{% endfor %} ];
// console.log(selected_options)
// querySelector, jQuery style
var $s = function (selector) {
return document.querySelector(selector);
};
var $sa = function (selector) {
return document.querySelectorAll(selector);
};
toBeSelected = document.getElementById('to-be-selected');
selectedItems = document.getElementById('selected-items');
searchText = document.getElementById('search-text');
selectorWidget = $s('.selector-widget');
sItems = $sa("#to-be-selected .item");
function removeTag(){
tempItem = this.parentNode.querySelector('.item');
tempItem.style.textDecoration = '';
tempItem.onclick = addToSelection;
tempItem.querySelector('.item-description').classList.remove('hide');
toBeSelected.appendChild(tempItem);
this.parentNode.onclick = detachEvent
this.parentNode.remove();
toBeSelected.classList.remove('hide');
}
function lineThrough(){
this.previousSibling.style.textDecoration = 'line-through';
}
function removeLineThrough(){
this.previousSibling.style.textDecoration = ''
}
function detachEvent() { return false; }
function addToSelection () {
// console.log(this.textContent);
this.onclick = detachEvent;
this.querySelector('.item-description').classList.add('hide');
selDiv = document.createElement('div');
selDiv.classList.add('label', 'secondary', 'selection');
var closeBtn = document.createElement("i");
closeBtn.className = "fi-x-circle remove-tag";
closeBtn.title = "Remove";
closeBtn.onclick = removeTag;
closeBtn.onmouseenter = lineThrough;
closeBtn.onmouseleave = removeLineThrough;
selDiv.appendChild(this);
selDiv.appendChild(closeBtn);
selectedItems.appendChild(selDiv);
selDiv.onclick = function(){selectedItems.insertBefore(this, this.previousSibling );}
}
for (var i = sItems.length - 1; i >= 0; i--) {
sItems[i].onclick = addToSelection;
// console.log(sItems[i].getAttribute('data-value'))
}
for (var i = 0; i < selected_options.length; i++) {
temp_item = toBeSelected.querySelector('.item[data-value="'+ selected_options[i] +'"]');
if(temp_item){temp_item.click()};
};
function searchOnItems (){
// console.log(this.textContent)
var toBeSearch = this.textContent.trim().toLowerCase();
sItemsTemp = $sa("#to-be-selected .item");
for (var i = sItemsTemp.length - 1; i >= 0; i--) {
// sItemsTemp[i].style.display = (sItemsTemp[i].textContent.indexOf(toBeSearch)>=0)? 'block': 'none';
sItemsTemp[i].style.display = (sItemsTemp[i].getAttribute('data-title').toLowerCase().indexOf(toBeSearch)>=0)? 'block': 'none';
};
}
searchText.oninput = searchOnItems;
function showOptionItems () {
toBeSelected.classList.remove('hide');
// searchText.textContent = '';
if(!searchText.textContent || searchText.textContent=='search'){
searchText.textContent = '';
}
}
function hideOptionItems () {
// toBeSelected.style.display = 'none';
if(!searchText.textContent || searchText.textContent=='search'){
searchText.textContent = 'search';
}
}
searchText.onfocus = showOptionItems;
searchText.onblur = hideOptionItems;
function getSelectedValues ({{for}}) {
selected = selectedItems.querySelectorAll('.selection .item');
selectedValuesList = [];
for (var i = 0; i < selected.length; i++) {
selectedValuesList.push( selected[i].getAttribute('data-value') );
}
// console.log(selectedValuesList);
return selectedValuesList
}
function getSelValuesHiddenElement (name, idToAppend){
idToAppend = idToAppend || false;
var hiddenInput = document.createElement('input');
hiddenInput.type = 'hidden';
hiddenInput.name = name;
hiddenInput.value = JSON.stringify(getSelectedValues());
if (idToAppend) {
document.getElementById(idToAppend).appendChild(hiddenInput);
}
return hiddenInput;
}
document.querySelector('html').onclick = function (e) {
// aaa = e;
p = $(e.target).closest('.selector-widget');
// console.log(p);
if (p.hasClass('selector-widget')) {
document.getElementById('to-be-selected').classList.remove('hide');
// console.log(e);
} else {
document.getElementById('to-be-selected').classList.add('hide');
}
};
</script>
......@@ -278,6 +278,24 @@ def all_gapps():
print "Error in get_gapps "+str(expt)
@get_execution_time
@register.assignment_tag
def get_group_gapps(group_id=None):
group_obj = node_collection.one({"_id": ObjectId(group_id) }, { "name": 1, "attribute_set.apps_list": 1, '_type': 1 })
if group_obj:
group_name = group_obj.name
for attr in group_obj.attribute_set:
if attr and "apps_list" in attr:
gapps_list = attr["apps_list"]
all_gapp_ids_list = [node_collection.one({'_id':ObjectId(g['_id'])}) for g in gapps_list]
return all_gapp_ids_list
return []
@get_execution_time
@register.assignment_tag
def get_create_group_visibility():
......@@ -655,6 +673,7 @@ def get_gapps_iconbar(request, group_id):
for attr in group_obj.attribute_set:
if attr and "apps_list" in attr:
gapps_list = attr["apps_list"]
break
if not gapps_list:
# If gapps not found for group, then make use of default apps list
......
......@@ -741,10 +741,13 @@ def submitDoc(request, group_id):
source = request.POST.get("Source", "")
Audience = request.POST.get("audience", "")
fileType = request.POST.get("FileType", "")
subject = request.POST.get("Subject", "")
level = request.POST.get("Level", "")
Based_url = request.POST.get("based_url", "")
map_geojson_data = request.POST.get('map-geojson-data')
subject = request.POST.get("Subject", "")
level = request.POST.get("Level", "")
subject = '' if (subject=='Not Sure') else subject
level = '' if (level=='Not Sure') else level
if map_geojson_data:
map_geojson_data = map_geojson_data + ","
......@@ -761,11 +764,11 @@ def submitDoc(request, group_id):
if index == 0:
# f, is_video = save_file(each, mtitle, userid, group_id, content_org, tags, img_type, language, usrname, access_policy, oid=True)
f, is_video = save_file(each, mtitle, userid, group_id, content_org, tags, img_type, language, usrname, access_policy, license, source, Audience, fileType, subject, level, Based_url, request, map_geojson_data, oid=True)
f, is_video = save_file(each, mtitle, userid, group_id, content_org, tags, img_type, language, usrname, access_policy, license, source, Audience, fileType, subject, level, Based_url, request, map_geojson_data)
else:
title = mtitle + "_" + str(i) # increament title
f, is_video = save_file(each, title, userid, group_id, content_org, tags, img_type, language, usrname, access_policy, license, source, Audience, fileType, subject, level, Based_url, request, map_geojson_data, oid=True)
f, is_video = save_file(each, title, userid, group_id, content_org, tags, img_type, language, usrname, access_policy, license, source, Audience, fileType, subject, level, Based_url, request, map_geojson_data)
i = i + 1
else:
title = each.name
......@@ -775,15 +778,24 @@ def submitDoc(request, group_id):
# if not obj_id_instance.is_valid(f):
# check if file is already uploaded file
# if isinstance(f, list):
f = save_file(each,title,userid,group_id, content_org, tags, img_type, language, usrname, access_policy, license, source, Audience, fileType, subject, level, Based_url, request, map_geojson_data, oid=True)
f, is_video = save_file(each,title,userid,group_id, content_org, tags, img_type, language, usrname, access_policy, license, source, Audience, fileType, subject, level, Based_url, request, map_geojson_data)
if isinstance(f, list):
alreadyUploadedFiles_append_temp(f)
title = mtitle
# print "=============== : ", f
try:
ObjectId(f)
except:
if isinstance(f, list):
# alreadyUploadedFiles_append_temp(f)
alreadyUploadedFiles = f
title = mtitle
# str1 = alreadyUploadedFiles
# print "=============== : ", alreadyUploadedFiles
if img_type != "":
# print "----------1-----------"
return HttpResponseRedirect(reverse('dashboard', kwargs={'group_id': int(userid)}))
......@@ -796,8 +808,8 @@ def submitDoc(request, group_id):
if alreadyUploadedFiles:
# return HttpResponseRedirect(page_url+'?var='+str1)
# if (type(alreadyUploadedFiles[0][0]).__name__ == "ObjectId"):
# print "----------3-----------", alreadyUploadedFiles[0][1]
return HttpResponseRedirect(reverse("file_detail", kwargs={'group_id': group_id, "_id": alreadyUploadedFiles[0][1].__str__() }))
# print "----------3-----------", alreadyUploadedFiles
return HttpResponseRedirect(reverse("file_detail", kwargs={'group_id': group_id, "_id": alreadyUploadedFiles[1].__str__() }))
# else:
# if alreadyUploadedFiles[0][1]:
# return HttpResponseRedirect(reverse("file_detail", kwargs={'group_id': group_id, "_id": alreadyUploadedFiles[0][0].__str__() }))
......@@ -814,8 +826,9 @@ def submitDoc(request, group_id):
t = create_moderator_task(request, fileobj.group_set[0], fileobj._id,on_upload=True)
return HttpResponseRedirect(reverse('moderation_status', kwargs={'group_id': fileobj.group_set[1], 'node_id': f }))
else:
# print "----------5-----------"
return HttpResponseRedirect(reverse('file', kwargs={'group_id': group_id }))
# print "----------5-----------", f
return HttpResponseRedirect(reverse("file_detail", kwargs={'group_id': group_id, "_id": ObjectId(f) }))
# if is_video == "True":
# return HttpResponseRedirect(page_url+'?'+'is_video='+is_video)
......
......@@ -1300,6 +1300,9 @@ class GroupCreateEditHandler(View):
group_name = group_obj.name
url_name = 'groupchange'
# print request.POST.get('apps_to_set', '')
app_selection(request, group_obj._id)
else:
# operation fail: redirect to group-listing
group_name = 'home'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment