Skip to content

Commit

Permalink
Merge pull request #2537 from learningequality/release-0.12.0
Browse files Browse the repository at this point in the history
Release 0.12.8
  • Loading branch information
aronasorman committed Oct 27, 2014
2 parents c77cbf8 + 8c08d89 commit b973ba1
Show file tree
Hide file tree
Showing 17 changed files with 236 additions and 48 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*.pid
*.prof
*.pyc
*.pyo
*~
*.sublime-*
*.zip
build/
locale/
node_modules/
tmp/
Expand Down Expand Up @@ -44,4 +44,5 @@ writeup/
/TAGS
.tags
/kalite/i18n/static/
ghostdriver.log
ghostdriver.log
/kalite/_built.touch
11 changes: 11 additions & 0 deletions docs/DJANGO-CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,14 @@ index 2b8e801..6349ed5 100644
+
TestRunner = get_runner(settings, options.get('testrunner'))
options['verbosity'] = int(options.get('verbosity'))

We extend clean_pyc so it will be automatically skipped when built by the build process
def handle_noargs(self, **options):
+ from django.conf import settings
+ if settings.BUILT:
+ settings.LOG.info("Installation built by build process; skipping clean_pyc")
+ return
+
project_root = options.get("path", None)
if not project_root:
project_root = get_project_root()
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@
altField: "#start_standard_date",
altFormat: "yy-mm-dd",
autoclose: true,
changeMonth: true,
changeYear: true,
showButtonPanel: true
});

$('#end_date_select').datepicker({
dateFormat: "d MM yy",
altField: "#end_standard_date",
altFormat: "yy-mm-dd"
altFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
showButtonPanel: true
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,13 @@ <h2>{% trans "Devices" %}</br><small>{% trans "A device is a KA Lite installatio
</td>
<td>
{% if device.is_own_device %}
<button id="force-sync" class="btn btn-primary registered-only">{% trans "Sync Now!" %}</button>
<a class="btn btn-success not-registered-only" href="{% url 'register_public_key' %}">{% trans "Register device" %}</a>

{% if device.is_registered %}
<button id="force-sync" class="btn btn-primary">{% trans "Sync Now!" %}</button>
{% else %}
<a class="btn btn-success not-registered-only" href="{% url 'register_public_key' %}">{% trans "Register device" %}</a>
{% endif %}

{% if clock_set %}
/
<a onclick="$('#clock_set').show()">set clock</a>
Expand Down
18 changes: 7 additions & 11 deletions kalite/control_panel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ def group_report(request, facility, group_id=None, zone_id=None):
return context


@facility_required
@require_authorized_admin
@render_to_csv(["students", "coaches"], key_label="user_id", order="stacked")
@render_to_csv(["students"], key_label="user_id", order="stacked")
def facility_management_csv(request, facility, group_id=None, zone_id=None, frequency=None, period_start="", period_end="", user_type=None):
"""NOTE: THIS IS NOT A VIEW FUNCTION"""
assert request.method == "POST", "facility_management_csv must be accessed via POST"
Expand All @@ -227,7 +226,7 @@ def facility_management_csv(request, facility, group_id=None, zone_id=None, freq
if not form.is_valid():
raise Exception(_("Error parsing date range: %(error_msg)s. Please review and re-submit.") % form.errors.as_data())

frequency = frequency or request.GET.get("frequency", "months")
frequency = frequency or request.GET.get ("frequency", "months")
period_start = period_start or form.data["period_start"]
period_end = period_end or form.data["period_end"]
(period_start, period_end) = _get_date_range(frequency, period_start, period_end)
Expand All @@ -237,15 +236,15 @@ def facility_management_csv(request, facility, group_id=None, zone_id=None, freq
context = control_panel_context(request, zone_id=zone_id, facility_id=facility.id)
group = group_id and get_object_or_None(FacilityGroup, id=group_id)
groups = FacilityGroup.objects.filter(facility=context["facility"]).order_by("name")
coaches = get_users_from_group(user_type="coaches", group_id=group_id, facility=facility)
# coaches = get_users_from_group(user_type="coaches", group_id=group_id, facility=facility)
students = get_users_from_group(user_type="students", group_id=group_id, facility=facility)

(student_data, group_data) = _get_user_usage_data(students, groups, group_id=group_id, period_start=period_start, period_end=period_end)
(coach_data, coach_group_data) = _get_user_usage_data(coaches, period_start=period_start, period_end=period_end)
# (coach_data, coach_group_data) = _get_user_usage_data(coaches, period_start=period_start, period_end=period_end)

context.update({
"students": student_data, # raw data
"coaches": coach_data, # raw data
# "coaches": coach_data, # raw data
})
return context

Expand Down Expand Up @@ -378,10 +377,9 @@ def _get_user_usage_data(users, groups=None, period_start=None, period_end=None,
user_data = OrderedDict()
group_data = OrderedDict()


# Make queries efficiently
exercise_logs = ExerciseLog.objects.filter(user__in=users, complete=True)
video_logs = VideoLog.objects.filter(user__in=users)
video_logs = VideoLog.objects.filter(user__in=users, total_seconds_watched__gt=0)
login_logs = UserLogSummary.objects.filter(user__in=users)

# filter results
Expand All @@ -392,8 +390,7 @@ def _get_user_usage_data(users, groups=None, period_start=None, period_end=None,
if period_end:
exercise_logs = exercise_logs.filter(completion_timestamp__lte=period_end)
video_logs = video_logs.filter(completion_timestamp__lte=period_end)
login_logs = login_logs.filter(end_datetime__lte=period_end)

login_logs = login_logs.filter(total_seconds__gt=0, start_datetime__lte=period_end)

# Force results in a single query
exercise_logs = list(exercise_logs.values("exercise_id", "user__pk"))
Expand All @@ -408,7 +405,6 @@ def _get_user_usage_data(users, groups=None, period_start=None, period_end=None,
user_data[user.pk]["username"] = user.username
user_data[user.pk]["group"] = user.group


user_data[user.pk]["total_report_views"] = 0#report_stats["count__sum"] or 0
user_data[user.pk]["total_logins"] =0# login_stats["count__sum"] or 0
user_data[user.pk]["total_hours"] = 0#login_stats["total_seconds__sum"] or 0)/3600.
Expand Down
1 change: 1 addition & 0 deletions kalite/distributed/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def USER_FACING_PORT():
"fle_utils.config",
"fle_utils.chronograph",
"fle_utils.django_utils", # templatetags
"fle_utils.build",
"kalite.facility", # must come first, all other apps depend on this one.
"kalite.control_panel", # in both apps
"kalite.coachreports", # in both apps; reachable on central via control_panel
Expand Down
4 changes: 2 additions & 2 deletions kalite/main/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class VideoLogAdmin(admin.ModelAdmin):
admin.site.register(VideoLog, VideoLogAdmin)

class ExerciseLogAdmin(admin.ModelAdmin):
list_display = ("exercise_id", "user", "language", "streak_progress", "complete",)
list_filter = ("exercise_id", "user", "language", "complete",)
list_display = ("exercise_id", "user", "language", "streak_progress", "completion_timestamp", "complete",)
list_filter = ("completion_timestamp", "complete", "language", "exercise_id", "user",)
admin.site.register(ExerciseLog, ExerciseLogAdmin)

class UserLogAdmin(admin.ModelAdmin):
Expand Down
21 changes: 14 additions & 7 deletions kalite/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@
import sys
import warnings


def clean_pyc(PROJECT_PATH):
for root, dirs, files in os.walk(os.path.join(PROJECT_PATH, "..")):
for pyc_file in glob.glob(os.path.join(root, "*.py[oc]")):
try:
os.remove(pyc_file)
except:
pass

if __name__ == "__main__":
import warnings

BUILD_INDICATOR_FILE = os.path.join(".", "_built.touch")
BUILT = os.path.exists(BUILD_INDICATOR_FILE) # whether this installation was processed by the build server

# We are overriding a few packages (like Django) from the system path.
# Suppress those warnings
warnings.filterwarnings('ignore', message=r'Module .*? is being added to sys\.path', append=True)
Expand All @@ -20,7 +32,6 @@
]
sys.path = [os.path.realpath(p) for p in PROJECT_PYTHON_PATHS] + sys.path


########################
# kaserve
########################
Expand All @@ -41,12 +52,8 @@
########################

# Manually clean all pyc files before entering any real codepath
for root, dirs, files in os.walk(os.path.join(PROJECT_PATH, "..")):
for pyc_file in glob.glob(os.path.join(root, "*.pyc")):
try:
os.remove(pyc_file)
except:
pass
if not BUILT:
clean_pyc(PROJECT_PATH)


########################
Expand Down
16 changes: 11 additions & 5 deletions kalite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def package_selected(package_name):
##############################
# Basic setup
##############################

try:
from local_settings import *
import local_settings
Expand All @@ -29,7 +28,6 @@ def package_selected(package_name):

CENTRAL_SERVER = False # Hopefully will be removed soon.


##############################
# Basic setup of logging
##############################
Expand All @@ -51,6 +49,9 @@ def package_selected(package_name):
# Not really a Django setting, but we treat it like one--it's eeeeverywhere.
PROJECT_PATH = os.path.realpath(getattr(local_settings, "PROJECT_PATH", os.path.dirname(os.path.realpath(__file__)))) + "/"

BUILD_INDICATOR_FILE = os.path.join(PROJECT_PATH, "_built.touch")
BUILT = os.path.exists(BUILD_INDICATOR_FILE) # whether this installation was processed by the build server

LOCALE_PATHS = getattr(local_settings, "LOCALE_PATHS", (PROJECT_PATH + "/../locale",))
LOCALE_PATHS = tuple([os.path.realpath(lp) + "/" for lp in LOCALE_PATHS])

Expand Down Expand Up @@ -103,10 +104,15 @@ def package_selected(package_name):
"django.contrib.messages",
"django.contrib.sessions",
"django_extensions", # needed for clean_pyc (testing)
"fle_utils.testing",
"kalite.testing",
"kalite.distributed",
) + getattr(local_settings, 'INSTALLED_APPS', tuple())
)

if not BUILT:
INSTALLED_APPS += (
"fle_utils.testing",
"kalite.testing",
) + getattr(local_settings, 'INSTALLED_APPS', tuple())

MIDDLEWARE_CLASSES = (
"django.contrib.messages.middleware.MessageMiddleware", # needed for django admin
"django_snippets.session_timeout_middleware.SessionIdleTimeout",
Expand Down
2 changes: 1 addition & 1 deletion kalite/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"admins": [],
},
"bugs_fixed": {
"all": ["fix to handle multiple psutil versions", "fix to handle multiple psutil versions"],
"all": ["fix to handle multiple psutil versions", "use POST requests when deleting student groups"],
"students": [],
"coaches": [],
"admins": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class Command(NoArgsCommand):
requires_model_validation = False

def handle_noargs(self, **options):
from django.conf import settings
if settings.BUILT:
settings.LOG.info("Installation built by build process; skipping clean_pyc")
return

project_root = options.get("path", None)
if not project_root:
project_root = get_project_root()
Expand Down
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit b973ba1

Please sign in to comment.