Adding code to forget categories
This commit is contained in:
parent
9edb58590d
commit
a316f1e3d3
@ -13,7 +13,7 @@
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Category</th>
|
||||
<th>Rating</th>
|
||||
<th class="text-right">Rating</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="categories"></tbody>
|
||||
@ -22,7 +22,7 @@
|
||||
<tr class="category_{{id}}">
|
||||
<td><button type="button" data-categoryId="{{id}}" class="btn btn-xs btn-danger">×</button></td>
|
||||
<td>{{description}}</td>
|
||||
<td>
|
||||
<td class="text-right">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="category_{{id}}" data-categoryId="{{id}}" value="1" {{checkMatch 1}}> Agree
|
||||
</label>
|
||||
|
@ -248,6 +248,16 @@ function addCategory(query, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
function removeCategory(query, callback) {
|
||||
pool.query('DELETE FROM categories WHERE id = (?)', [query.id], function(err, info) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
callback({success: info.affectedRows > 0});
|
||||
});
|
||||
}
|
||||
|
||||
function accessReview(query, callback) {
|
||||
pool.query('SELECT url FROM reviews WHERE id = (?) LIMIT 1', [query.id], function(err, rows) {
|
||||
if (err) {
|
||||
@ -266,17 +276,10 @@ function accessReview(query, callback) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
var pitcher = function(err, info) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
for (var categoryId in query.profile) {
|
||||
pool.query(
|
||||
'INSERT INTO historyGroups(categoryId, categoryValue, historyId) VALUES(?, ?, ?)',
|
||||
[categoryId, query.profile[categoryId], info.insertId],
|
||||
pitcher
|
||||
[categoryId, query.profile[categoryId], info.insertId]
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -332,5 +335,6 @@ module.exports = {
|
||||
runQuery: runQuery,
|
||||
getCategories: getCategories,
|
||||
addCategory: addCategory,
|
||||
removeCategory: removeCategory,
|
||||
accessReview: accessReview
|
||||
};
|
||||
|
@ -57,6 +57,12 @@ function main(staticFiles, port) {
|
||||
});
|
||||
});
|
||||
|
||||
app.use('/forget', function(req, res) {
|
||||
search.removeCategory(req.query, function(results) {
|
||||
res.json(results);
|
||||
});
|
||||
});
|
||||
|
||||
app.use('/access', function(req, res) {
|
||||
search.accessReview(req.query, function(results) {
|
||||
res.json(results);
|
||||
|
Loading…
Reference in New Issue
Block a user