Commit 4a80373c authored by Renfred Harper's avatar Renfred Harper

Merge branch 'front-end/build'

parents b32c3747 f59f5d6b
var advisor = advisor || {};
$(function () {
advisor.Programs = new advisor.ProgramCollection();
var p = new advisor.Program({id: 3});
advisor.Programs.reset([p]);
(new advisor.ProgramCollectionView())
});
advisor.CourseCollection = Backbone.Collection.extend({
model: advisor.Course
});
advisor.ProgramCollection = Backbone.Collection.extend({
model: advisor.Program
});
advisor.RequirementCollection = Backbone.Collection.extend({
model: advisor.Requirement
});
var advisor = advisor || {};
advisor.Course = Backbone.RelationalModel.extend({
urlRoot: '/api/courses',
defaults: {
dept: '',
......
var advisor = advisor || {};
advisor.Program = Backbone.RelationalModel.extend({
urlRoot: '/api/programs',
initialize: function() {
this.fetch()
},
relations: [{
type: Backbone.HasMany,
key: 'requirements',
relatedModel: 'advisor.Requirement',
collectionType: 'RequirementCollection',
collectionType: 'advisor.RequirementCollection',
autoFetch: true,
reverseRelation: {
key: 'program',
includeInJSON: 'id'
......
var advisor = advisor || {};
advisor.Requirement = Backbone.RelationalModel.extend({
urlRoot: '/api/requirements',
defaults: {
name: '',
},
relations: [{
type: Backbone.HasMany,
key: 'courses',
relatedModel: 'advisor.Course',
collectionType: 'CourseCollection',
collectionType: 'advisor.CourseCollection',
autoFetch: true,
reverseRelation: {
key: 'satisfies',
includeInJSON: 'id'
......
var advisor = advisor || {};
advisor.CourseView = Backbone.View.extend({
tagName: 'div',
template: _.template( $('#course-template').html() ),
events: {
},
initialize: function() {
this.listenTo(this.model, 'change', this.render);
},
// Re-renders the titles of the todo item.
render: function() {
$('body').append( this.template( this.model.toJSON() ) );
return this;
},
});
var advisor = advisor || {};
advisor.CourseCollectionView = Backbone.View.extend({
elements: [],
addOne: function(course) {
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);
},
// Add all items in the **Todos** collection at once.
addAll: function(courses) {
courses.each(this.addOne, this);
}
});
var advisor = advisor || {};
advisor.CourseView = Backbone.View.extend({
template: _.template( $('#course-template').html() ),
initialize: function() {
this.listenTo(this.model, 'change', this.render);
},
render: function() {
this.$el.addClass('course ' + this.model.get('dept')).attr('id', 'course-' + this.model.get('id'))
.html(this.template(this.model.toJSON()));
return this;
},
});
var advisor = advisor || {};
advisor.ProgramCollectionView = Backbone.View.extend({
el: '#programs',
initialize: function() {
this.addAll();
},
addOne: function(program) {
var view = new advisor.ProgramView({ model: program });
var el = view.render().el
this.$el.append(el);
},
addAll: function() {
this.$el.html('');
advisor.Programs.each(this.addOne, this);
}
});
var advisor = advisor || {};
advisor.ProgramView = Backbone.View.extend({
template: _.template( $('#program-template').html() ),
initialize: function() {
this.listenTo(this.model, 'change', this.render);
},
render: function() {
this.$el.attr('id', 'program-' + this.model.get('id')).addClass('panel panel-primary program')
.html(this.template(this.model.toJSON()));
this.render_courses();
return this;
},
render_courses: function() {
this.$('.panel-body').html('');
var that = this;
this.model.fetchRelated('requirements', {
success: function(requirements) {
that.model.get('requirements').forEach(function(requirement) {
requirement.fetchRelated('courses', {
success: function() {
var courseViews = new advisor.CourseCollectionView({el: that.el});
courseViews.addAll(requirement.get('courses'));
}
})
})
}
})
}
});
......@@ -4,39 +4,79 @@
{% endblock %}
{% block templates %}
<script type="text/template" id="course-template">
<%= dept %> <%= courseid %>
</script>
<script type="text/template" id="program-template">
<div class="panel-heading">
<h3 class="panel-title"><%= name %></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>
</div>
<div id="programs">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Computer Science Major</h3>
<div class="row">
<div id="programs" class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Computer Science Major</h3>
</div>
<div class="panel-body">
<div class="gridster courses">
<ul>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="1" data-sizex="1" data-sizey="1"></li>
<li data-row="3" data-col="1" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="2" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="2" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="4" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="4" data-sizex="1" data-sizey="1"></li>
<li data-row="3" data-col="4" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="5" data-sizex="1" data-sizey="1"></li>
<li data-row="3" data-col="5" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="6" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="6" data-sizex="1" data-sizey="1"></li>
</ul>
</div>
<div class="panel-body">
<div class="gridster courses">
<ul>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="1" data-sizex="1" data-sizey="1"></li>
<li data-row="3" data-col="1" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="2" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="2" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="4" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="4" data-sizex="1" data-sizey="1"></li>
<li data-row="3" data-col="4" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="5" data-sizex="1" data-sizey="1"></li>
<li data-row="3" data-col="5" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="6" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="6" data-sizex="1" data-sizey="1"></li>
</ul>
</div>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Computer Science Major</h3>
</div>
<div class="panel-body">
<div class="gridster courses">
<ul>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="1" data-sizex="1" data-sizey="1"></li>
<li data-row="3" data-col="1" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="2" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="2" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="4" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="4" data-sizex="1" data-sizey="1"></li>
<li data-row="3" data-col="4" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="5" data-sizex="1" data-sizey="1"></li>
<li data-row="3" data-col="5" data-sizex="1" data-sizey="1"></li>
<li data-row="1" data-col="6" data-sizex="1" data-sizey="1"></li>
<li data-row="2" data-col="6" data-sizex="1" data-sizey="1"></li>
</ul>
</div>
</div>
</div>
......@@ -46,8 +86,15 @@
{% block javascript %}
{{ block.super }}
<script src="/static/js/grids.js"></script>
<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/course.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/views/courseView.js"></script>
<script src="/static/js/advisor/views/programView.js"></script>
<script src="/static/js/advisor/views/programCollectionView.js"></script>
<script src="/static/js/advisor/views/courseCollectionView.js"></script>
<script src="/static/js/advisor/app.js"></script>
{% endblock %}
......@@ -21,7 +21,8 @@ from mainapp.forms import StartTrajectoryForm, StudentForm
def build_trajectory(request):
#process
semester_key = 1
return HttpResponse(semester_key)
return render(request, 'build.html')
class StartTrajectoryView(FormView):
template_name = 'new.html'
form_class = StartTrajectoryForm
......
......@@ -29,6 +29,32 @@ body {
list-style-type: none;
}
.program {
text-align: center;
}
.course {
width: 160px;
height: 80px;
margin: 10px;
text-align: center;
padding-top: 18px;
font-size: 24px;
color: #171C21;
display: inline-block;
background-color: #2980B9;
}
.CS {
background-color: #3498DB;
}
.MATH {
background-color:
}
.ASTR, .PHYS, .CHEM, .BIOL {
background-color: #27AE60;
}
/* Set the fixed height of the footer here */
#footer {
height: 30px;
......
......@@ -40,6 +40,8 @@
<title> {% block title %} {% endblock %} </title>
</head>
<body>
{% block templates %}
{% endblock %}
<div id = "wrap">
{% include 'layouts/navbar.html' %}
......
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