فهرست منبع

[core] Add switch for collection in the admin wizard

Collection is on when this checkbox is checked + collect_usage=true in hue.ini
Romain Rigaux 12 سال پیش
والد
کامیت
fd376b3
3فایلهای تغییر یافته به همراه26 افزوده شده و 1 حذف شده
  1. 17 0
      apps/about/src/about/templates/admin_wizard.mako
  2. 4 0
      apps/about/src/about/views.py
  3. 5 1
      desktop/core/src/desktop/views.py

+ 17 - 0
apps/about/src/about/templates/admin_wizard.mako

@@ -159,6 +159,23 @@ ${ header.menubar() }
                   </p>
                 </div>
               </div>
+
+          <div class="card card-home card-tab card-tab-bordertop card-listcontent">
+            <h2 class="card-heading simple">${ _('Anonymous usage analytics') }</h2>
+
+            <div class="card-body">
+              <label class="checkbox">
+                <input class="updatePreferences" type="checkbox" name="collect_usage" style="margin-right: 10px" title="${ ('Check to enable usage analytics') }" ${ collect_usage and "checked" }/>
+                ${ ('Help improve Hue with anonymous usage analytics.') }
+                <a href="javascript:void(0)" style="display: inline" data-trigger="hover" data-toggle="popover" data-placement="right" rel="popover"
+                   title="${_('How does it work?') }"
+                   data-content="${ ('We are using Google Analytics to see how many times an application or specific section of an application is used, nothing more.') }">
+                   <i class="fa fa-question-circle"></i>
+                </a>
+              </label>
+            </div>
+          </div>
+
             </div>
 
             <div id="step4" class="stepDetails hide">

+ 4 - 0
apps/about/src/about/views.py

@@ -25,6 +25,7 @@ from django.utils.translation import ugettext as _
 from desktop.lib.django_util import render
 from desktop.models import Settings
 from desktop import appmanager
+from desktop.views import collect_usage
 
 
 def admin_wizard(request):
@@ -38,6 +39,7 @@ def admin_wizard(request):
       'apps': dict([(app.name, app) for app in apps]),
       'app_names': app_names,
       'tours_and_tutorials': tours_and_tutorials,
+      'collect_usage': collect_usage(),
   })
 
 
@@ -48,9 +50,11 @@ def update_preferences(request):
     try:
       settings = Settings.get_settings()
       settings.tours_and_tutorials = request.POST.get('tours_and_tutorials', False)
+      settings.collect_usage = request.POST.get('collect_usage', False)
       settings.save()
       response['status'] = 0
       response['tours_and_tutorials'] = settings.tours_and_tutorials
+      response['collect_usage'] = settings.collect_usage
     except Exception, e:
       response['data'] = str(e)
   else:

+ 5 - 1
desktop/core/src/desktop/views.py

@@ -495,11 +495,15 @@ def commonfooter(messages=None):
   return django_mako.render_to_string("common_footer.mako", {
     'messages': messages,
     'version': settings.HUE_DESKTOP_VERSION,
-    'collect_usage': desktop.conf.COLLECT_USAGE.get(),
+    'collect_usage': collect_usage(),
     'tours_and_tutorials': hue_settings.tours_and_tutorials
   })
 
 
+def collect_usage():
+  return desktop.conf.COLLECT_USAGE.get() and Settings.get_settings().collect_usage
+
+
 # If the app's conf.py has a config_validator() method, call it.
 CONFIG_VALIDATOR = 'config_validator'