Created
December 19, 2013 06:32
-
-
Save barnash/8035228 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'includes/base_header.html' %} | |
{% from 'includes/links.html' import course_link %} | |
{% block window_title %}אנשים{% endblock %} | |
{% block stylesheets %}{{ super() }} | |
<link rel="stylesheet" type="text/css" href="/static/css/people-list.css" /> | |
{% endblock %} | |
{% block page_end_javascripts %} | |
<script src="/static/scripts/person/ourperson-controllers.js"></script> | |
{% endblock %} | |
{% block page_title_text -%} | |
<h1>אנשים</h1> | |
{%- endblock %} | |
{% block page_main %} | |
<div ng-controller="OurPeopleCtrl"> | |
<table> | |
<thead> | |
<tr> | |
<th>שם</th> | |
<th>תפקיד</th> | |
<th>פעולות</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr ng-repeat="person in people"> | |
<td>{@ person.name @}</td> | |
<td>{@ person.role @}</td> | |
<td><button ng-click="deletePerson(person)">מחק</button></td> | |
</tr> | |
</tbody> | |
</table> | |
</div> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function OurPeopleCtrl($scope, $http) { | |
$http.get("/api/ourpeople").then(function(result) { | |
$scope.people = result.data; | |
}); | |
$scope.deletePerson = function(person) { | |
// console.log(person); | |
$http.delete("/api/ourpeople/" + person.id).then(function(result) { | |
}, function(error) { | |
var p = person; | |
$scope.people = _.without($scope.people, person); | |
// debugger; | |
// alert("We had a problem..."); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The route to the html itself | |
@ischool_route('/our_people/', Permissions.all_staffs) | |
def person_list_viewa(): | |
return render_template('our_people.html') | |
# The route to the api to GET all people | |
import json | |
@ischool_route('/api/ourpeople', Permissions.all_staffs) | |
def ourpeople_foo(): | |
#import pdb; pdb.set_trace() | |
people = Person.query.all() | |
dicts = [] | |
for p in people: | |
obj = { | |
"name": p.name, | |
"role": p.role, | |
"id": p.id | |
} | |
dicts.append(obj) | |
return json.dumps(dicts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment