From b5a9a9bfc9bcd43f785f788c18e7f349395435ae Mon Sep 17 00:00:00 2001
From: Bruno Nocera Zanette <brunonzanette@gmail.com>
Date: Tue, 10 Sep 2013 13:23:10 -0300
Subject: [PATCH] Add PID attribute to post entities

Added PID (Post ID) attribute to entities of type "post".
Before this change it was a HREF attribute.

Signed-off-by: Bruno Nocera Zanette <brunonzanette@gmail.com>
---
 lib_group_section.py | 18 ++++++++++++------
 lib_user_section.py  | 18 ++++++++++++------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/lib_group_section.py b/lib_group_section.py
index 93c0f76..4c1fd1f 100644
--- a/lib_group_section.py
+++ b/lib_group_section.py
@@ -142,6 +142,12 @@ def cidstr(guid):
     return uid_string
 #--------------------------------------------------------------------#
 
+#--------------------------------------------------------------------#
+def pidstr(guid):
+    pid_string=" pid="+"\""+guid+"\""
+    return pid_string
+#--------------------------------------------------------------------#
+
 #--------------------------------------------------------------------#
 def permstr(perm):
     perm_string=" habilitado="+"\""+str(perm)+"\""
@@ -299,7 +305,7 @@ def write_groupfiles_subsection (db, xml, group_guid):
         link_prefix="http://participatorio.juventude.gov.br/file/download/"
         file_link=str(link_prefix)+str(post_guid)
         
-        post_attr=hrefstr(urlparticipa('file/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('file/view/',str(post_guid)))
         xml.write(l3+"<arquivo"+post_attr+">\n")
 
         owner_attr=uidstr(urlparticipa('profile/',owner_username))
@@ -334,7 +340,7 @@ def write_groupforumtopics_subsection (db, xml, group_guid):
         owner_id, owner_name, owner_username, time)\
         in group_forumtopics:
         
-        post_attr=hrefstr(urlparticipa('discussion/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('discussion/view/',str(post_guid)))
         xml.write(l3+"<debate"+post_attr+">\n")
 
         owner_attr=uidstr(urlparticipa('profile/',owner_username))
@@ -371,7 +377,7 @@ def write_groupbookmarks_subsection (db, xml, group_guid):
         # 90 = select * from elgg_metastrings where string='address';
         bookmark_link=post_content(db,post_guid,90)
         
-        post_attr=hrefstr(urlparticipa('bookmarks/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('bookmarks/view/',str(post_guid)))
         xml.write(l3+"<favorito"+post_attr+">\n")
 
         owner_attr=uidstr(urlparticipa('profile/',owner_username))
@@ -406,7 +412,7 @@ def write_grouppages_subsection (db, xml, group_guid):
             owner_id, owner_name, owner_username, time)\
         in group_pages:
             
-        post_attr=hrefstr(urlparticipa('pages/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('pages/view/',str(post_guid)))
         xml.write(l3+"<pagina"+post_attr+">\n")
 
         owner_attr=uidstr(urlparticipa('profile/',owner_username))
@@ -443,7 +449,7 @@ def write_groupvideos_subsection (db, xml, group_guid):
         # 477 = select * from elgg_metastrings where string='video_url';
         video_link=post_content(db,post_guid, 477)
             
-        post_attr=hrefstr(urlparticipa('videos/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('videos/view/',str(post_guid)))
         xml.write(l3+"<video"+post_attr+">\n")
 
         owner_attr=uidstr(urlparticipa('profile/',owner_username))
@@ -496,7 +502,7 @@ def write_groupevents_subsection (db, xml, group_guid):
         # 30 = select * from elgg_metastrings where string='organizer';
         organizer=post_content(db, post_guid, 30)
 
-        post_attr=hrefstr(urlparticipa('event_calendar/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('event_calendar/view/',str(post_guid)))
         xml.write(l3+"<evento"+post_attr+">\n")
         
         owner_attr=uidstr(urlparticipa('profile/',owner_username))
diff --git a/lib_user_section.py b/lib_user_section.py
index a312ecd..c74bba1 100644
--- a/lib_user_section.py
+++ b/lib_user_section.py
@@ -139,6 +139,12 @@ def cidstr(guid):
     return uid_string
 #--------------------------------------------------------------------#
 
+#--------------------------------------------------------------------#
+def pidstr(guid):
+    pid_string=" pid="+"\""+guid+"\""
+    return pid_string
+#--------------------------------------------------------------------#
+
 #--------------------------------------------------------------------#
 def urlparticipa(prefix, guid):
     http_str="http://participatorio.juventude.gov.br/"
@@ -278,7 +284,7 @@ def write_userfiles_subsection (db, xml, user_guid):
         link_prefix="http://participatorio.juventude.gov.br/file/download/"
         file_link=str(link_prefix)+str(post_guid)
         
-        post_attr=hrefstr(urlparticipa('file/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('file/view/',str(post_guid)))
         xml.write(l3+"<arquivo"+post_attr+">\n")
         
         write_tag(xml,l4,"titulo",post_title,'')
@@ -311,7 +317,7 @@ def write_userblogs_subsection (db, xml, user_guid):
         # 64 = select * from elgg_metastrings where string='excerpt';
         post_excerpt=post_content(db,post_guid,64)
             
-        post_attr=hrefstr(urlparticipa('blog/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('blog/view/',str(post_guid)))
         xml.write(l3+"<blog"+post_attr+">\n")
 
         write_tag(xml,l4,"titulo",post_title,'')
@@ -343,7 +349,7 @@ def write_userbookmarks_subsection (db, xml, user_guid):
         # 90 = select * from elgg_metastrings where string='address';
         bookmark_link=post_content(db,post_guid,90)
   
-        post_attr=hrefstr(urlparticipa('bookmarks/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('bookmarks/view/',str(post_guid)))
         xml.write(l3+"<favorito"+post_attr+">\n")
     
         write_tag(xml,l4,"titulo",post_title,'')
@@ -372,7 +378,7 @@ def write_userpages_subsection (db, xml, user_guid):
     for (post_guid, post_title, post_desc, time)\
         in user_pages:
         
-        post_attr=hrefstr(urlparticipa('pages/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('pages/view/',str(post_guid)))
         xml.write(l3+"<pagina"+post_attr+">\n")
 
         write_tag(xml,l4,"titulo",post_title,'')
@@ -403,7 +409,7 @@ def write_uservideos_subsection (db, xml, user_guid):
         # 477 = select * from elgg_metastrings where string='video_url';
         video_link=post_content(db, post_guid, 477)
         
-        post_attr=hrefstr(urlparticipa('videos/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('videos/view/',str(post_guid)))
         xml.write(l3+"<video"+post_attr+">\n")
         
         write_tag(xml,l4,"titulo",post_title,'')
@@ -451,7 +457,7 @@ def write_userevents_subsection (db, xml, user_guid):
         # 30 = select * from elgg_metastrings where string='organizer';
         organizer=post_content(db, post_guid, 30)
         
-        post_attr=hrefstr(urlparticipa('event_calendar/view/',str(post_guid)))
+        post_attr=pidstr(urlparticipa('event_calendar/view/',str(post_guid)))
         xml.write(l3+"<evento"+post_attr+">\n")
         
         write_tag(xml,l4,"titulo",post_title,'')
-- 
GitLab