allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/2] git commit: [#7208] ticket:566 Few fixes for project DOAP API
Date Thu, 03 Apr 2014 21:01:54 GMT
[#7208] ticket:566 Few fixes for project DOAP API


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/d37bf5fa
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d37bf5fa
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d37bf5fa

Branch: refs/heads/master
Commit: d37bf5fadb0b4108de1b0aedf5b27f3ed9c0ef34
Parents: 461a4b5
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Apr 1 13:49:53 2014 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Apr 3 21:01:40 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/project.py              | 10 +++++-----
 Allura/allura/tests/functional/test_rest.py | 11 ++++++++++-
 2 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d37bf5fa/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 1ee6683..16733cc 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -1038,15 +1038,15 @@ class Project(MappedClass, ActivityNode, ActivityObject):
             'xmlns:rss': "http://purl.org/rss/1.0/",
             'xmlns:dc': "http://dublincore.org/documents/dcmi-namespace/",
             'xmlns:beer': "http://www.purl.org/net/ontology/beer.owl#",
-            'rdf:about': "http://sourceforge.net/api/project/name/vivo/doap#",
+            'rdf:about': h.absurl('/rest/' + self.url().strip('/') + '?doap#'),
         })
         # Basic fields
         ET.SubElement(project, 'name').text = self.shortname
         ET.SubElement(project, 'dc:title').text = self.name
-        ET.SubElement(project, 'sf:id').text = str(self._id)
-        ET.SubElement(project, 'sf:private').text = self.private
-        ET.SubElement(project, 'shortdesc', {'xml:lang': 'en'}).text = self.short_description
-        ET.SubElement(project, 'description', {'xml:lang': 'en'}).text = self.description
+        ET.SubElement(project, 'sf:private').text = '1' if self.private else '0'  # strange,
but sf.net does this
+        ET.SubElement(project, 'shortdesc', {'xml:lang': 'en'}).text = self.summary
+        ET.SubElement(project, 'description', {'xml:lang': 'en'}).text = self.short_description
+        ET.SubElement(project, 'created').text = self._id.generation_time.strftime('%Y-%m-%d')
         if self.external_homepage:
             ET.SubElement(project, 'homepage', {'rdf:resource': self.external_homepage})
 

http://git-wip-us.apache.org/repos/asf/allura/blob/d37bf5fa/Allura/allura/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_rest.py b/Allura/allura/tests/functional/test_rest.py
index 4bd53cf..55dcc0b 100644
--- a/Allura/allura/tests/functional/test_rest.py
+++ b/Allura/allura/tests/functional/test_rest.py
@@ -232,14 +232,23 @@ class TestDoap(TestRestApiBase):
     ns_sf = '{http://sourceforge.net/api/sfelements.rdf#}'
     foaf = '{http://xmlns.com/foaf/0.1/}'
     dc = '{http://dublincore.org/documents/dcmi-namespace/}'
+    rdf = '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}'
 
     def test_project_data(self):
+        project = M.Project.query.get(shortname='test')
+        project.summary = 'A Summary'
+        project.short_description = 'A Short Description'
+        ThreadLocalODMSession.flush_all()
         r = self.app.get('/rest/p/test?doap')
         assert_equal(r.content_type, 'application/rdf+xml')
         p = r.xml.find(self.ns + 'Project')
+        assert_equal(p.attrib[self.rdf + 'about'], 'http://localhost/rest/p/test?doap#')
         assert_equal(p.find(self.ns + 'name').text, 'test')
         assert_equal(p.find(self.dc + 'title').text, 'Test Project')
-        assert p.find(self.ns_sf + 'id') is not None
+        assert_equal(p.find(self.ns_sf + 'private').text, '0')
+        assert_equal(p.find(self.ns + 'shortdesc').text, 'A Summary')
+        assert_equal(p.find(self.ns + 'description').text, 'A Short Description')
+        assert_equal(p.find(self.ns + 'created').text, project._id.generation_time.strftime('%Y-%m-%d'))
 
         maintainers = p.findall(self.ns + 'maintainer')
         assert_equal(len(maintainers), 1)


Mime
View raw message