• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

修订版74cae90557ab9516a9ef677f0b18d89faea60f51 (tree)
时间2012-05-04 02:22:13
作者Jenny Steele <jsteele@geek...>
CommiterYaroslav Luzin

Log Message

[#4113] Neighborhood and project GA tracking now checks to make sure feature is enabled for the neighborhood

更改概述

差异

--- a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
@@ -38,9 +38,11 @@
3838 {% if value.support_page == '_url' %} checked{% endif %}>
3939 <label for="support_page_url_cb">URL: </label>
4040 <input type="text" name="support_page_url" value="{{value.support_page_url}}" style="width: 70%">
41+ {% if value.neighborhood.features['google_analytics'] %}
4142 {{ widget.display_label(widget.fields.tracking_id) }}
4243 <br>
4344 {{widget.display_field(widget.fields.tracking_id) }}
45+ {% endif %}
4446 </div>
4547 <div class="grid-9">
4648
--- a/Allura/allura/templates/jinja_master/theme_macros.html
+++ b/Allura/allura/templates/jinja_master/theme_macros.html
@@ -42,11 +42,13 @@
4242 {% if account -%}
4343 _add_tracking('sfnt', '{{account}}');
4444 {%- endif %}
45- {% if project and project.neighborhood.tracking_id -%}
46- _add_tracking('nbhd', '{{project.neighborhood.tracking_id}}');
47- {%- endif %}
48- {% if project and project.tracking_id -%}
49- _add_tracking('proj', '{{project.tracking_id}}');
45+ {% if project and project.neighborhood.features['google_analytics'] -%}
46+ {% if project.neighborhood.tracking_id -%}
47+ _add_tracking('nbhd', '{{project.neighborhood.tracking_id}}');
48+ {%- endif %}
49+ {% if project.tracking_id -%}
50+ _add_tracking('proj', '{{project.tracking_id}}');
51+ {%- endif %}
5052 {%- endif %}
5153
5254 (function() {
--- a/Allura/allura/templates/widgets/neighborhood_overview_form.html
+++ b/Allura/allura/templates/widgets/neighborhood_overview_form.html
@@ -24,8 +24,10 @@
2424 {{widget.display_field(widget.fields.icon)}}
2525 </div>
2626 {% endif %}
27+ {% if value.features and value.features['google_analytics'] %}
2728 <label class="grid-4">Analytics Tracking ID</label>
2829 <div class="grid-14">{{widget.display_field(widget.fields.tracking_id)}}</div>
30+ {% endif %}
2931 <label class="grid-4">&nbsp;</label>
3032 <div class="grid-14"><input type="submit" value="Save"/></div>
3133 </form>
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -48,6 +48,8 @@ class TestNeighborhood(TestController):
4848 r = self.app.get('/adobe/_admin/', extra_environ=dict(username='root'))
4949 r = self.app.get('/adobe/_admin/overview', extra_environ=dict(username='root'))
5050 r = self.app.get('/adobe/_admin/accolades', extra_environ=dict(username='root'))
51+ neighborhood = M.Neighborhood.query.get(name='Adobe')
52+ neighborhood.features['google_analytics'] = True
5153 r = self.app.post('/adobe/_admin/update',
5254 params=dict(name='Mozq1', css='', homepage='# MozQ1!', tracking_id='U-123456'),
5355 extra_environ=dict(username='root'))
@@ -112,6 +114,34 @@ class TestNeighborhood(TestController):
112114 image = Image.open(StringIO(r.body))
113115 assert image.size == (48,48)
114116
117+ def test_google_analytics(self):
118+ # analytics allowed
119+ neighborhood = M.Neighborhood.query.get(name='Adobe')
120+ neighborhood.features['google_analytics'] = True
121+ r = self.app.get('/adobe/_admin/overview', extra_environ=dict(username='root'))
122+ assert 'Analytics Tracking ID' in r
123+ r = self.app.get('/adobe/adobe-1/admin/overview', extra_environ=dict(username='root'))
124+ assert 'Analytics Tracking ID' in r
125+ r = self.app.post('/adobe/_admin/update',
126+ params=dict(name='Adobe', css='', homepage='# MozQ1', tracking_id='U-123456'),
127+ extra_environ=dict(username='root'))
128+ r = self.app.post('/adobe/adobe-1/admin/update',
129+ params=dict(tracking_id='U-654321'),
130+ extra_environ=dict(username='root'))
131+ r = self.app.get('/adobe/adobe-1/admin/overview', extra_environ=dict(username='root'))
132+ assert "_add_tracking('nbhd', 'U-123456');" in r
133+ assert "_add_tracking('proj', 'U-654321');" in r
134+ # analytics not allowed
135+ neighborhood = M.Neighborhood.query.get(name='Adobe')
136+ neighborhood.features['google_analytics'] = False
137+ r = self.app.get('/adobe/_admin/overview', extra_environ=dict(username='root'))
138+ assert 'Analytics Tracking ID' not in r
139+ r = self.app.get('/adobe/adobe-1/admin/overview', extra_environ=dict(username='root'))
140+ assert 'Analytics Tracking ID' not in r
141+ r = self.app.get('/adobe/adobe-1/admin/overview', extra_environ=dict(username='root'))
142+ assert "_add_tracking('nbhd', 'U-123456');" not in r
143+ assert "_add_tracking('proj', 'U-654321');" not in r
144+
115145 def test_custom_css(self):
116146 test_css = '.test{color:red;}'
117147 custom_css = 'Custom CSS'