Homework from last time was to work on 'people' app and foreign keys. I worked on both but got stuck on both.
11/23 Wednesday:
Combined deleted accounts app and put user models in donate for simplification on angular side
Fixed foreign key category and subcategory selection html
<p>
<label>Category choice: </label>
<select ng-model="donate.category">
<option data-ng-repeat="cat in categories" value="{{cat.resource_uri}}" ng-click="getSubCategories(cat)">{{cat.title}}<option>
</select>
</p>
<p ng-show="donate.category">
<label>SubCategory choice: </label>
<select ng-model="donate.subcategory">
<option data-ng-repeat="sub in subcategories" value="{{sub.resource_uri}}">{{sub.title}}<option>
</select>
</p>
....
<td ng-bind="d.category.title"></td>
<td ng-bind="d.subcategory.title"></td>
call to foreign keys cat and subcat in apiSvc.js:
function get(resourceName, params){
var queryString = "";
for (var k in params){
if (params.hasOwnProperty(k)){
queryString += "&" + k + "=" + params[k]
}}
Add a delete function in apiSvc.js
function remove(resourceName, resourceId){
return $http.delete("/api/v1/" + resourceName+"/"+ resourceId + "/?format=json")
}
in resources.py import and add filtering
from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS
class SubCategoryResource(ModelResource):
category = fields.ForeignKey(CategoryResource, 'category', null=True, full=True)
class Meta:
queryset = SubCategory.objects.all()
filtering = {
'category' : ALL_WITH_RELATIONS,
}
resource_name = 'subcategory'
Homework: Define minimum viable product.
Check out my progress here.
No comments here yet