A view containing most active discussions & users during a specific time
period. This gets ajaxed into the dashboard homepage as date ranges are
defined.
359408
public function SettingsController_DashboardSummaries_Create($Sender) {
      // Load javascript & css, check permissions, and load side menu for this page.
      $Sender->AddJsFile('settings.js');
      $Sender->Title(T('Dashboard Summaries'));
      $Sender->RequiredAdminPermissions[] = 'Garden.Settings.Manage';
      $Sender->RequiredAdminPermissions[] = 'Garden.Users.Add';
      $Sender->RequiredAdminPermissions[] = 'Garden.Users.Edit';
      $Sender->RequiredAdminPermissions[] = 'Garden.Users.Delete';
      $Sender->RequiredAdminPermissions[] = 'Garden.Users.Approve';
      $Sender->FireEvent('DefineAdminPermissions');
      $Sender->Permission($Sender->RequiredAdminPermissions, '', FALSE);
      $Sender->AddSideMenu('dashboard/settings');
      
      $this->ConfigureRange($Sender);

      // Load the most active discussions during this date range
      $UserModel = new UserModel();
      $Sender->SetData('DiscussionData', $UserModel->SQL
         ->Select('d.DiscussionID, d.Name, d.CountBookmarks, d.CountViews, d.CountComments')
         ->From('Discussion d')
         ->Where('d.DateLastComment >=', $Sender->DateStart)
         ->Where('d.DateLastComment <=', $Sender->DateEnd)
         ->OrderBy('d.CountViews', 'desc')
         ->OrderBy('d.CountComments', 'desc')
         ->OrderBy('d.CountBookmarks', 'desc')
         ->Limit(10, 0)
         ->Get()
      );
      
      // Load the most active users during this date range
      $Sender->SetData('UserData', $UserModel->SQL
         ->Select('u.UserID, u.Name')
         ->Select('c.CommentID', 'count', 'CountComments')
         ->From('User u')
         ->Join('Comment c', 'u.UserID = c.InsertUserID', 'inner')
         ->GroupBy('u.UserID, u.Name')
         ->Where('c.DateInserted >=', $Sender->DateStart)
         ->Where('c.DateInserted <=', $Sender->DateEnd)
         ->OrderBy('CountComments', 'desc')
         ->Limit(10, 0)
         ->Get()
      );
      
      // Render the custom dashboard view
      $Sender->Render('dashboardsummaries', '', 'plugins/VanillaStats');
   }
551977
function View(view, options) {
  this.history = [];
  Item.call(this, view, options);
  this.init(view);
  return view;
}
1252905
function GotoTimeView(options) {
  /**
   * Create the elements that make up the view.
   *
   * @returns {void}
   */
  var createViewElements = function () {
    this.node = blessed.box({
      position: {
        top: "center",
        left: "center",
        // using fixed numbers to support use of alignment tags
        width: 64,
        height: 12
      },
      border: "line",
      padding: {
        left: 1,
        right: 1
      },
      style: {
        border: {
          fg: "white"
        }
      },
      tags: true,
      hidden: true,
      label: " Goto Time "
    });

    this.form = blessed.form({
      name: "form",
      top: 0,
      left: 0,
      height: "100%-2",
      width: "100%-4",
      keys: true
    });

    this.timeRangeLabel = blessed.text({
      top: 1,
      align: "center",
      width: "100%",
      content: this.getTimeRangeLabel()
    });

    this.textBox = blessed.textbox({
      name: "textBox",
      input: true,
      inputOnFocus: true,
      top: 3,
      left: 0,
      height: 1,
      width: "100%",
      style: {
        fg: "white",
        bg: "black",
        focus: {
          fg: "yellow"
        },
        underline: true
      },
      keys: true,
      content: ""
    });

    this.errorText = blessed.text({
      top: 5,
      align: "center",
      width: "100%",
      height: 1,
      content: "",
      style: {
        fg: "red"
      },
      hidden: true
    });

    this.acceptButton = blessed.button({
      top: "100%-3",
      height: 3,
      width: "half",
      name: "accept",
      content: "Accept",
      align: "center",
      style: {
        focus: {
          bg: "green",
          fg: "black"
        },
        border: {
          fg: "green"
        },
        fg: "green"
      },
      border: {
        type: "line"
      }
    });

    this.cancelButton = blessed.button({
      left: "50%",
      top: "100%-3",
      height: 3,
      width: "half",
      name: "cancel",
      content: "Cancel",
      align: "center",
      style: {
        focus: {
          bg: "red",
          fg: "black"
        },
        fg: "red",
        border: {
          fg: "red"
        }
      },
      border: {
        type: "line"
      }
    });
  }.bind(this);

  /**
   * Construct the view now that the elements have been created.
   *
   * @returns {void}
   */
  var constructView = function () {
    options.parent.append(this.node);

    this.node.append(this.form);
    this.form.append(this.timeRangeLabel);
    this.form.append(this.textBox);
    this.form.append(this.errorText);
    this.form.append(this.acceptButton);
    this.form.append(this.cancelButton);
  }.bind(this);

  /**
   * Setup all event handlers for the screen to flow.
   *
   * @returns {void}
   */
  var setupEventHandlers = function () {
    this.screen.on("metrics", function () {
      // dynamically change the range as the underlying data grows
      this.timeRangeLabel.setContent(this.getTimeRangeLabel());
    }.bind(this));

    this.node.on("show", function () {
      this.screen.saveFocus();
      this.node.setFront();
      this.form.reset();
      this.textBox.focus();
    }.bind(this));

    this.form.on("reset", function () {
      this.errorText.hide();
    }.bind(this));

    this.textBox.key("enter", function () {
      this.acceptButton.press();
    }.bind(this));

    this.textBox.key("escape", function () {
      this.cancelButton.press();
    }.bind(this));

    this.acceptButton.key("escape", function () {
      this.cancelButton.press();
    }.bind(this));

    this.acceptButton.on("press", function () {
      this.form.submit();
    }.bind(this));

    this.cancelButton.key("escape", function () {
      this.cancelButton.press();
    }.bind(this));

    this.cancelButton.on("press", function () {
      this.form.cancel();
    }.bind(this));

    this.form.on("submit", function (data) {
      if (this.errorTimeout) {
        clearTimeout(this.errorTimeout);
        delete this.errorTimeout;
      }

      try {
        var timeValue = this.validate(data);
        this.metricsProvider.gotoTimeValue(timeValue);
        this.hide();
      } catch (e) {
        this.errorText.setContent(e.message);
        this.errorText.show();
        this.textBox.focus();
        this.screen.render();

        this.errorTimeout = setTimeout(function () {
          this.errorText.hide();
          this.screen.render();
        }.bind(this), ERROR_TEXT_DISPLAY_TIME);
      }
    }.bind(this));

    this.form.on("cancel", function () {
      this.hide();
    }.bind(this));
  }.bind(this);

  // capture options
  this.metricsProvider = options.metricsProvider;
  this.parent = options.parent;
  this.screen = options.screen;

  // build the view
  createViewElements();
  constructView();
  setupEventHandlers();
}
1326685
protected void onDateClicked(final DayView dayView) {
    final CalendarDay currentDate = getCurrentDate();
    final CalendarDay selectedDate = dayView.getDate();
    final int currentMonth = currentDate.getMonth();
    final int selectedMonth = selectedDate.getMonth();

    if (calendarMode == CalendarMode.MONTHS
        && allowClickDaysOutsideCurrentMonth
        && currentMonth != selectedMonth) {
      if (currentDate.isAfter(selectedDate)) {
        goToPrevious();
      } else if (currentDate.isBefore(selectedDate)) {
        goToNext();
      }
    }
    onDateClicked(dayView.getDate(), !dayView.isChecked());
  }
449090
public function timed_discussion_tooltip($discussion, $visiblenow) {
        $dates = array();
        if ($discussion->timestart) {
            $dates[] = get_string('displaystart', 'mod_forum').': '.userdate($discussion->timestart);
        }
        if ($discussion->timeend) {
            $dates[] = get_string('displayend', 'mod_forum').': '.userdate($discussion->timeend);
        }

        $str = $visiblenow ? 'timedvisible' : 'timedhidden';
        $dates[] = get_string($str, 'mod_forum');

        $tooltip = implode("\n", $dates);
        return $this->pix_icon('i/calendar', $tooltip, 'moodle', array('class' => 'smallicon timedpost'));
    }
86439
def semester_view(request, semester, profile=None):
    
    template_dict = {}
    template_dict["page_name"] = "Workshift for {} {}".format(
        semester.get_season_display(),
        semester.year,
    )

    today = localtime(now()).date()
    template_dict["semester_percentage"] = int(
        (today - semester.start_date).days /
        (semester.end_date - semester.start_date).days * 100
    )

    # We want a form for verification, a notification of upcoming shifts, and a
    # chart displaying the entire house's workshift for the day as well as
    # weekly shifts.
    #
    # The chart should have left and right arrows on the sides to switch the
    # day, with a dropdown menu to select the day from a calendar. Ideally,
    # switching days should use AJAX to appear more seemless to users.

    # Recent History
    day = _get_date(request, "day", today)
    start_date = _get_date(request, "start_date", day)
    end_date = _get_date(request, "end_date", day)

    template_dict["day"] = day
    template_dict["start_date"] = start_date
    template_dict["end_date"] = end_date
    template_dict["long_range"] = (end_date - start_date).days > 7

    if day > semester.start_date:
        template_dict["prev_day"] = (start_date - timedelta(days=1)).strftime("%Y-%m-%d")
    if day < semester.end_date:
        template_dict["next_day"] = (end_date + timedelta(days=1)).strftime("%Y-%m-%d")

    if Semester.objects.count() > 1:
        switch_form = SwitchSemesterForm(
            data=request.POST if "switch_semester" in request.POST else None
        )
        template_dict["switch_form"] = switch_form

        if switch_form.is_valid():
            semester = switch_form.save()
            return HttpResponseRedirect(semester.get_view_url())

    # Grab the shifts for just today, as well as week-long shifts
    day_shifts = WorkshiftInstance.objects.filter(
        date__gte=start_date,
        date__lte=end_date,
    ).exclude(
        Q(weekly_workshift__week_long=True) |
        Q(info__week_long=True),
    )

    last_monday = start_date - timedelta(days=start_date.weekday())
    next_sunday = end_date - timedelta(days=end_date.weekday() + 1) + timedelta(weeks=1)

    week_shifts = WorkshiftInstance.objects.filter(
        Q(weekly_workshift__week_long=True) |
        Q(info__week_long=True),
        date__gte=last_monday, date__lte=next_sunday,
    )

    template_dict["last_monday"] = last_monday.strftime("%Y-%m-%d")
    template_dict["next_sunday"] = next_sunday.strftime("%Y-%m-%d")

    # Add a login form for anonymous user
    if profile is None and request.user.username == ANONYMOUS_USERNAME:
        anonymous_form = AnonymousUserLogin(
            data=request.POST or None,
            prefix="anon",
            semester=semester,
        )

        if anonymous_form.is_valid():
            profile = anonymous_form.save()

        template_dict["anonymous_form"] = anonymous_form

    template_dict["day_shifts"] = [
        (shift, _get_forms(
            profile, shift, request,
            undo=utils.can_manage(request.user, semester=semester, pool=shift.pool),
        ))
        for shift in day_shifts
    ]
    template_dict["week_shifts"] = [
        (shift, _get_forms(
            profile, shift, request,
            undo=utils.can_manage(request.user, semester=semester, pool=shift.pool),
        ))
        for shift in week_shifts
    ]

    # Save any forms that were submitted
    all_forms = [
        form
        for instance, forms in template_dict["day_shifts"]
        for form in forms
    ] + [
        form
        for instance, forms in template_dict["week_shifts"]
        for form in forms
    ]
    for form in all_forms:
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(
                semester.get_view_url() + _get_date_params(request)
            )
        else:
            for error in form.errors.values():
                messages.add_message(request, messages.ERROR, error)

    return render_to_response(
        "semester.html",
        template_dict,
        context_instance=RequestContext(request),
    )
968219
function Analytics() {
  this._options({});
  this.Integrations = {};
  this._integrations = {};
  this._readied = false;
  this._timeout = 300;
  // XXX: BACKWARDS COMPATIBILITY
  this._user = user;
  this.log = debug('analytics.js');
  bindAll(this);

  var self = this;
  this.on('initialize', function(settings, options) {
    if (options.initialPageview) self.page();
    self._parseQuery(window.location.search);
  });
}
328280
def _effective_view_filter(self):
        """"""
        if self._effective_view == EFFECTIVE:
            now = datetime.datetime.utcnow()
            return {'startDate': {'$$lte': now}, 'endDate': {'$$gte': now}}
        return {}
979319
def user_view_prj(self, ):
        
        i = self.user_prj_tablev.currentIndex()
        item = i.internalPointer()
        if item:
            prj = item.internal_data()
            self.view_prj(prj)
691902
def filter_by_analysis_period(self, analysis_period):
        
        _filtered_data = self.filter_by_months_per_hour(
            analysis_period.months_per_hour)
        _filtered_data.header._analysis_period = analysis_period
        return _filtered_data
940648
public function showAddSchedule()
    {
        $incidentTemplates = IncidentTemplate::all();

        return View::make('dashboard.maintenance.add')
            ->withPageTitle(trans('dashboard.schedule.add.title').' - '.trans('dashboard.dashboard'))
            ->withIncidentTemplates($incidentTemplates);
    }
578392
public function &daterange_display()
    {

        $text = "";
        $this->range_start = $this->range_end = "";

        if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("MANUAL_" . $this->query_name . "_FROMDATE", $_REQUEST)) {

            $this->range_start = $_REQUEST["MANUAL_" . $this->query_name . "_FROMDATE"];
            $this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
        } else
        if (!array_key_exists("clearform", $_REQUEST) && array_key_exists("HIDDEN_" . $this->query_name . "_FROMDATE", $_REQUEST)) {
            $this->range_start = $_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"];
            $this->range_start = $this->collateRequestDate($this->query_name, "FROMDATE", $this->range_start, ReporticoApp::getConfig("prep_dateformat"));
        } else {
            // User reset form or first time in, set defaults and clear existing form info
            if (count($this->defaults) == 0) {
                $this->defaults[0] = "TODAY-TODAY";
            }

            if ($this->defaults[0]) {
                if (!ReporticoLocale::convertDateRangeDefaultsToDates("DATERANGE", $this->defaults[0], $this->range_start, $this->range_end)) {
                    trigger_error("Date default '" . $this->defaults[0] . "' is not a valid date range. Should be 2 values separated by '-'. Each one should be in date format (e.g. yyyy-mm-dd, dd/mm/yyyy) or a date type (TODAY, TOMMORROW etc", E_USER_ERROR);
                }

                unset($_REQUEST["MANUAL_" . $this->query_name . "_FROMDATE"]);
                unset($_REQUEST["MANUAL_" . $this->query_name . "_TODATE"]);
                unset($_REQUEST["HIDDEN_" . $this->query_name . "_FROMDATE"]);
                unset($_REQUEST["HIDDEN_" . $this->query_name . "_TODATE"]);
            }
        }

        if (!$this->range_start) {
            $this->range_end = "TODAY";
        }

        $this->range_start = ReporticoLocale::parseDate($this->range_start, false, ReporticoApp::getConfig("prep_dateformat"));
        $text .= $this->formatDateValue($this->query_name . '_FROMDATE', $this->range_start, ReporticoApp::getConfig("prep_dateformat"));

        $text .= "&nbsp;- ";

        if (array_key_exists("MANUAL_" . $this->query_name . "_TODATE", $_REQUEST)) {
            $this->range_end = $_REQUEST["MANUAL_" . $this->query_name . "_TODATE"];
            $this->range_end = $this->collateRequestDate($this->query_name, "TODATE", $this->range_end, ReporticoApp::getConfig("prep_dateformat"));
        } else if (array_key_exists("HIDDEN_" . $this->query_name . "_TODATE", $_REQUEST)) {
            $this->range_end = $_REQUEST["HIDDEN_" . $this->query_name . "_TODATE"];
            $this->range_end = $this->collateRequestDate($this->query_name, "TODATE", $this->range_end, ReporticoApp::getConfig("prep_dateformat"));
        }

        if (!$this->range_end) {
            $this->range_end = "TODAY";
        }

        $this->range_end = ReporticoLocale::parseDate($this->range_end, false, ReporticoApp::getConfig("prep_dateformat"));
        $text .= $this->formatDateValue($this->query_name . '_TODATE', $this->range_end, ReporticoApp::getConfig("prep_dateformat"));
        return $text;
    }
848657
def discussion_is_still_open(self, discussion_type, auto_close_after):
        
        discussion_enabled = getattr(self, discussion_type)
        if (discussion_enabled and isinstance(auto_close_after, int) and
                auto_close_after >= 0):
            return (timezone.now() - (
                self.start_publication or self.publication_date)).days < \
                auto_close_after
        return discussion_enabled
117856
def today_view(request, template='swingtime/daily_view.html', **params):
    '''
    

    '''
    return _datetime_view(request, template, datetime.now(), **params)
1047325
def daterange(self, datecol, date_start, op, **args):
        
        df = self._daterange(datecol, date_start, op, **args)
        if df is None:
            self.err("Can not select date range data")
        self.df = df
849526
function(visualData) {

            var insightsList = 
'<li class="list-group-item">The site served' +
'  <strong>' + visualData.total[0] + '</strong> total pageviews on' +
'  <strong>' + visualData.total[1] + '</strong> pages of' +
'  <strong>' + visualData.total[2] + '</strong> sites' +
'</li>' +
// the first group
'<li class="list-group-item">The No. 1 group is <strong>' +
  visualData.groupsPageviews[0][0] + '</strong>, which has <strong>' +
  visualData.groupsPageviews[0][1] + '</strong> pageviews' +
'</li>' +
// the most viewed single page
'<li class="list-group-item">The most views single page is <strong>' +
  visualData.jsonData[0][0] + '</strong>, which has <strong>' +
  visualData.jsonData[0][2] + '</strong> pageviews' +
'</li>';

            $('#' + visualData.getId('insightsList')).html(insightsList);
        }
515421
def status(ctx, date, f, pushed):
    
    try:
        timesheet_collection = get_timesheet_collection_for_context(ctx, f)
    except ParseError as e:
        ctx.obj['view'].err(e)
    else:
        ctx.obj['view'].show_status(
            timesheet_collection.entries.filter(
                date, regroup=ctx.obj['settings']['regroup_entries'],
                pushed=False if not pushed else None
            )
        )