diff options
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/edit_group.html | 157 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/groupdashboard.html | 28 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_details_base.html | 10 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/urls/__init__.py | 2 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/urls/ajax-urls.py | 3 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/urls/group.py | 1 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/views/ajax-views.py | 34 | ||||
-rw-r--r-- | gnowsys-ndf/gnowsys_ndf/ndf/views/group.py | 19 |
8 files changed, 229 insertions, 25 deletions
diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/edit_group.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/edit_group.html new file mode 100644 index 00000000..3407178c --- /dev/null +++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/edit_group.html @@ -0,0 +1,157 @@ +{% extends "ndf/node_edit_base.html" %} + +{% load ndf_tags %} + +{% block title %} {{node.name}} - edit {% endblock %} + +{% get_user_object node.created_by as user_obj %} + +{% block body_content %} +{% get_user_object node.created_by as user_obj %} +{% ifequal user_obj.username user.username %} +<dl class="accordion" data-accordion> +<dd> +<a href="#change_settings">Click here change {{node.name}}'s settings </a> +<div id="change_settings" class="content"> + <div style='display:table; border:1px; border-spacing:10px; '> + <div style='display:table-row;' > + <div style='display:table-cell;'> + <font size="3" >Group Type</font> + </div> + <div style='display:table-cell;'> + <select name="group_type" id="group_type"> + <option id="PUBLIC">PUBLIC</option> + <option id="PRIVATE">PRIVATE</option> + <option id="ANONYMOUS">ANONYMOUS</option> + </select> + </div> + <div style='display:table-cell;'> + <font size="3" >Group Editing policy</font> + </div> + <div style='display:table-cell;'> + <select name="edit_policy" id="edit_policy"> + <option id="EDITABLE_NON_MODERATED">EDITABLE_NON_MODERATED</option> + <option id="EDITABLE_MODERATED">EDITABLE_MODERATED</option> + <option id="NON_EDITABLE">NON_EDITABLE</option> + </select> + </div> + + </div> + + <div style='display:table-row;'> + <div style='display:table-cell;'> + <font size="3" >Group Subscription policy</font> + </div> + <div style='display:table-cell;'> + <select name="subscription_policy" id="subscription_policy"> + <option id="OPEN">OPEN</option> + <option id="BY_REQUEST">BY_REQUEST</option> + <option id="BY_INVITATION">BY_INVITATION</option> + </select> + </div> + <div style='display:table-cell;'> + <font size="3" >Group Existance visibility</font> + </div> + <div style='display:table-cell;'> + <select name="visibility_policy" id="visibility_policy"> + <option id="ANNOUNCED">ANNOUNCED</option> + <option id="NOT_ANNOUNCED">NOT_ANNOUNCED</option> + </select> + </div> + + </div> + + <div style='display:table-row;'> + <div style='display:table-cell;'> + <font size="3"> Group Member Visibility</font> + </div> + <div style='display:table-cell;'> + <select name="disclosure_policy" id="disclosure_policy"> + <option id="DISCLOSED_TO_MEM">DISCLOSED_TO_MEM</option> + <option id="NOT_DISCLOSED_TO_MEM">NOT_DISCLOSED_TO_MEM</option> + </select> + </div> + <div style='display:table-cell;'> + <font size="3" >Group Encryption policy</font> + </div> + <div style='display:table-cell;'> + <select name="encryption_policy" id="encryption_policy"> + <option id="NOT_ENCRYPTED">NOT_ENCRYPTED</option> + <option id="ENCRYPTED">ENCRYPTED</option> + </select> + </div> + </div> + + <div style='display:table-row;'> + + </div> + <div style='display:table-row;'> + <div style='display:table-cell;' colspan='2' align="middle"> + <input type="button" id="changeButton" value="Change" > + <img id="ajax_search" width="50" style="display: none;" src="/static/ndf/images/ajax-wait.gif"> + <font id="status"></font> + </div> + </div> +</div> +</div> +</form> +</div> +</dd> +</dl> +{{ block.super }} +{% else %} +<b>you are not allowed to change group</b> +{% endifequal %} +{% endblock %} + + + +{% block script %} +{% get_user_object node.created_by as user_obj %} +{% ifequal user_obj.username user.username %} +var edit_policy = document.getElementById("edit_policy") +var group_type = document.getElementById("group_type") +var subscription_policy = document.getElementById("subscription_policy") +var visibility_policy = document.getElementById("visibility_policy") +var disclosure_policy = document.getElementById("disclosure_policy") +var encryption_policy = document.getElementById("encryption_policy") +{% if node.edit_policy %} +edit_policy.selectedIndex = edit_policy.options.{{node.edit_policy}}.index +{% endif %} +{% if node.group_type %} +group_type.selectedIndex = group_type.options.{{node.group_type}}.index +{% endif %} +{% if node.subscription_policy %} +subscription_policy.selectedIndex = subscription_policy.options.{{node.subscription_policy}}.index +{% endif %} +{% if node.visibility_policy %} +visibility_policy.selectedIndex = visibility_policy.options.{{node.visibility_policy}}.index +{% endif %} +{% if node.disclosure_policy %} +disclosure_policy.selectedIndex = disclosure_policy.options.{{node.disclosure_policy}}.index +{% endif %} +{% if node.encryption_policy %} +encryption_policy.selectedIndex = encryption_policy.options.{{node.encryption_policy}}.index +{% endif %} + + +$(document).on('click',"#changeButton",function(){ + + $.ajax({ + url:'/{{node.altnames}}/ajax/change_group_settings/', + type: 'POST', + data: {edit_policy:edit_policy.value, group_type:group_type.value, subscription_policy:subscription_policy.value, visibility_policy:visibility_policy.value, disclosure_policy:disclosure_policy.value, encryption_policy:encryption_policy.value, csrfmiddlewaretoken: '{{ csrf_token }}', group_id:"{{node}}"}, + beforeSend: function() { + $("#ajax_search").show(); + }, + success: function(result){ + $("#ajax_search").hide(); + $("#status").html(result); + } + }); +}); + +{% else %} +{% endifequal %} +{% endblock %} + diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/groupdashboard.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/groupdashboard.html index 4b973aef..b2bf8935 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/groupdashboard.html +++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/groupdashboard.html @@ -1,4 +1,4 @@ -{% extends "ndf/base.html" %} +{% extends "ndf/node_details_base.html" %} {% load ndf_tags %} {% block title %} Group Dashboard {% endblock %} {% block head %} @@ -59,23 +59,17 @@ notify(groupn,"remove") </script> {% endblock %} - +{% block url %} +{% get_user_object node.created_by as user_obj %} +{% ifequal user_obj.username user.username %} +{% url 'edit_group' groupobj.altnames groupobj %} +{% else %} +# +{% endifequal %} +{% endblock %} {% block body_content %} {% get_group_name request.path as group %} -{% if group != "home" %} -<p> -<font size="4px" color="#BAC1C8"> -{{groupobj.altnames}} -</font> -</p> -{% else %} -<p> -<font size="4px" color="#BAC1C8"> -home -</font> -</p> -{% endif %} -<font size="2px" color="black"> Members in this group : 0 </font> +<font size="3" color="black"> Members in this group : 0 </font> {% get_group_policy group request.user as policy %} @@ -114,6 +108,6 @@ home </div> </div> - +{{ block.super }} {% endblock %} diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_details_base.html b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_details_base.html index 7067dc0c..875132c6 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_details_base.html +++ b/gnowsys-ndf/gnowsys_ndf/ndf/templates/ndf/node_details_base.html @@ -42,11 +42,11 @@ <tr> <td> <pre> - Posted by : {{ node.user_details_dict.created_by }} on {{ node.created_at|date:"j F Y" }} - Member of : {{ node.member_of|join:', ' }} - Contributors : {{ node.user_details_dict.modified_by|join:', ' }} - Last update : {{ node.last_update|date:"j F Y" }} - Versions : {% for seq_no, version_no in node.version_dict.items reversed %}<abbr title={{version_no}}><a href="{% url 'node_version' group_name node.pk version_no %}">*</a></abbr> {% endfor %}</pre> + Posted by: {{ node.user_details_dict.created_by }} on {{ node.created_at|date:"j F Y" }} + Member of: {{ node.member_of|join:', ' }} + Contributors: {{ node.user_details_dict.modified_by|join:', ' }} + Last update: {{ node.last_update|date:"j F Y" }} + Versions: {% for seq_no, version_no in node.version_dict.items reversed %}<abbr title={{version_no}}><a href="{% url 'node_version' group_name node.pk version_no %}">*</a></abbr> {% endfor %}</pre> </td> </tr> </table> diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/urls/__init__.py b/gnowsys-ndf/gnowsys_ndf/ndf/urls/__init__.py index 75ca5bc0..a2093a44 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/urls/__init__.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/urls/__init__.py @@ -20,7 +20,7 @@ urlpatterns = patterns('', (r'^(?P<group_name>[\w-]+)/forum/', include('gnowsys_ndf.ndf.urls.forum')), (r'^(?P<group_name>[\w-]+)/ajax/', include('gnowsys_ndf.ndf.urls.ajax-urls')), (r'^(?P<group_name>[\w-]+)/',include('gnowsys_ndf.ndf.urls.group')), - (r'^home/', 'gnowsys_ndf.ndf.views.home.homepage'), + # (r'^home/', 'gnowsys_ndf.ndf.views.home.homepage'), (r'^benchmarker/', include('gnowsys_ndf.benchmarker.urls')), (r'^admin/', include(admin.site.urls)), url(r'^accounts/password/change/done/', auth_views.password_change_done, name='password_change_done'), diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/urls/ajax-urls.py b/gnowsys-ndf/gnowsys_ndf/ndf/urls/ajax-urls.py index 4a361106..01cd0bfa 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/urls/ajax-urls.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/urls/ajax-urls.py @@ -7,5 +7,6 @@ from gnowsys_ndf.ndf.views import * urlpatterns = patterns('gnowsys_ndf.ndf.views.ajax-views', - url(r'^collection/', 'select_drawer', name='select_drawer'), + url(r'^collection/', 'select_drawer', name='select_drawer'), + url(r'^change_group_settings/', 'change_group_settings', name='change_group_settings'), ) diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/urls/group.py b/gnowsys-ndf/gnowsys_ndf/ndf/urls/group.py index 16d71dcb..13bc6569 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/urls/group.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/urls/group.py @@ -8,6 +8,7 @@ urlpatterns = patterns('gnowsys_ndf.ndf.views.group', url(r'^$','group_dashboard', name='groupchange'), url(r'^(?P<app_id>[\w-]+)$', 'group', name='group'), url(r'^create_group/', 'create_group', name='create_group'), + url(r'^(?P<group_id>[\w-]+)/edit_group/', 'edit_group', name='edit_group'), ) urlpatterns += patterns('gnowsys_ndf.ndf.views.ajax-views', url(r'^check_group/', 'checkgroup', name='check_group'), diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/views/ajax-views.py b/gnowsys-ndf/gnowsys_ndf/ndf/views/ajax-views.py index b4861e0b..5ad7d207 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/views/ajax-views.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/views/ajax-views.py @@ -10,6 +10,7 @@ from django.core.urlresolvers import reverse from django.shortcuts import render_to_response from django.template import RequestContext from django.template.defaultfilters import slugify +from django.contrib.auth.decorators import login_required from django_mongokit import get_database @@ -78,3 +79,36 @@ def select_drawer(request, group_name): }, context_instance=RequestContext(request) ) + +@login_required +def change_group_settings(request, group_name): + ''' + changing group's object data + ''' + if request.is_ajax() and request.method =="POST": + try: + edit_policy = request.POST['edit_policy'] + group_type = request.POST['group_type'] + subscription_policy = request.POST['subscription_policy'] + visibility_policy = request.POST['visibility_policy'] + disclosure_policy = request.POST['disclosure_policy'] + encryption_policy = request.POST['encryption_policy'] + group_id = request.POST['group_id'] + group_node = gs_collection.GSystem.one({"_id": ObjectId(group_id)}) + if group_node : + group_node.edit_policy = edit_policy + group_node.group_type = group_type + group_node.subscription_policy = subscription_policy + group_node.visibility_policy = visibility_policy + group_node.disclosure_policy = disclosure_policy + group_node.encryption_policy = encryption_policy + group_node.save() + return HttpResponse("changed successfully") + except: + return HttpResponse("failed") + return HttpResponse("failed") + + + + + diff --git a/gnowsys-ndf/gnowsys_ndf/ndf/views/group.py b/gnowsys-ndf/gnowsys_ndf/ndf/views/group.py index b3d07bb5..730dee10 100644 --- a/gnowsys-ndf/gnowsys_ndf/ndf/views/group.py +++ b/gnowsys-ndf/gnowsys_ndf/ndf/views/group.py @@ -25,6 +25,7 @@ from gnowsys_ndf.ndf.models import GSystemType, GSystem from gnowsys_ndf.ndf.models import Group from gnowsys_ndf.ndf.templatetags.ndf_tags import get_existing_groups +from gnowsys_ndf.ndf.views.methods import * ####################################################################################################################################### @@ -76,5 +77,21 @@ def group_dashboard(request,group_name): except: groupobj="" pass - return render_to_response("ndf/groupdashboard.html",{'groupobj':groupobj},context_instance=RequestContext(request)) + return render_to_response("ndf/groupdashboard.html",{'groupobj':groupobj,'node':groupobj},context_instance=RequestContext(request)) + +def edit_group(request,group_name,group_id): + page_node = gs_collection.GSystem.one({"_id": ObjectId(group_id)}) + if request.method == "POST": + get_node_common_fields(request, page_node, group_name, gst_group) + page_node.save() + return HttpResponseRedirect(reverse('groupchange', kwargs={'group_name': group_name})) + + return render_to_response("ndf/edit_group.html", + { 'node': page_node, + 'group_name': group_name + }, + context_instance=RequestContext(request) + ) + + |