Skip to content

Commit

Permalink
just stashing these changes so I don't lose them.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdreher committed Jul 19, 2014
1 parent 178829c commit ff48a78
Show file tree
Hide file tree
Showing 32 changed files with 941 additions and 1,683 deletions.
7 changes: 4 additions & 3 deletions docs/lettuce_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ Alternate Course
# Course: [Sample Course], Asset MAAP Award Reception [2]
# Primary: image
# Note test_student_two None
# Note test_student_two Nice Tie
# Note test_student_two Nice Tie, tags: u',student_two_selection'
# Note test_student_one None
# Note test_student_one The Award
# Note test_instructor Our esteemed leaders
# Note test_student_one The Award, tags: u',student_one_selection'
# Note test_instructor Our esteemed leaders,
tags: u',image, instructor_one_selection, '
# Note test_instructor None
# Course: [Sample Course], Asset The Armory - Home to CCNMTL'S CUMC Office [3]
# Primary: image
Expand Down
15 changes: 7 additions & 8 deletions media/jquery/js/jquery.masonry.min.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions media/js/app/assetmgr/assetpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var AssetPanelHandler = function (el, parent, panel, space_owner) {
});

jQuery(window).bind('asset.on_delete', { 'self': self },
function (event, asset_id) { event.data.self.onDeleteItem(asset_id); });
function (event, asset_id) {event.data.self.onDeleteItem(asset_id); });

jQuery(window).bind('asset.edit', { 'self': self }, self.dialog);
jQuery(window).bind('annotation.create', { 'self': self }, self.dialog);
Expand Down Expand Up @@ -96,8 +96,6 @@ var AssetPanelHandler = function (el, parent, panel, space_owner) {
} else {
jQuery('div.asset-table').css('height', '500px');
}

jQuery(window).trigger("resize");
}
});
}
Expand Down
17 changes: 9 additions & 8 deletions media/js/app/assetmgr/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ CollectionList.prototype.createAssetThumbs = function (assets) {

if (!asset.thumbable) {
if (jQuery(target_parent).hasClass("static-height")) {
if (asset.sources.hasOwnProperty("thumb") &&
asset.sources.thumb.hasOwnProperty("height") &&
asset.sources.thumb.height > 240) {
var thumbs = jQuery.grep(asset.sources, function(s) {
return s.label == 'thumb'; });
if (thumbs.length && thumbs[0].height > 240) {
jQuery(target_parent).css({
height: (asset.sources.thumb.height + 75) + 'px'
height: (thumbs[0].height + 75) + 'px'
});
} else {
jQuery(target_parent).css({height: '240px'});
Expand Down Expand Up @@ -304,7 +304,7 @@ CollectionList.prototype.createAssetThumbs = function (assets) {
asset.zoom = 1;

try {
view.html.push(obj_div, { asset: asset });
view.html.push(obj_div, {asset: asset});
view.setState(asset);
} catch (e) {
}
Expand Down Expand Up @@ -460,7 +460,7 @@ CollectionList.prototype.updateAssets = function (the_records) {
self.appendItems(self.current_records);
}
});
}
}

jQuery(elt).fadeIn("slow");

Expand Down Expand Up @@ -549,12 +549,13 @@ CollectionList.prototype.updateAssets = function (the_records) {
self.view_callback(the_records.assets.length);
}

jQuery(window).trigger("resize");

if (self.scrollTop) {
jQuery(self.el).find("div.collection-assets").scrollTop(self.scrollTop);
self.scrollTop = undefined;
}

jQuery(window).trigger("resize");

}
});
};
Expand Down
2 changes: 1 addition & 1 deletion media/js/app/mediathread_mustache.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
return '/comments/post/';
},
'tags': function () {
return '/_main/api/v1/tag/';
return '/tag/json/';
},
'references': function (asset) {
return '/asset/references/' + asset.id + '/';
Expand Down
41 changes: 5 additions & 36 deletions mediathread/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from courseaffils.lib import get_public_name
from django.contrib.auth.models import User, Group
from django.core.exceptions import ObjectDoesNotExist
from mediathread.djangosherd.models import SherdNote
from mediathread.main.course_details import all_selections_are_visible, \
cached_course_is_faculty
from tagging.models import Tag
Expand Down Expand Up @@ -219,15 +218,11 @@ def authorized_read_list(self, object_list, bundle):
return self.get_restricted(request, object_list, course)


class TagResource(RestrictedCourseResource):
def __init__(self, course=None):
super(TagResource, self).__init__(None)
self.filters = {}

class TagResource(ModelResource):
class Meta:
queryset = Tag.objects.none()
list_allowed_methods = ['get']
detail_allowed_methods = ['get']
list_allowed_methods = []
detail_allowed_methods = []
authentication = ClassLevelAuthentication()
limit = 1000
max_limit = 1000
Expand All @@ -238,30 +233,10 @@ def dehydrate(self, bundle):
bundle.data['last'] = hasattr(bundle.obj, "last")
return bundle

def _filter_tags(self, note_set):
if 'assets' in self.filters:
note_set = note_set.filter(asset__id__in=self.filters['assets'])
if 'record_owner' in self.filters:
note_set = note_set.filter(author=self.filters['record_owner'])

counts = 'counts' in self.filters
tags = Tag.objects.usage_for_queryset(note_set, counts=counts)
def render_related(self, request, object_list):
tags = Tag.objects.usage_for_queryset(object_list, counts=True)
tags.sort(lambda a, b: cmp(a.name.lower(), b.name.lower()))
return tags

def get_unrestricted(self, request, object_list, course):
notes = SherdNote.objects.filter(asset__course=course)
return self._filter_tags(notes)

def get_restricted(self, request, object_list, course):
whitelist = [f.id for f in course.faculty]
whitelist.append(request.user.id)

notes = SherdNote.objects.filter(asset__course=course,
author__id__in=whitelist)
return self._filter_tags(notes)

def render_list(self, request, tags):
tag_last = len(tags) - 1
data = []
for idx, tag in enumerate(tags):
Expand All @@ -272,9 +247,3 @@ def render_list(self, request, tags):
dehydrated = self.full_dehydrate(bundle)
data.append(dehydrated.data)
return data

def filter(self, request, filters):
self.filters = filters
base_bundle = self.build_bundle(request=request)
objects = self.obj_get_list(bundle=base_bundle)
return self.render_list(request, objects)
Loading

0 comments on commit ff48a78

Please sign in to comment.