← Back to team overview

harvest-dev team mailing list archive

[Merge] lp:~dholbach/harvest/release into lp:harvest

 

Daniel Holbach has proposed merging lp:~dholbach/harvest/release into lp:harvest.

Requested reviews:
  harvest-dev (harvest-dev)

-- 
https://code.launchpad.net/~dholbach/harvest/release/+merge/26514
Your team harvest-dev is requested to review the proposed merge of lp:~dholbach/harvest/release into lp:harvest.
=== added file 'harvest/common/context_processors.py'
--- harvest/common/context_processors.py	1970-01-01 00:00:00 +0000
+++ harvest/common/context_processors.py	2010-06-01 16:18:26 +0000
@@ -0,0 +1,16 @@
+from django.conf import settings
+
+def harvest_version(request):
+    """
+    add the harvest version to template context processor. 
+    """
+    try:
+        version = settings.VERSION_STRING
+    except AttributeError:
+        version = "unknown"
+
+    return {'harvest_version': version}
+
+def login_redirect(request):
+    return {'login_next': request.get_full_path()}
+

=== added file 'harvest/common/utils.py'
--- harvest/common/utils.py	1970-01-01 00:00:00 +0000
+++ harvest/common/utils.py	2010-06-01 16:18:26 +0000
@@ -0,0 +1,25 @@
+import email
+import os
+
+def get_harvest_version(version_file, debug):
+    """
+    return the bzr revision number and version of Harvest
+    """
+
+    if not os.path.exists(version_file):
+        return "version unknown"
+
+    f = email.message_from_file(open(version_file))
+    version = f["version"]
+    bzr_revno = f["revno"]
+    
+    if debug:
+        try:
+            from bzrlib.branch import Branch
+            branch = Branch.open_containing('.')[0]
+            bzr_revno = branch.revno()
+        except:
+            pass
+
+    return "version %s (rev %s)" % (version, bzr_revno)
+

=== added file 'harvest/opportunities/management/commands/release.py'
--- harvest/opportunities/management/commands/release.py	1970-01-01 00:00:00 +0000
+++ harvest/opportunities/management/commands/release.py	2010-06-01 16:18:26 +0000
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+from django.core.management.base import LabelCommand
+from django.conf import settings
+
+import subprocess
+import sys
+import os
+
+def write_version_strings(version):
+    try:
+        from bzrlib.branch import Branch
+        branch = Branch.open_containing('.')[0]
+        bzr_revno = '%s' % (int(branch.revno())+1)
+    except:
+        bzr_revno = 'unknown'
+
+    file_name = os.path.join(settings.PROJECT_PATH, "version")
+    if os.path.exists(file_name):
+        os.remove(file_name)
+    f = open(file_name, "w")
+    f.write("""version: %s
+revno: %s
+""" % (version, bzr_revno))
+    f.close()
+    return (version, bzr_revno)
+
+class Command(LabelCommand):
+    help = "Prepare release of Harvest. Please pass <version> as an argument."
+
+    def handle_label(self, label, **options):
+        (version, bzr_revno) = write_version_strings(label)
+        subprocess.call(["bzr", "tag", version])
+        print >> sys.stdout, "Released %s." % label

=== modified file 'harvest/settings.py'
--- harvest/settings.py	2010-03-08 16:33:21 +0000
+++ harvest/settings.py	2010-06-01 16:18:26 +0000
@@ -8,6 +8,11 @@
 STATIC_SERVE = True
 PROJECT_NAME = 'harvest'
 
+from common import utils
+VERSION_STRING = utils.get_harvest_version(
+                    os.path.join(PROJECT_PATH, "version"),
+                    DEBUG)
+
 ADMINS = ('Daniel Holbach', 'daniel.holbach@xxxxxxxxxx')
 MANAGERS = ADMINS
 
@@ -82,6 +87,8 @@
     "django.core.context_processors.i18n",
     "django.core.context_processors.media",
     "django.core.context_processors.request",
+    "common.context_processors.harvest_version",
+    "common.context_processors.login_redirect",
     )
 
 INSTALLED_APPS = (

=== modified file 'harvest/templates/base.html'
--- harvest/templates/base.html	2010-01-05 01:47:06 +0000
+++ harvest/templates/base.html	2010-06-01 16:18:26 +0000
@@ -79,7 +79,7 @@
       <div class="wrapper">
         <img src="{{ MEDIA_URL }}img/rule.png" width="740" height="1" alt="" class="rule" />
         <p>&copy; 2008-2009 Canonical Ltd.  Ubuntu and Canonical are registered
-        trademarks of Canonical Ltd.</p>
+        trademarks of Canonical Ltd.<br />{% trans "Harvest" %} {{ harvest_version }}</p>
       </div>
     </div>
     <div id="bg-right">&nbsp;</div><div id="bottom-right">&nbsp;</div> 

=== added file 'harvest/version'
--- harvest/version	1970-01-01 00:00:00 +0000
+++ harvest/version	2010-06-01 16:18:26 +0000
@@ -0,0 +1,2 @@
+version: 0.2.0-pre
+revno: 182