From a97d8967426bda55381e0f235b26e51777228f5a Mon Sep 17 00:00:00 2001 From: supriya Date: Tue, 7 Aug 2012 11:41:01 +0530 Subject: Wikipage added to gstudio --- gstudio/methods.py | 172 ++++++++++++++- gstudio/static/gstudio/js/addcontent.js | 232 +++++++++++++++++++++ gstudio/templates/gstudio/NewPage.html | 30 +++ gstudio/templates/gstudio/NewSection1.html | 26 +++ gstudio/templates/gstudio/_header.html | 1 + gstudio/templates/gstudio/nodetype_detail.html | 8 +- gstudio/templates/gstudio/skeleton.html | 33 ++- gstudio/templates/gstudio/tags/commentpage.html | 75 +++++++ gstudio/templates/metadashboard/pgedashboard.html | 178 ++++++++++++++++ gstudio/templates/metadashboard/wikidashboard.html | 24 +++ gstudio/templatetags/gstudio_tags.py | 4 + gstudio/urls/__init__.py | 4 + gstudio/urls/page.py | 27 +++ gstudio/urls/pageadd.py | 20 ++ gstudio/urls/sectionadd1.py | 9 + gstudio/urls/user.py | 5 +- gstudio/views/page.py | 79 +++++++ gstudio/views/pageadd.py | 41 ++++ gstudio/views/sectionadd1.py | 36 ++++ gstudio/views/user.py | 11 + gstudio/views/wikidashboard.py | 61 ++++++ 21 files changed, 1062 insertions(+), 14 deletions(-) create mode 100644 gstudio/static/gstudio/js/addcontent.js create mode 100644 gstudio/templates/gstudio/NewPage.html create mode 100644 gstudio/templates/gstudio/NewSection1.html create mode 100644 gstudio/templates/gstudio/tags/commentpage.html create mode 100644 gstudio/templates/metadashboard/pgedashboard.html create mode 100644 gstudio/templates/metadashboard/wikidashboard.html create mode 100644 gstudio/urls/page.py create mode 100644 gstudio/urls/pageadd.py create mode 100644 gstudio/urls/sectionadd1.py create mode 100644 gstudio/views/page.py create mode 100644 gstudio/views/pageadd.py create mode 100644 gstudio/views/sectionadd1.py create mode 100644 gstudio/views/wikidashboard.py (limited to 'gstudio') diff --git a/gstudio/methods.py b/gstudio/methods.py index 38ceb196..70407168 100644 --- a/gstudio/methods.py +++ b/gstudio/methods.py @@ -2,6 +2,9 @@ from gstudio.models import * from objectapp.models import * from django.template.defaultfilters import slugify import datetime +import os +from demo.settings import PYSCRIPT_URL_GSTUDIO + def delete(idnum): del_ob = Gbobject.objects.get(id=idnum) @@ -32,6 +35,72 @@ def make_topic_object(title,auth_id,content): new_ob.sites.add(Site.objects.get_current()) return new_ob +def make_sectionreply_object(content_org,title,auth_id): + new_ob = Gbobject() + new_ob.title = title + new_ob.status = 2 + new_ob.slug = slugify(title) + new_ob.content_org = content_org + myfile = open('/tmp/file.org', 'w') + myfile.write(new_ob.content_org) + myfile.close() + myfile = open('/tmp/file.org', 'r') + myfile.readline() + myfile = open('/tmp/file.org', 'a') + myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") + myfile.write("\n#+TITLE: ") + myfile = open('/tmp/file.org', 'r') + stdout = os.popen(PYSCRIPT_URL_GSTUDIO) + output = stdout.read() + data = open("/tmp/file.html") + data1 = data.readlines() + data2 = data1[67:] + newdata="" + for line in data2: + newdata += line.lstrip() + new_ob.content = newdata + myfile = open('/tmp/file.org', 'w') + # myfile.write(new_ob.content_org) + # myfile.close() + new_ob.save() + new_ob.objecttypes.add(Objecttype.objects.get(title="Subsection")) + new_ob.authors.add(Author.objects.get(id=auth_id)) + new_ob.sites.add(Site.objects.get_current()) + return new_ob + + +def make_section_object(title,auth_id,content_org): + new_ob = Gbobject() + new_ob.title = title + new_ob.status = 2 + new_ob.slug = slugify(title) + #new_ob.content = content + new_ob.content_org = content_org + myfile = open('/tmp/file.org', 'w') + myfile.write(new_ob.content_org) + myfile.close() + myfile = open('/tmp/file.org', 'r') + myfile.readline() + myfile = open('/tmp/file.org', 'a') + myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") + myfile.write("\n#+TITLE: ") + myfile = open('/tmp/file.org', 'r') + stdout = os.popen(PYSCRIPT_URL_GSTUDIO) + output = stdout.read() + data = open("/tmp/file.html") + data1 = data.readlines() + data2 = data1[67:] + newdata="" + for line in data2: + newdata += line.lstrip() + new_ob.content = newdata + new_ob.save() + new_ob.objecttypes.add(Objecttype.objects.get(title="Section")) + new_ob.authors.add(Author.objects.get(id=auth_id)) + new_ob.sites.add(Site.objects.get_current()) + return new_ob + + def make_relation(rep,id_no,idusr): r = make_rep_object(rep,idusr) t = Gbobject.objects.get(id=id_no) @@ -39,11 +108,25 @@ def make_relation(rep,id_no,idusr): r.prior_nodes.add(t) return True +def make_sectionrelation(rep,ptitle,id_no,idusr): + r = make_sectionreply_object(rep,ptitle,idusr) + t = Gbobject.objects.get(id=id_no) + t.posterior_nodes.add(r) + r.prior_nodes.add(t) + return True + + def rate_it(topic_id,request,rating): ob = Gbobject.objects.get(id=topic_id) ob.rating.add(score=rating ,user=request.user, ip_address=request.META['REMOTE_ADDR']) return True +def rate_section(section_id,request,rating): + ob = Gbobject.objects.get(id=section_id) + ob.rating.add(score=rating ,user=request.user, ip_address=request.META['REMOTE_ADDR']) + return True + + def create_meeting(title,idusr,content): sys = System() @@ -76,12 +159,63 @@ def create_meeting(title,idusr,content): sys.sites.add(Site.objects.get_current()) sys1.sites.add(Site.objects.get_current()) return sys.id + +def create_wikipage(title,idusr,content_org): + sys = System() + sys.title = title + sys.status = 2 + sys.content_org= content_org + myfile = open('/tmp/file.org', 'w') + myfile.write(sys.content_org) + myfile.close() + myfile = open('/tmp/file.org', 'r') + myfile.readline() + myfile = open('/tmp/file.org', 'a') + myfile.write("\n#+OPTIONS: timestamp:nil author:nil creator:nil H:3 num:nil toc:nil @:t ::t |:t ^:t -:t f:t *:t <:t") + myfile.write("\n#+TITLE: ") + myfile = open('/tmp/file.org', 'r') + stdout = os.popen(PYSCRIPT_URL_GSTUDIO) + output = stdout.read() + data = open("/tmp/file.html") + data1 = data.readlines() + data2 = data1[67:] + newdata="" + for line in data2: + newdata += line.lstrip() + sys.content = newdata + sys.slug = slugify(title) + sys.save() + sys.systemtypes.add(Systemtype.objects.get(title="Wikipage")) + sys.authors.add(Author.objects.get(id=idusr)) + + a = Attribute() + a.title = "released button of " + title + a.slug = slugify(a.title) + a.content = a.slug + a.status = 2 + a.subject = sys + a.svalue = "False" + a.attributetype_id = Attributetype.objects.get(title="pagerelease").id + a.save() + sys1 = System() + sys1.title = "page box of " + title + sys1.status = 2 + sys1.content = "contains pages of " + title + sys1.slug = slugify(title) + sys1.save() + sys1.systemtypes.add(Systemtype.objects.get(title="page_box")) + sys.system_set.add(sys1) + sys.member_set.add(Author.objects.get(id=idusr)) + sys.sites.add(Site.objects.get_current()) + sys1.sites.add(Site.objects.get_current()) + return sys.id + def make_att_true(meet_ob): - for each in meet_ob.subject_of.all(): - if(each.attributetype.title=='release'): - each.svalue = "true" - meet_ob.subject_of.add(each) - break + for each in meet_ob.subject_of.all(): + if(each.attributetype.title=='release'): + each.svalue = "true" + meet_ob.subject_of.add(each) + break def make_att_false(meet_ob): for each in meet_ob.subject_of.all(): @@ -89,6 +223,21 @@ def make_att_false(meet_ob): each.svalue = "" meet_ob.subject_of.add(each) break + +def make_att1_true(page_ob): + for each in page_ob.subject_of.all(): + if(each.attributetype.title=='pagerelease'): + each.svalue = "true" + page_ob.subject_of.add(each) + break + +def make_att1_false(page_ob): + for each in page_ob.subject_of.all(): + if(each.attributetype.title=='pagerelease'): + each.svalue = "" + page_ob.subject_of.add(each) + break + def schedule_time(stTime, endTime, sys_id): sys=System.objects.get(id=sys_id) atty1=Attributetype.objects.get(title='timeofstart') @@ -103,6 +252,12 @@ def schedule_time(stTime, endTime, sys_id): ats.save() sys.save() return sys.id + + +def make_title(id_no): + i = Gbobject.objects.get(id=id_no) + return "Subsection of:"+i.title + def get_time(sys_id): later = False meetover = False @@ -137,3 +292,10 @@ def del_topic(topic_id): del_comment(each.id) ob.delete() return True + +def del_section(section_id): + ob = Gbobject.objects.get(id=int(section_id)) + for each in ob.posterior_nodes.all(): + del_comment(each.id) + ob.delete() + return True diff --git a/gstudio/static/gstudio/js/addcontent.js b/gstudio/static/gstudio/js/addcontent.js new file mode 100644 index 00000000..9581aeb6 --- /dev/null +++ b/gstudio/static/gstudio/js/addcontent.js @@ -0,0 +1,232 @@ + $.noConflict(); + + jQuery(document).ready(function($) { + $("#addcontent").one("click",function(){ + //var abc = document.getElementById('pageid1').value; + //window.location.replace('sectionadd1/'+abc); + $("#chart").hide(); + // var orgdata = document.getElementById('orgcontent').value; + document.getElementById('gnoweditor').style.visibility="visible"; + + $("#gnoweditor").orgitdown(mySettings); + + var orgtext = $("#gnoweditor").val(); + + // }); + // }); + }); + $("#save").one("click",function() { + var org_data = $("#gnoweditor").val(); + document.getElementById("orgpage").value = org_data; + var encode_data = encodeURIComponent(org_data); + }); + + $("#pagecontent1").one("click",function() { + $("#chart").hide(); + document.getElementById('gnoweditor').style.visibility="visible"; + $("#gnoweditor").orgitdown(mySettings); + }); + $("#save").one("click",function() { + var org_data = $("#gnoweditor").val(); + document.getElementById("orgpage1").value = org_data; + var encode_data = encodeURIComponent(org_data); + }); + $("#editseccontent").one("click",function(){ + $("#chart").hide(); + document.getElementById('gnoweditor').style.visibility="visible"; + $("#gnoweditor").orgitdown(mySettings); + var a = document.getElementById('sectionorg').value; + $("#gnoweditor").val(a); + var screenTop = $(document).scrollTop(); + $(".orgitdownContainer").css({ + "margin-top":screenTop,}); + + }); + $("#saveseccontent").one("click",function(){ + var org_data = $("#gnoweditor").val(); + var id = document.getElementById("sectionid").value + document.getElementById("sectionorg").value = org_data; + var encode_data = encodeURIComponent(org_data); + + $.ajax({ + url: '/nodetypes/ajax/contentorgadd/?id=' + id + '&contentorg=' + encode_data, + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/ajaxcreatefile/?id=' +id+ '&content_org=' +encode_data, + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/ajaxcreatehtml/', + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/contentadd/?id=' +id, + success: function(data) { + //alert("Data Saved"); + location.reload();} + }); + } + }); + } + }); + + } + }); + + + + + + + }); + $("#editsubsec").one("click",function(){ + $("#chart").hide(); + document.getElementById('gnoweditor').style.visibility="visible"; + $("#gnoweditor").orgitdown(mySettings); + var a = document.getElementById('subsecorg').value; + $("#gnoweditor").val(a); + var screenTop = $(document).scrollTop(); + $(".orgitdownContainer").css({ + "margin-top":screenTop,}); + + }); + $("#savesubsec1").one("click",function(){ + var org_data = $("#gnoweditor").val(); + var id = document.getElementById("subsecid").value + document.getElementById("subsecorg").value = org_data; + var encode_data = encodeURIComponent(org_data); + + $.ajax({ + url: '/nodetypes/ajax/contentorgadd/?id=' + id + '&contentorg=' + encode_data, + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/ajaxcreatefile/?id=' +id+ '&content_org=' +encode_data, + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/ajaxcreatehtml/', + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/contentadd/?id=' +id, + success: function(data) { + //alert("Data Saved"); + location.reload();} + }); + } + }); + } + }); + + } + }); + + + + + + + }); + + $("#editpagecontent").one("click",function(){ + //var abc = document.getElementById('pageid1').value; + //window.location.replace('sectionadd1/'+abc); + $("#chart").hide(); + // var orgdata = document.getElementById('orgcontent').value; + document.getElementById('gnoweditor').style.visibility="visible"; + + $("#gnoweditor").orgitdown(mySettings); + + // var org_data = $("#gnoweditor").val(); + + var a = document.getElementById('pageorg').value; + $("#gnoweditor").val(a); + var screenTop = $(document).scrollTop(); + $(".orgitdownContainer").css({ + "margin-top":screenTop,}); + + + }); + $("#savepagecontent").one("click",function(){ + // var org = $("#gnoweditor").val(); + // $("#sectionorg").val(org); + // var test = $("#sectionorg").val(); + // alert(test); + var org_data = $("#gnoweditor").val(); + var id = document.getElementById("pageid").value + document.getElementById("pageorg").value = org_data; + var encode_data = encodeURIComponent(org_data); + //$("#gnoweditor").val(org_data); + + $.ajax({ + url: '/nodetypes/ajax/contentorgadd/?id=' + id + '&contentorg=' + encode_data, + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/ajaxcreatefile/?id=' +id+ '&content_org=' +encode_data, + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/ajaxcreatehtml/', + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/contentadd/?id=' +id, + success: function(data) { + //alert("Data Saved"); + location.reload();} + }); + } + }); + } + }); + + } + }); + + + }); + + + $("#createsubsection").one("click",function(){ + $("#chart").hide(); + document.getElementById('gnoweditor').style.visibility="visible"; + $("#gnoweditor").orgitdown(mySettings); + $("#gnoweditor").val(''); + var screenTop = $(document).scrollTop(); + $(".orgitdownContainer").css({ + "margin-top":screenTop,}); + }); + $("#savesubsec").one("click",function() { + var org_data = $("#gnoweditor").val(); + document.getElementById("sectionreply").value = org_data; + var encode_data = encodeURIComponent(org_data); + alert(org_data);}); + + $("#savecontent").one("click",function() { + var org_data = $("#gnoweditor").val(); + var id = document.getElementById("objectid").value + document.getElementById("orgcontent").value = org_data; + var encode_data = encodeURIComponent(org_data); + + $.ajax({ + url: '/nodetypes/ajax/contentorgadd/?id=' + id + '&contentorg=' + encode_data, + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/ajaxcreatefile/?id=' +id+ '&content_org=' +encode_data, + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/ajaxcreatehtml/', + success: function(data) { + $.ajax({ + url: '/nodetypes/ajax/contentadd/?id=' +id, + success: function(data) { + // alert("Data Saved"); + location.reload();} + }); + } + }); + } + }); + + } + }); + + }); + }); + + + diff --git a/gstudio/templates/gstudio/NewPage.html b/gstudio/templates/gstudio/NewPage.html new file mode 100644 index 00000000..541554b2 --- /dev/null +++ b/gstudio/templates/gstudio/NewPage.html @@ -0,0 +1,30 @@ +{%extends "gstudio/base.html"%} +{%load i18n %} +{% block content %} +{%if user.is_authenticated%} +{% if errors %} + +{% endif %} +
+{% csrf_token %} + +

Name of the Page:

+

+ +


+ +

+
+ + +
+{%else%} +

Sorry! Login To proceed

+ +{%endif%} +{% endblock %} + diff --git a/gstudio/templates/gstudio/NewSection1.html b/gstudio/templates/gstudio/NewSection1.html new file mode 100644 index 00000000..75db8a2a --- /dev/null +++ b/gstudio/templates/gstudio/NewSection1.html @@ -0,0 +1,26 @@ + +{% extends "gstudio/base.html" %} +{% block content %} +

Add a new Section

+{% if errors %} + +{% endif %} + +
{% csrf_token %} +

Title:

+

+

+

+ + +


+ + + +
+ +{% endblock %} diff --git a/gstudio/templates/gstudio/_header.html b/gstudio/templates/gstudio/_header.html index 08fdab24..4b2b0753 100644 --- a/gstudio/templates/gstudio/_header.html +++ b/gstudio/templates/gstudio/_header.html @@ -17,6 +17,7 @@ {% if user.is_staff %} | Gnowledge Studio | Documents + | Wikipage | Images | Videos | Admin Dashboard diff --git a/gstudio/templates/gstudio/nodetype_detail.html b/gstudio/templates/gstudio/nodetype_detail.html index 95cf45bf..73db903a 100644 --- a/gstudio/templates/gstudio/nodetype_detail.html +++ b/gstudio/templates/gstudio/nodetype_detail.html @@ -214,7 +214,7 @@ Content: - + @@ -223,8 +223,10 @@ {% else %} - Content: - + Content: + + + diff --git a/gstudio/templates/gstudio/skeleton.html b/gstudio/templates/gstudio/skeleton.html index 8f5c30dc..9ce61885 100644 --- a/gstudio/templates/gstudio/skeleton.html +++ b/gstudio/templates/gstudio/skeleton.html @@ -51,9 +51,9 @@ display: block; position: absolute; } -.orgitdown .orgitdownButton1 a { - background-image:url(/static/gstudio/js/orgitdown/orgitdown/sets/org/images/save.jpeg); -} + + + .orgitdown .orgitdownButton2 a { background-image:url(/static/gstudio/js/orgitdown/orgitdown/sets/default/images/bold.png); } @@ -104,7 +104,7 @@ background:#FFF url(/static/gstudio/js/orgitdown/orgitdown/skins/orgitdown/images/bg-container.png) repeat-x top left; padding:5px 5px 2px 5px; font:11px Verdana, Arial, Helvetica, sans-serif; - margin-left:450px; + margin-left:640px; width:450px; margin-top:30px; } @@ -285,6 +285,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gstudio/templates/gstudio/tags/commentpage.html b/gstudio/templates/gstudio/tags/commentpage.html new file mode 100644 index 00000000..a998a7ff --- /dev/null +++ b/gstudio/templates/gstudio/tags/commentpage.html @@ -0,0 +1,75 @@ + + + + +{% load gstudio_tags %} +{% load i18n %} + + + +{% if comment.posterior_nodes.count %} + +
    +{% for child in comment.posterior_nodes.all %} + + {% for each in child.authors.all %} + {% ifequal idusr admin_id %} +
  • {{child.title}}
    {{child.content}} +
    {% csrf_token %} + + + + + + + + + + + + + + + + +
    + {% show_commentpage child idusr flag admin_id attribute%} +
  • + {% else %} + {% ifequal idusr each.id %} +
  • {{each}} says {{child.title}} +
    {% csrf_token %} + + + + + + +
    + {% show_commentpage child idusr flag admin_id attribute%} +
  • + {% else %} + {% ifequal attribute "true" %} + +
  • {{each}} says {{child.title}} +
    {% csrf_token %} + + + + + + +
    + {% show_commentpage child idusr flag admin_id attribute%} +
  • + {% endifequal %} + {% endifequal %} + {% endifequal %} + {% endfor %} + + +{% endfor %} +
+{% endif %} + + diff --git a/gstudio/templates/metadashboard/pgedashboard.html b/gstudio/templates/metadashboard/pgedashboard.html new file mode 100644 index 00000000..2c24cc60 --- /dev/null +++ b/gstudio/templates/metadashboard/pgedashboard.html @@ -0,0 +1,178 @@ +{% extends "gstudio/base.html" %} +{% load i18n comments gstudio_tags %} +{% load adminmedia grp_tags %} +{% load gstudio_tags %} +{% load pagination_tags %} + +{% block content %} + + + + +{% if user.is_authenticated %} +{% autopaginate section 1 %} + +

{{ page_ob.title }}

+ Wikipage posted on : {{page_ob.creation_date}} + by {% for author in page_ob.authors.all %} + {{author}} + {% endfor %}

+ + {% with page_ob.html_content|safe as page_ob_content %} + + {{page_ob_content}} + {% endwith %} + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{% csrf_token %} + + + +
+ +
{% autoescape off %} + + {% for each in section %} +

{{each.title}}


+ Posted on : {{each.creation_date}} + by {% for author in each.authors.all %} + {{author}} + {% endfor %}
+ + {% ifequal each.rating.get_rating 0 %} +
Not yet rated
+ {% else %} + Current rating is
{{ each.rating.get_rating }}
+ {% endifequal %} + {%autoescape on%} + {% with each.html_content|safe as each_content %} + {{each_content}} + {% endwith %} + {% endautoescape%} + + + + +
{% csrf_token %} + Create Subsection: +
+ + + + +
+

Delete section +
+ Do you wanna rate it ?
+ + + + + + +
+ +
+

+ Subsections : + + + + + + + {% show_commentpage each user.id flag1 admin_id attribute %} + {% endfor %} +{% endautoescape %} + +{% else %} +

OOPS!!! Login Please!

+{% endif %} + +{% block nodetype-comments %} +
+
{% trans "Comments" %}
+ {% with page_ob.comments as comment_list %} + {% if comment_list.count %} +
    + {% for comment in comment_list %} + + {% endfor %} +
+ {% if not page_ob.comments_are_open %} +

{% trans "Comments are closed." %}

+ {% endif %} + {% else %} + {% if page_ob.comments_are_open %} +

{% trans "No comments yet." %}

+ {% else %} +

{% trans "Comments are closed." %}

+ {% endif %} + {% endif %} + {% endwith %} +
+{% endblock %} +
+ {% render_comment_form for page_ob %} +
+ +{% paginate %} + +{% endblock %} + diff --git a/gstudio/templates/metadashboard/wikidashboard.html b/gstudio/templates/metadashboard/wikidashboard.html new file mode 100644 index 00000000..8b9d15ef --- /dev/null +++ b/gstudio/templates/metadashboard/wikidashboard.html @@ -0,0 +1,24 @@ +{% extends "gstudio/base.html" %} +{% load gstudio_tags %} +{% load i18n %} +{% block content %} + + +{% if user.is_authenticated %} + +

Here is a list of all the pages:

+
+ {% for each in pages.member_systems.all %} + {{each.title}}
+ {% endfor %} + +

+

+
+{% else %} +

OOPS!!! Login Please!

+{% endif %} + + + +{% endblock %} diff --git a/gstudio/templatetags/gstudio_tags.py b/gstudio/templatetags/gstudio_tags.py index c5954ab1..d79c658d 100644 --- a/gstudio/templatetags/gstudio_tags.py +++ b/gstudio/templatetags/gstudio_tags.py @@ -385,3 +385,7 @@ def get_tag_cloud(steps=6, template='gstudio/tags/tag_cloud.html'): @register.inclusion_tag('gstudio/tags/comment.html') def show_comment(comment,idusr,flag,admin_id,attob): return {'comment':comment , 'idusr' : idusr, "flag" : flag, "admin_id" : admin_id , "attribute" : attob} + +@register.inclusion_tag('gstudio/tags/commentpage.html') +def show_commentpage(comment,idusr,flag,admin_id,attob): + return {'comment':comment , 'idusr' : idusr, "flag" : flag, "admin_id" : admin_id , "attribute" : attob} diff --git a/gstudio/urls/__init__.py b/gstudio/urls/__init__.py index d9f65cd5..efc6305c 100644 --- a/gstudio/urls/__init__.py +++ b/gstudio/urls/__init__.py @@ -39,10 +39,14 @@ urlpatterns = patterns( url(r'^', include('gstudio.urls.capabilities')), url(r'^', include('gstudio.urls.nodetypes')), url(r'topicadd1/', include('gstudio.urls.topicadd1')), + url(r'sectionadd1/', include('gstudio.urls.sectionadd1')), url(r'^login', include('gstudio.urls.login')), url(r'user/(\w+)/$','gstudio.views.user.userdashboard'), + url(r'user/wikipage/(\w+)/$','gstudio.views.user.wikidashboard'), url(r'groupadd/', include('gstudio.urls.groupadd')), + url(r'pageadd/', include('gstudio.urls.pageadd')), url(r'group/',include('gstudio.urls.group')), + url(r'page/',include('gstudio.urls.page')), url(r'^resources/images/',include('gstudio.urls.image')), url(r'^resources/videos/',include('gstudio.urls.video')), url(r'^resources/documents',include('gstudio.urls.docu')), diff --git a/gstudio/urls/page.py b/gstudio/urls/page.py new file mode 100644 index 00000000..23df1e3d --- /dev/null +++ b/gstudio/urls/page.py @@ -0,0 +1,27 @@ +# Copyright (c) 2011, 2012 Free Software Foundation + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + + +"""Url for Gstudio User Dashboard""" +from django.conf.urls.defaults import url +from django.conf.urls.defaults import patterns + +urlpatterns = patterns('gstudio.views.page', + url(r'^gnowsys-page/(\d+)/$', 'pagedashboard', name='gstudio_page'), + # url(r'^later$', 'grouplater', name='gstudio_group'), + # url(r'^over$', 'groupover', + # name='gstudio_group'), + ) diff --git a/gstudio/urls/pageadd.py b/gstudio/urls/pageadd.py new file mode 100644 index 00000000..8aa4b10c --- /dev/null +++ b/gstudio/urls/pageadd.py @@ -0,0 +1,20 @@ +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +"""Url for Gstudio User Dashboard""" +from django.conf.urls.defaults import url +from django.conf.urls.defaults import patterns + +urlpatterns = patterns('gstudio.views.pageadd', + url(r'^$', 'pageadd', + name='gstudio_page'), + + ) diff --git a/gstudio/urls/sectionadd1.py b/gstudio/urls/sectionadd1.py new file mode 100644 index 00000000..592b493b --- /dev/null +++ b/gstudio/urls/sectionadd1.py @@ -0,0 +1,9 @@ +"""Url for Gstudio User Dashboard""" +from django.conf.urls.defaults import url +from django.conf.urls.defaults import patterns + +urlpatterns = patterns('gstudio.views.sectionadd1', + url(r'(\d+)', 'sectionadd1', + name='gstudio_section'), + + ) diff --git a/gstudio/urls/user.py b/gstudio/urls/user.py index 12031d35..7b73c8a0 100644 --- a/gstudio/urls/user.py +++ b/gstudio/urls/user.py @@ -20,7 +20,8 @@ from django.conf.urls.defaults import url from django.conf.urls.defaults import patterns urlpatterns = patterns('gstudio.views.user', - url(r'^$', 'userdashboard', - name='gstudio_user'), + url(r'^$', 'userdashboard',name='gstudio_user'), + url(r'^wikipage/$', 'wikidashboard', name='gstudio_wiki'), + ) diff --git a/gstudio/views/page.py b/gstudio/views/page.py new file mode 100644 index 00000000..71111ffe --- /dev/null +++ b/gstudio/views/page.py @@ -0,0 +1,79 @@ +# Copyright (c) 2011, 2012 Free Software Foundation + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from django.http import HttpResponse +from django.http import HttpResponseRedirect +from django.template import RequestContext +from django.shortcuts import render_to_response +from gstudio.models import * +from gstudio.methods import * + +def pagedashboard(request,pageid): + pageid = int(pageid) + # boolean1 = False + flag= False + page_ob = System.objects.get(id=pageid) + if request.method == "POST" : + boolean = False + rep = request.POST.get("replytosection",'') + print "rep" ,rep +# content_org = request.POST.get("orgreply",'') + id_no = request.POST.get("iden",'') + id_no1 = request.POST.get("parentid","") + idusr = request.POST.get("idusr",'') + rating = request.POST.get("star1","") + # # flag1=request.POST.get("pagerelease","") + # # block = request.POST.get("block","") + section_del = request.POST.get("del_section", "") + comment_del = request.POST.get("del_comment", "") + if section_del: + del_section(int(id_no)) + if comment_del: + del_comment(int(id_no1)) + if rating : + rate_section(int(id_no),request,int(rating)) + if rep : + if not id_no : + ptitle= make_title(int(id_no)) + boolean = make_sectionrelation(rep,ptitle,int(id_no1),int(idusr)) + + + elif not id_no1 : + ptitle= make_title(int(id_no)) + boolean = make_sectionrelation(rep,ptitle,int(id_no),int(idusr)) + + if boolean : + return HttpResponseRedirect("/gstudio/page/gnowsys-page/"+str(pageid)) + pageid = int(pageid) + if request.user.id == page_ob.authors.all()[0].id : + flag = True + Section = page_ob.system_set.all()[0].gbobject_set.all() + admin_id = page_ob.authors.all()[0].id #a list of topics + # # for each in page_ob.subject_of.all(): + # # if each.attributetype.title=='pagerelease': + # # attob = each.svalue + # # break + admin_m = page_ob.authors.all()[0] + + topic_type_set=Objecttype.objects.get(title='Section') + if(len(topic_type_set.get_members)): + latest_topic=topic_type_set.get_members[0] + post=latest_topic.get_absolute_url() + else: + post="no topic added yet!!" + + variables = RequestContext(request, {'section' : Section,'page_ob' : page_ob,'admin_m':admin_m,"flag" : flag,"admin_id" : admin_id,'post':post}) + template = "metadashboard/pgedashboard.html" + return render_to_response(template, variables) diff --git a/gstudio/views/pageadd.py b/gstudio/views/pageadd.py new file mode 100644 index 00000000..4f63ead0 --- /dev/null +++ b/gstudio/views/pageadd.py @@ -0,0 +1,41 @@ +# Copyright (c) 2011, 2012 Free Software Foundation + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from django.http import HttpResponse +from django.http import HttpResponseRedirect +from django.template import RequestContext +from django.shortcuts import render_to_response +from gstudio.models import * +from gstudio.methods import * +import datetime +def pageadd(request): + errors = [] + pageId = "" + if request.method == 'POST': + if not request.POST.get('subject', ''): + errors.append('Enter a title.') + # if not request.POST.get('org1', ''): + # errors.append('Enter a page.') + if not errors: + title=request.POST['subject'] + # content=request.POST['page'] + content_org=request.POST['org1'] + idusr=request.POST['idusr'] + pageId = create_wikipage(title,int(idusr),content_org) + if pageId : + return HttpResponseRedirect('/gstudio/page/gnowsys-page/'+ str(pageId)) + variables = RequestContext(request,{'errors' : errors, 'pageId' : pageId}) + template = "gstudio/NewPage.html" + return render_to_response(template, variables) diff --git a/gstudio/views/sectionadd1.py b/gstudio/views/sectionadd1.py new file mode 100644 index 00000000..0c5643ca --- /dev/null +++ b/gstudio/views/sectionadd1.py @@ -0,0 +1,36 @@ + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + + +from django.http import HttpResponse +from django.http import HttpResponseRedirect +from django.template import RequestContext +from django.shortcuts import render_to_response +from gstudio.models import * +from gstudio.methods import * + +def sectionadd1(request,pageid): + errors = [] + if request.method == 'POST': + if not request.POST.get('subject', ''): + errors.append('Enter a title.') + if not request.POST.get('org', ''): + errors.append('Enter a page.') + if not errors: + title=request.POST['subject'] + # content=request.POST['page'] + content_org=request.POST['org'] + idusr=request.POST['idusr'] + tp = make_section_object(title,int(idusr),content_org) + System.objects.get(id=int(pageid)).system_set.all()[0].gbobject_set.add(tp) + if tp: + return HttpResponseRedirect('/gstudio/page/gnowsys-page/'+pageid) + + + variables = RequestContext(request,{'errors' : errors,'pageid' : pageid}) + template = "gstudio/NewSection1.html" + return render_to_response(template, variables) + + diff --git a/gstudio/views/user.py b/gstudio/views/user.py index 10e1ff7e..9fa9b6d3 100644 --- a/gstudio/views/user.py +++ b/gstudio/views/user.py @@ -32,6 +32,17 @@ def userdashboard(request,username): template = "metadashboard/logindashboard.html" return render_to_response(template,variables) +def wikidashboard(request,username): + if request.user.username == username : + pages = Systemtype.objects.get(title="Wikipage") + variables = RequestContext(request,{"pages" : pages }) + template = "metadashboard/wikidashboard.html" + return render_to_response(template, variables) + else : + variables = RequestContext(request) + template = "metadashboard/logindashboard.html" + return render_to_response(template,variables) + diff --git a/gstudio/views/wikidashboard.py b/gstudio/views/wikidashboard.py new file mode 100644 index 00000000..ed08b9d3 --- /dev/null +++ b/gstudio/views/wikidashboard.py @@ -0,0 +1,61 @@ +# Copyright (c) 2011, 2012 Free Software Foundation + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +# This project incorporates work covered by the following copyright and permission notice: + +# Copyright (c) 2009, Julien Fache +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: + +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of the author nor the names of other +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +# OF THE POSSIBILITY OF SUCH DAMAGE. + + + +from django.http import HttpResponse +from django.http import HttpResponseRedirect +from django.template import RequestContext +from django.shortcuts import render_to_response + +def wikidashboard(request): + variables = RequestContext(request) + template = "gstudiodashboard/dashboard.html" + return render_to_response(template, variables) + + -- cgit v1.2.3-70-g09d2