Commit 2df64f79 authored by Renfred Harper's avatar Renfred Harper

Add semester views options

parent b60fbc38
......@@ -42,6 +42,14 @@ class RequirementAdmin(admin.ModelAdmin):
filter_horizontal = ('courses',)
class TrajectoryAdmin(admin.ModelAdmin):
pass
class SemesterAdmin(admin.ModelAdmin):
pass
admin.site.register(Student, StudentAdmin)
admin.site.register(Course, CourseAdmin)
admin.site.register(CourseGroup, CourseGroupAdmin)
......@@ -50,4 +58,6 @@ admin.site.register(Minor, MinorAdmin)
admin.site.register(GenEd, GenEdAdmin)
admin.site.register(Concentration, ConcentrationAdmin)
admin.site.register(Requirement, RequirementAdmin)
admin.site.register(Trajectory, TrajectoryAdmin)
admin.site.register(Semester, SemesterAdmin)
admin.site.unregister(Group)
var advisor = advisor || {};
$(function () {
advisor.Programs = new advisor.ProgramCollection();
var p = new advisor.Program({id: 3});
advisor.Programs.reset([p]);
(new advisor.ProgramCollectionView())
var t = new advisor.Trajectory({id: 1});
t.fetch({
success: function() {
t.fetchRelated('semesters', {
success: function() {
advisor.Semesters = t.get('semesters');
new advisor.SemesterCollectionView();
}
});
}
});
});
advisor.SemesterCollection = Backbone.Collection.extend({
model: advisor.Semester
});
var advisor = advisor || {};
advisor.Semester = Backbone.RelationalModel.extend({
urlRoot: '/api/semesters',
initialize: function() {
this.fetchRelated('courses')
},
events: {
"click .panel-heading": "toggle"
},
relations: [{
type: Backbone.HasMany,
key: 'courses',
relatedModel: 'advisor.Course',
collectionType: 'advisor.CourseCollection',
reverseRelation: {
key: 'semester',
includeInJSON: 'id'
}
}],
});
var advisor = advisor || {};
advisor.Trajectory = Backbone.RelationalModel.extend({
urlRoot: '/api/trajectories',
initialize: function() {
this.fetch()
},
relations: [{
type: Backbone.HasMany,
key: 'semesters',
relatedModel: 'advisor.Semester',
collectionType: 'advisor.SemesterCollection',
autoFetch: true,
reverseRelation: {
key: 'trajectory',
includeInJSON: 'id'
}
}]
});
......@@ -7,6 +7,7 @@ advisor.CourseView = Backbone.View.extend({
template: _.template( $('#course-template').html() ),
events: {
"click": "info"
},
initialize: function() {
......@@ -18,4 +19,8 @@ advisor.CourseView = Backbone.View.extend({
$('body').append( this.template( this.model.toJSON() ) );
return this;
},
info: function() {
}
});
......@@ -8,13 +8,15 @@ advisor.CourseCollectionView = Backbone.View.extend({
var view = new advisor.CourseView({ model: course });
// Fix bug where element render multiple times
var elm = view.render().el
if(!($('#' + elm.id).length))
this.$el.append(elm);
console.log(elm)
$('#' + elm.id).remove()
this.$el.append(elm);
},
// Add all items in the **Todos** collection at once.
addAll: function(courses) {
courses.each(this.addOne, this);
(function() {console.log("done")})();
}
});
......@@ -16,7 +16,7 @@ advisor.ProgramView = Backbone.View.extend({
},
render_courses: function() {
this.$('.panel-body').html('');
this.$('.courses-panel').html('');
var that = this;
this.model.fetchRelated('requirements', {
success: function(requirements) {
......
var advisor = advisor || {};
advisor.SemesterCollectionView = Backbone.View.extend({
className: 'semester',
initialize: function() {
this.addAll();
},
addOne: function(semester) {
var view = new advisor.SemesterView({ model: semester });
var el = view.render().el
$('#semesters').append(el);
},
addAll: function() {
this.$el.html('');
advisor.Semesters.each(this.addOne, this);
},
});
var advisor = advisor || {};
advisor.SemesterView = Backbone.View.extend({
template: _.template( $('#semester-template').html() ),
initialize: function() {
},
events: {
"click .panel-heading": "render"
},
render: function() {
this.$el.addClass('semester panel panel-info').attr('id', 'semester-' + this.model.get('id'))
.html(this.template(this.model.toJSON()));
this.render_courses()
return this;
},
render_courses: function() {
//this.$('.panel-body').html('');
var that = this;
console.log(that.model.get('courses'))
this.model.fetchRelated('courses', {
success: function() {
console.log(that.model.get('courses'));
var courseViews = new advisor.CourseCollectionView({el: that.el});
courseViews.addAll(that.model.get('courses'));
},
});
}
});
......@@ -9,7 +9,7 @@
<%= dept %> <%= courseid %>
</script>
<script type="text/template" id="program-template">
<div class="panel-heading">
<div class="panel-heading program-title">
<h3 class="panel-title"><%= name %></h3>
</div>
<div class="panel-body">
......@@ -17,27 +17,36 @@
</div>
</div>
</script>
<script type="text/template" id="semester-template">
<div class="panel-heading">
<h3 class="panel-title">Semester <%= id %></h3>
</div>
<div class="panel-body">
<div class="gridster courses">
</div>
</div>
</script>
{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-12">
<div class="row semester-controls">
<div class="col-lg-2 col-lg-offset-8">
<a href="#NewSemester" class="btn btn-block btn-lg btn-info">Semester <i class="fa fa-plus"></i> </a>
</div>
<div class="col-lg-2">
<a href="#Save" class="btn btn-block btn-lg btn-primary">Save</a>
</div>
</div>
<div class="row gridster">
<div id="" class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Semester</h3>
</div>
<div class="panel-body"></div>
<div id="semesters">
</div>
<div id="programs">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Computer Science Major</h3>
</div>
<div class="panel-body">
<div class="panel-body courses-panel">
<div class="gridster courses">
<ul>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"></li>
......@@ -97,12 +106,17 @@
<script src="/static/js/advisor/models/course.js"></script>
<script src="/static/js/advisor/models/requirement.js"></script>
<script src="/static/js/advisor/models/program.js"></script>
<script src="/static/js/advisor/models/semester.js"></script>
<script src="/static/js/advisor/models/trajectory.js"></script>
<script src="/static/js/advisor/collections/courses.js"></script>
<script src="/static/js/advisor/collections/requirements.js"></script>
<script src="/static/js/advisor/collections/programs.js"></script>
<script src="/static/js/advisor/collections/semesters.js"></script>
<script src="/static/js/advisor/views/courseView.js"></script>
<script src="/static/js/advisor/views/programView.js"></script>
<script src="/static/js/advisor/views/semesterView.js"></script>
<script src="/static/js/advisor/views/programCollectionView.js"></script>
<script src="/static/js/advisor/views/semesterCollectionView.js"></script>
<script src="/static/js/advisor/views/courseCollectionView.js"></script>
<script src="/static/js/advisor/app.js"></script>
{% endblock %}
......@@ -21,7 +21,7 @@ body {
height: 16px;
}
#main {
margin-top: 65px;
padding-top: 65px;
}
.courses li {
......@@ -31,9 +31,16 @@ body {
.program {
text-align: center;
padding-bottom: 15px;
max-height: 480px;
overflow-y: scroll;
}
.program-title {
padding: 16px 0;
}
.semester-controls {
margin-bottom: 15px;
}
.course {
width: 160px;
height: 80px;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment