You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2018/10/01 13:31:07 UTC
[2/3] allura git commit: Enforce a format for GA tracking id
Enforce a format for GA tracking id
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6862652b
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6862652b
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6862652b
Branch: refs/heads/master
Commit: 6862652b225edf66c22c03bcd6ba4d787ed62452
Parents: 0f77ad5
Author: Dave Brondsema <da...@brondsema.net>
Authored: Mon Sep 24 17:42:47 2018 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Tue Sep 25 12:10:53 2018 -0400
----------------------------------------------------------------------
Allura/allura/ext/admin/widgets.py | 3 ++-
Allura/allura/lib/widgets/forms.py | 2 +-
Allura/allura/templates/jinja_master/theme_macros.html | 2 +-
.../allura/templates/widgets/neighborhood_overview_form.html | 2 +-
Allura/allura/tests/functional/test_neighborhood.py | 8 ++++----
5 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/6862652b/Allura/allura/ext/admin/widgets.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/widgets.py b/Allura/allura/ext/admin/widgets.py
index dd10429..716171d 100644
--- a/Allura/allura/ext/admin/widgets.py
+++ b/Allura/allura/ext/admin/widgets.py
@@ -236,7 +236,8 @@ 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")
+ field_type="text", label="Google Analytics ID",
+ attrs=(dict(placeholder='UA-123456-0', pattern='UA-[0-9]+-[0-9]+')))
twitter_handle = ew.InputField(
field_type="text", label='Twitter Handle')
facebook_page = ew.InputField(field_type="text", label='Facebook page',
http://git-wip-us.apache.org/repos/asf/allura/blob/6862652b/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 2c17aea..d436fff 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -813,7 +813,7 @@ class NeighborhoodOverviewForm(ForgeForm):
project_template = ffw.AutoResizeTextarea(
validator=V.JsonValidator(if_empty=''))
icon = ew.FileField(attrs={'accept': 'image/*'})
- tracking_id = ew.TextField()
+ tracking_id = ew.TextField(attrs=(dict(placeholder='UA-123456-0', pattern='UA-[0-9]+-[0-9]+')))
project_list_url = ew.TextField()
anchored_tools = ffw.AutoResizeTextarea()
prohibited_tools = ffw.AutoResizeTextarea()
http://git-wip-us.apache.org/repos/asf/allura/blob/6862652b/Allura/allura/templates/jinja_master/theme_macros.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/theme_macros.html b/Allura/allura/templates/jinja_master/theme_macros.html
index bb1f381..3b8e844 100644
--- a/Allura/allura/templates/jinja_master/theme_macros.html
+++ b/Allura/allura/templates/jinja_master/theme_macros.html
@@ -83,7 +83,7 @@ http://stackoverflow.com/questions/26582731/redefining-imported-jinja-macros
}
{%- for account in accounts %}
- _add_tracking('sfnt{{ loop.index }}', '{{account}}');
+ _add_tracking('acct{{ loop.index }}', '{{account}}');
{%- endfor %}
{% if project and project.neighborhood.features['google_analytics'] -%}
{% if project.neighborhood.tracking_id -%}
http://git-wip-us.apache.org/repos/asf/allura/blob/6862652b/Allura/allura/templates/widgets/neighborhood_overview_form.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/neighborhood_overview_form.html b/Allura/allura/templates/widgets/neighborhood_overview_form.html
index 936b5ab..9724ecb 100644
--- a/Allura/allura/templates/widgets/neighborhood_overview_form.html
+++ b/Allura/allura/templates/widgets/neighborhood_overview_form.html
@@ -55,7 +55,7 @@
{{widget.display_field(widget.fields.icon)}}
</div>
{% if neighborhood.features and neighborhood.features['google_analytics'] %}
- <label class="grid-4">Analytics Tracking ID</label>
+ <label class="grid-4">Google Analytics ID</label>
<div class="grid-14">{{widget.display_field(widget.fields.tracking_id)}}</div>
{% endif %}
<label class="grid-4">Project List URL</label>
http://git-wip-us.apache.org/repos/asf/allura/blob/6862652b/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index 81f2aee..55a492c 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -283,10 +283,10 @@ class TestNeighborhood(TestController):
neighborhood.features['google_analytics'] = True
r = self.app.get('/adobe/_admin/overview',
extra_environ=dict(username='root'))
- assert 'Analytics Tracking ID' in r
+ assert 'Google Analytics ID' in r
r = self.app.get('/adobe/adobe-1/admin/overview',
extra_environ=dict(username='root'))
- assert 'Analytics Tracking ID' in r
+ assert 'Google Analytics ID' in r
r = self.app.post('/adobe/_admin/update',
params=dict(name='Adobe', css='',
homepage='# MozQ1', tracking_id='U-123456'),
@@ -303,10 +303,10 @@ class TestNeighborhood(TestController):
neighborhood.features['google_analytics'] = False
r = self.app.get('/adobe/_admin/overview',
extra_environ=dict(username='root'))
- assert 'Analytics Tracking ID' not in r
+ assert 'Google Analytics ID' not in r
r = self.app.get('/adobe/adobe-1/admin/overview',
extra_environ=dict(username='root'))
- assert 'Analytics Tracking ID' not in r
+ assert 'Google Analytics ID' not in r
r = self.app.get('/adobe/adobe-1/admin/overview',
extra_environ=dict(username='root'))
assert "_add_tracking('nbhd', 'U-123456');" not in r