allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wwitz...@apache.org
Subject [3/3] git commit: [#5282] Add twitter handle to metadata form
Date Wed, 12 Dec 2012 14:47:58 GMT
[#5282] Add twitter handle to metadata form


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

Branch: refs/heads/master
Commit: eef1aca99d6fb94b34f22f479d0fbc0a396cd912
Parents: 919f6b0
Author: Patrick Lenz <plenz@geek.net>
Authored: Tue Dec 4 20:50:34 2012 +0000
Committer: Patrick Lenz <plenz@geek.net>
Committed: Tue Dec 4 20:50:34 2012 +0000

----------------------------------------------------------------------
 Allura/allura/ext/admin/admin_main.py              |    5 +++
 .../templates/admin_widgets/metadata_admin.html    |    3 ++
 Allura/allura/ext/admin/widgets.py                 |    1 +
 Allura/allura/model/project.py                     |   23 +++++++++++++++
 4 files changed, 32 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/eef1aca9/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index ad35414..04f902a 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -261,6 +261,7 @@ class ProjectAdminController(BaseController):
                external_homepage='',
                support_page='',
                support_page_url='',
+               twitter_handle='',
                removal='',
                moved_to_url='',
                export_controlled=False,
@@ -317,6 +318,10 @@ class ProjectAdminController(BaseController):
             h.log_action(log, 'change project support page').info('')
             M.AuditLog.log('change project support page to %s', support_page)
             c.project.support_page = support_page
+        if twitter_handle != c.project.social_account('Twitter'):
+            h.log_action(log, 'change project twitter handle').info('')
+            M.AuditLog.log('change project twitter handle to %s', twitter_handle)
+            c.project.set_social_account('Twitter', twitter_handle)
         if support_page_url != c.project.support_page_url:
             h.log_action(log, 'change project support page url').info('')
             M.AuditLog.log('change project support page url to %s', support_page_url)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/eef1aca9/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
index b822fd9..5e5db7a 100644
--- a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
@@ -38,6 +38,9 @@
            {% if value.support_page == '_url' %} checked{% endif %}>
     <label for="support_page_url_cb">URL: </label>
     <input type="text" name="support_page_url" value="{{value.support_page_url}}" style="width:
70%">
+    {{ widget.display_label(widget.fields.twitter_handle) }}
+    <br>
+    {{widget.display_field(widget.fields.twitter_handle) }}
     {% if value.neighborhood.features['google_analytics'] %}
     {{ widget.display_label(widget.fields.tracking_id) }}
     <br>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/eef1aca9/Allura/allura/ext/admin/widgets.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/widgets.py b/Allura/allura/ext/admin/widgets.py
index 8800798..2c5f5dd 100644
--- a/Allura/allura/ext/admin/widgets.py
+++ b/Allura/allura/ext/admin/widgets.py
@@ -162,6 +162,7 @@ class MetadataAdmin(ff.AdminForm):
         delete_icon = ew.InputField(field_type="hidden", label='Delete Icon')
         undelete = ew.InputField(field_type="hidden", label='Undelete')
         tracking_id = ew.InputField(field_type="text", label="Analytics Tracking ID")
+        twitter_handle = ew.InputField(field_type="text", label='Twitter Handle')
 
 class AuditLog(ew_core.Widget):
     template='jinja:allura.ext.admin:templates/widgets/audit.html'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/eef1aca9/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index de54e76..dd1f2c7 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -131,6 +131,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
     external_homepage=FieldProperty(str, if_missing='')
     support_page=FieldProperty(str, if_missing='')
     support_page_url=FieldProperty(str, if_missing='')
+    socialnetworks=FieldProperty([dict(socialnetwork=str,accounturl=str)])
     removal=FieldProperty(str, if_missing='')
     moved_to_url=FieldProperty(str, if_missing='')
     removal_changed_date = FieldProperty(datetime, if_missing=datetime.utcnow)
@@ -683,6 +684,28 @@ class Project(MappedClass, ActivityNode, ActivityObject):
             r = ProjectRole.by_name(role_name, self)
             pr.roles.append(r._id)
 
+    @property
+    def twitter_handle(self):
+        return self.social_account('Twitter').accounturl
+
+    def social_account(self, socialnetwork):
+        try:
+            account = (sn for sn in self.socialnetworks if sn.socialnetwork == socialnetwork).next()
+        except StopIteration:
+            return None
+        else:
+            return account
+
+    def set_social_account(self, socialnetwork, accounturl):
+        account = self.social_account(socialnetwork)
+        if account:
+            account.accounturl = accounturl
+        else:
+            self.socialnetworks.append(dict(
+                socialnetwork=socialnetwork,
+                accounturl=accounturl
+                ))
+
 class AppConfig(MappedClass):
     """
     Configuration information for an instantiated :class:`Application <allura.app.Application>`


Mime
View raw message