Removes script and change according to suggestion.

This commit is contained in:
gaba
2016-11-11 08:38:51 -08:00
parent ce206047f4
commit ad01bc813f
2 changed files with 1 additions and 50 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ const router = express.Router();
router.get('/comments/pending', (req, res, next) => {
Setting.getModerationSetting().then(function({moderation}){
let moderationValue = req.query.moderation;
if (typeof moderationValue === 'undefined' || moderationValue === undefined) {
if (typeof moderationValue === 'undefined' || !moderationValue) {
moderationValue = moderation;
}
Comment.moderationQueue(moderationValue).then((comments) => {
-49
View File
@@ -1,49 +0,0 @@
from pymongo import MongoClient
import requests
url = 'http://localhost:3000/api/v1/'
url_asset = '%sasset' % url
url_comment = '%scomments' % url
def main():
client = MongoClient('localhost', 27017)
db_wapo = client.original_wapo
wcomments = db_wapo.comments
for comment in wcomments.find():
ncomment = {}
nasset = {}
status = comment['object']['status']
if (status == 'Untouched'):
ncomment['status'] = ''
elif (status == 'CommunityFlagged'):
ncomment['status'] = ''
elif (status == 'ModeratorApproved'):
ncomment['status'] = 'accepted'
elif (status == 'ModeratorDeleted'):
ncomment['status'] = 'rejected'
ncomment['body'] = comment['object']['content']
nasset['url'] = comment['targets'][0]['conversationID']
ncomment['asset_id'] = post_asset(nasset)
ncomment['author_id'] = '1'
post_comment(ncomment)
def post_asset(nasset):
print 'Posting %s into %s.' % (nasset, url_asset)
try:
r = requests.put(url_asset, json=nasset)
if 'id' in r.json():
return r.json()['id']
else:
ra = requests.get(url_asset, { url: nasset['url']})
return ra.json()['id']
except:
print('Error when getting asset.')
return 'asset'
def post_comment(ncomment):
print 'Posting %s into %s.' % (ncomment, url_comment)
r = requests.post(url_comment, json=ncomment)
if __name__ == '__main__':
main()