You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/04/03 23:01:53 UTC

[1/2] git commit: [#7208] add registration_date method to ProjectRegistrationProvider

Repository: allura
Updated Branches:
  refs/heads/master 461a4b542 -> 323c00dab


[#7208] add registration_date method to ProjectRegistrationProvider


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

Branch: refs/heads/master
Commit: 323c00dabd195dfbd2e3f6bf090c57b5e9fd4209
Parents: d37bf5f
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Apr 3 20:18:59 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Apr 3 21:01:40 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py    | 6 ++++++
 Allura/allura/model/project.py | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/323c00da/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 7aea613..2a09d73 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -683,6 +683,12 @@ class ProjectRegistrationProvider(object):
            It should be overridden for your specific envirnoment'''
         return None
 
+    def registration_date(self, project):
+        '''
+        Return the datetime the project was created.
+        '''
+        return project._id.generation_time
+
 
 class ThemeProvider(object):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/323c00da/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 16733cc..ed581d0 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -1046,7 +1046,8 @@ class Project(MappedClass, ActivityNode, ActivityObject):
         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')
+        registration_date = plugin.ProjectRegistrationProvider.get().registration_date(self)
+        ET.SubElement(project, 'created').text = registration_date.strftime('%Y-%m-%d')
         if self.external_homepage:
             ET.SubElement(project, 'homepage', {'rdf:resource': self.external_homepage})
 


[2/2] git commit: [#7208] ticket:566 Few fixes for project DOAP API

Posted by br...@apache.org.
[#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 <je...@gmail.com>
Authored: Tue Apr 1 13:49:53 2014 +0300
Committer: Dave Brondsema <db...@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)