Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
removed course_selection/bower_components wrapper
Browse files Browse the repository at this point in the history
now bower_components live in /static/bower_components
  • Loading branch information
dxue2012 committed Aug 27, 2015
1 parent d7bce22 commit 585cc09
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .bowerrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"directory" : "course_selection/static/course_selection/bower_components"
"directory" : "course_selection/static/bower_components"
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ course_selection/static/node_modules/*
staticfiles
*.swp
.env
course_selection/static/course_selection/bower_components
course_selection/static/bower_components
42 changes: 6 additions & 36 deletions course_selection/api.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from django.conf.urls import patterns, include, url
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from tastypie.resources import ModelResource
from tastypie.constants import ALL, ALL_WITH_RELATIONS
from tastypie.utils import trailing_slash
from tastypie.cache import SimpleCache
from tastypie.cache import NoCache
from tastypie.authorization import Authorization, ReadOnlyAuthorization
from tastypie.exceptions import Unauthorized
from tastypie.http import HttpGone
from tastypie import fields
from course_selection.models import *


class UserAuthorization(Authorization):
def read_list(self, object_list, bundle):
# This assumes a ``QuerySet`` from ``ModelResource``.
Expand All @@ -20,8 +17,6 @@ def read_list(self, object_list, bundle):
else:
raise Unauthorized("Sorry, no peeking!")

#return object_list.filter(user=bundle.request.user)

def read_detail(self, object_list, bundle):
# Is the requested object owned by the user?
if bundle.obj.netid == bundle.request.user.username:
Expand All @@ -35,20 +30,10 @@ def create_list(self, object_list, bundle):

def create_detail(self, object_list, bundle):
return bundle.obj.netid == bundle.request.user.username
#return bundle.obj.user == bundle.request.user

def update_list(self, object_list, bundle):
return [obj for obj in object_list if obj.netid == bundle.request.user.username]

#allowed = []

## Since they may not all be saved, iterate over them.
#for obj in object_list:
# if obj.user == bundle.request.user:
# allowed.append(obj)

#return allowed

def update_detail(self, object_list, bundle):
return bundle.obj.netid == bundle.request.user.username

Expand All @@ -59,10 +44,10 @@ def delete_list(self, object_list, bundle):
def delete_detail(self, object_list, bundle):
raise Unauthorized("Sorry, no deletes.")


# you can only use it if you own this object
class UserObjectsOnlyAuthorization(Authorization):
def read_list(self, object_list, bundle):
#return object_list
filtered = [obj for obj in object_list if obj.user.netid == bundle.request.user.username]
return filtered

Expand All @@ -78,37 +63,22 @@ def create_list(self, object_list, bundle):
return [obj for obj in object_list if obj.user.netid == bundle.request.user.username]

def create_detail(self, object_list, bundle):
#return True
return bundle.obj.user.netid == bundle.request.user.username
#return bundle.obj.user == bundle.request.user

def update_list(self, object_list, bundle):
#return object_list
return [obj for obj in object_list if obj.user.netid == bundle.request.user.username]

#allowed = []

## Since they may not all be saved, iterate over them.
#for obj in object_list:
# if obj.user == bundle.request.user:
# allowed.append(obj)

#return allowed

def update_detail(self, object_list, bundle):
#return True
return bundle.obj.user.netid == bundle.request.user.username

def delete_list(self, object_list, bundle):
# Sorry user, no deletes for you!
raise Unauthorized("Sorry, no deleting lists.")
#return [obj for obj in object_list if obj.user.netid == bundle.request.user.username]
#return object_list
# return [obj for obj in object_list if obj.user.netid == bundle.request.user.username]
# return object_list

def delete_detail(self, object_list, bundle):
#return True
return bundle.obj.user.netid == bundle.request.user.username
#raise Unauthorized("Sorry, no deletes.")

# you can see the objects if a) you are the owner OR b) you and the owner are friends
# currently this should apply to schedules
Expand Down Expand Up @@ -163,8 +133,8 @@ def dehydrate(self, bundle):

def prepend_urls(self):
return [
#url(r"^(?P<resource_name>%s)/(?P<term_code>[\w\d_.-]+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
#url(r"^(?P<resource_name>%s)/(?P<term_code>[\w\d_.-]+)/course%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('get_course'), name="api_get_course"),
# url(r"^(?P<resource_name>%s)/(?P<term_code>[\w\d_.-]+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
# url(r"^(?P<resource_name>%s)/(?P<term_code>[\w\d_.-]+)/course%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('get_course'), name="api_get_course"),
]

#def get_course(self, request, **kwargs):
Expand Down
151 changes: 69 additions & 82 deletions course_selection/static/js/config.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,69 @@
/// <reference path="../ts/typings/tsd.d.ts" />
function staticPath(path) {
return '../' + path;
}
function bowerPath(path) {
return staticPath('course_selection/bower_components/' + path);
}
require.config({
paths: {
/* this is flatstrap */
'flatstrap': bowerPath('flatstrap/dist/js/flatstrap.min'),
'fullcalendar': bowerPath('fullcalendar/dist/fullcalendar.min'),
'jquery': bowerPath('jquery/jquery.min'),
'jquery.cookie': bowerPath('jquery.cookie/jquery.cookie'),
'jqueryui': bowerPath('jquery-ui/jquery-ui.min'),
'moment': bowerPath('moment/min/moment.min'),
'moment-timezone': bowerPath('moment-timezone/builds/moment-timezone-with-data'),
'angular': bowerPath('angular/angular'),
'angular-animate': bowerPath('angular-animate/angular-animate.min'),
'angular-resource': bowerPath('angular-resource/angular-resource.min'),
// 'angular-ui-calendar': bowerPath('angular-ui-calendar/src/calendar'),
'angular-bootstrap': bowerPath('angular-bootstrap/ui-bootstrap-tpls.min'),
'angular-local-storage': bowerPath('angular-local-storage/dist/angular-local-storage.min'),
'angular-aria': bowerPath('angular-aria/angular-aria.min'),
'angular-material': bowerPath('angular-material/angular-material.min'),
'angular-hotkeys': bowerPath('angular-hotkeys/build/hotkeys.min'),
'angular-loading-bar': bowerPath('angular-loading-bar/build/loading-bar'),
'qtip': bowerPath('qtip2/jquery.qtip.min'),
/* 'chai': bowerPath('chai/chai'), */
'text': bowerPath('requirejs-text/text')
},
shim: {
'flatstrap': ['jquery'],
'fullcalendar': ['jqueryui'],
'angular': { exports: 'angular', dep: ['jquery'] },
'angular-animate': ['angular'],
'angular-aria': ['angular'],
'angular-material': ['angular'],
'angular-resource': ['angular'],
// 'angular-ui-calendar': ['angular'],
'angular-bootstrap': ['angular'],
'angularRoute': ['angular'],
'angular-hotkeys': ['angular'],
'angular-local-storage': ['angular'],
'angular-loading-bar': ['angular'],
},
priority: [
"angular"
]
});
require(['angular',
'angular-animate',
'angular-local-storage',
'angular-hotkeys',
'angular-aria',
'angular-material',
'angular-loading-bar',
'angular-resource',
'moment',
/* 'chai', */
'fullcalendar',
// 'angular-ui-calendar',
'angular-bootstrap',
'Application',
'controllers/Controllers',
'filters/Filters',
'services/Services',
'directives/Directives',
'jquery',
'qtip',
'flatstrap'
], function (angular) {
angular.bootstrap(document, ['nice']);
});
// TypeScript declarations useful for importing angular modules
/*
declare module 'angular' {
var angular: ng.IAngularStatic;
export = angular;
}
*/
//# sourceMappingURL=config.js.map
/// <reference path="../ts/typings/tsd.d.ts" />
function staticPath(path) {
return "/static/" + path;
}
function appPath(path) {
return "../js/" + path;
}
require.config({
baseUrl: staticPath("bower_components/"),
paths: {
'flatstrap': 'flatstrap/dist/js/flatstrap.min',
'fullcalendar': 'fullcalendar/dist/fullcalendar.min',
'jquery': 'jquery/jquery.min',
'jquery.cookie': 'jquery.cookie/jquery.cookie',
'jqueryui': 'jquery-ui/jquery-ui.min',
'moment': 'moment/min/moment.min',
'moment-timezone': 'moment-timezone/builds/moment-timezone-with-data',
'angular': 'angular/angular',
'angular-animate': 'angular-animate/angular-animate.min',
'angular-resource': 'angular-resource/angular-resource.min',
'angular-bootstrap': 'angular-bootstrap/ui-bootstrap-tpls.min',
'angular-local-storage': 'angular-local-storage/dist/angular-local-storage.min',
'angular-aria': 'angular-aria/angular-aria.min',
'angular-material': 'angular-material/angular-material.min',
'angular-hotkeys': 'angular-hotkeys/build/hotkeys.min',
'angular-loading-bar': 'angular-loading-bar/build/loading-bar',
'qtip': 'qtip2/jquery.qtip.min',
'text': 'requirejs-text/text'
},
shim: {
'flatstrap': ['jquery'],
'fullcalendar': ['jqueryui'],
'angular': { exports: 'angular', dep: ['jquery'] },
'angular-animate': ['angular'],
'angular-aria': ['angular'],
'angular-material': ['angular'],
'angular-resource': ['angular'],
'angular-bootstrap': ['angular'],
'angularRoute': ['angular'],
'angular-hotkeys': ['angular'],
'angular-local-storage': ['angular'],
'angular-loading-bar': ['angular'],
},
priority: [
"angular"
]
});
require(['angular',
'angular-animate',
'angular-local-storage',
'angular-hotkeys',
'angular-aria',
'angular-material',
'angular-loading-bar',
'angular-resource',
'moment',
'fullcalendar',
'angular-bootstrap',
appPath('Application'),
appPath('controllers/Controllers'),
appPath('filters/Filters'),
appPath('services/Services'),
appPath('directives/Directives'),
'jquery',
'qtip',
'flatstrap'
], function (angular) {
angular.bootstrap(document, ['nice']);
});
69 changes: 30 additions & 39 deletions course_selection/static/js/config.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
/// <reference path="../ts/typings/tsd.d.ts" />

function staticPath(path: String): String
{
return '../' + path;
function staticPath(path: string) {
return "/static/" + path;
}

function bowerPath(path: String): String
{
return staticPath('course_selection/bower_components/' + path);
function appPath(path: string) {
return "../js/" + path;
}

require.config({
baseUrl: staticPath("bower_components/"),
paths: {
/* this is flatstrap */
'flatstrap': bowerPath('flatstrap/dist/js/flatstrap.min'),
'fullcalendar': bowerPath('fullcalendar/dist/fullcalendar.min'),
'jquery': bowerPath('jquery/jquery.min'),
'jquery.cookie': bowerPath('jquery.cookie/jquery.cookie'),
'jqueryui': bowerPath('jquery-ui/jquery-ui.min'),
'moment': bowerPath('moment/min/moment.min'),
'moment-timezone': bowerPath('moment-timezone/builds/moment-timezone-with-data'),
'angular': bowerPath('angular/angular'),
'angular-animate': bowerPath('angular-animate/angular-animate.min'),
'angular-resource': bowerPath('angular-resource/angular-resource.min'),
// 'angular-ui-calendar': bowerPath('angular-ui-calendar/src/calendar'),
'angular-bootstrap': bowerPath('angular-bootstrap/ui-bootstrap-tpls.min'),
'angular-local-storage': bowerPath('angular-local-storage/dist/angular-local-storage.min'),
'angular-aria': bowerPath('angular-aria/angular-aria.min'),
'angular-material': bowerPath('angular-material/angular-material.min'),
'angular-hotkeys': bowerPath('angular-hotkeys/build/hotkeys.min'),
'angular-loading-bar': bowerPath('angular-loading-bar/build/loading-bar'),
'qtip': bowerPath('qtip2/jquery.qtip.min'),
/* 'chai': bowerPath('chai/chai'), */
'text': bowerPath('requirejs-text/text')
'flatstrap': 'flatstrap/dist/js/flatstrap.min',
'fullcalendar': 'fullcalendar/dist/fullcalendar.min',
'jquery': 'jquery/jquery.min',
'jquery.cookie': 'jquery.cookie/jquery.cookie',
'jqueryui': 'jquery-ui/jquery-ui.min',
'moment': 'moment/min/moment.min',
'moment-timezone': 'moment-timezone/builds/moment-timezone-with-data',
'angular': 'angular/angular',
'angular-animate': 'angular-animate/angular-animate.min',
'angular-resource': 'angular-resource/angular-resource.min',
// 'angular-ui-calendar': 'angular-ui-calendar/src/calendar',
'angular-bootstrap': 'angular-bootstrap/ui-bootstrap-tpls.min',
'angular-local-storage': 'angular-local-storage/dist/angular-local-storage.min',
'angular-aria': 'angular-aria/angular-aria.min',
'angular-material': 'angular-material/angular-material.min',
'angular-hotkeys': 'angular-hotkeys/build/hotkeys.min',
'angular-loading-bar': 'angular-loading-bar/build/loading-bar',
'qtip': 'qtip2/jquery.qtip.min',
/* 'chai': 'chai/chai', */
'text': 'requirejs-text/text'
},
shim: {
'flatstrap': ['jquery'],
Expand Down Expand Up @@ -68,22 +67,14 @@ require(['angular',
'fullcalendar',
// 'angular-ui-calendar',
'angular-bootstrap',
'Application',
'controllers/Controllers',
'filters/Filters',
'services/Services',
'directives/Directives',
appPath('Application'),
appPath('controllers/Controllers'),
appPath('filters/Filters'),
appPath('services/Services'),
appPath('directives/Directives'),
'jquery',
'qtip',
'flatstrap'
], function (angular) {
angular.bootstrap(document, ['nice']);
});

// TypeScript declarations useful for importing angular modules
/*
declare module 'angular' {
var angular: ng.IAngularStatic;
export = angular;
}
*/
16 changes: 8 additions & 8 deletions course_selection/templates/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

{% block link_or_script_blocking %}
<meta name="apple-itunes-app" content="app-id=946948041, app-argument=recalCourseSelection://launch">
<link rel="stylesheet" href="{% static 'course_selection/bower_components/jquery-ui/themes/ui-lightness/jquery-ui.min.css' %}">
<link rel="stylesheet" href="{% static 'course_selection/bower_components/fontawesome/css/font-awesome.min.css' %}">
<link rel="stylesheet" href="{% static 'course_selection/bower_components/fullcalendar/dist/fullcalendar.min.css' %}">
<link rel="stylesheet" href="{% static 'course_selection/bower_components/angular-loading-bar/build/loading-bar.css' %}">
<link rel="stylesheet" href="{% static 'course_selection/bower_components/qtip2/jquery.qtip.min.css' %}">
<link id="theme_css" rel="stylesheet" href="{% static 'course_selection/bower_components/flatstrap/dist/css/flatstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'bower_components/jquery-ui/themes/ui-lightness/jquery-ui.min.css' %}">
<link rel="stylesheet" href="{% static 'bower_components/fontawesome/css/font-awesome.min.css' %}">
<link rel="stylesheet" href="{% static 'bower_components/fullcalendar/dist/fullcalendar.min.css' %}">
<link rel="stylesheet" href="{% static 'bower_components/angular-loading-bar/build/loading-bar.css' %}">
<link rel="stylesheet" href="{% static 'bower_components/qtip2/jquery.qtip.min.css' %}">
<link id="theme_css" rel="stylesheet" href="{% static 'bower_components/flatstrap/dist/css/flatstrap.min.css' %}">
<!-- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> -->
<link rel="stylesheet" href="{% static 'course_selection/bower_components/angular-material/angular-material.min.css' %}">
<link rel="stylesheet" href="{% static 'bower_components/angular-material/angular-material.min.css' %}">
<link rel="stylesheet" href="{% static 'less/main.css' %}">
{% endblock %}

{% block link_or_script_nonblocking %}
<script src="{% static 'course_selection/bower_components/requirejs/require.js' %}" data-main="{% static 'js/config.js' %}"></script>
<script src="{% static 'bower_components/requirejs/require.js' %}" data-main="{% static 'js/config.js' %}"></script>
{% endblock %}

0 comments on commit 585cc09

Please sign in to comment.