Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

wrapping up admin flow

  • Loading branch information...
commit acc39a01ebc5d2cf582557b49c1b6c71f2a64443 1 parent 58520e2
Dhaval Patel authored
Showing with 23 additions and 3 deletions.
  1. +3 −1 app.py
  2. +7 −0 common/db.py
  3. +13 −2 templates/admin.html
View
4 app.py
@@ -1,5 +1,5 @@
from flask import Flask, render_template, request, jsonify
-from common.db import subscribe_email, confirm, unsubscribe, admin_query
+from common.db import *
from common.time import get_next_week
from common.mail import SendEmail
import os
@@ -48,6 +48,8 @@ def curate():
@app.route("/filtered")
def filtered():
ids = request.values.get("ids")
+ filtered = filter_ids_based_on(ids.split(","))
+ set_data_to_send(filtered)
return "true"
@app.route("/l")
View
7 common/db.py
@@ -1,5 +1,6 @@
from settings import data_dump, sent_data, user_table
from common.time import get_next_week
+from pymongo.objectid import ObjectId
import hashlib
@@ -48,6 +49,12 @@ def set_data_to_send(data_list):
"meetup_date" : data["meetup_date"]}}, True)
+def filter_ids_based_on(ids):
+ i = [ObjectId(each) for each in ids]
+ cursor = data_dump.find({"_id" : {"$in" : i} })
+ return list(cursor)
+
+
def get_data_to_send():
c = sent_data.find().sort("$natural", -1).limit(1)
return list(c)
View
15 templates/admin.html
@@ -64,9 +64,20 @@
}
function submit() {
- console.log();
+ var ids = [];
$.each($('.row_selected'), function(index, value) {
- console.log($(value).attr('id'));
+ ids.push($(this).attr('id'));
+ });
+ var idsStr = ids.join(',');
+ $.ajax({
+ url: "/filtered?ids=" + idsStr,
+ context: document.body,
+ success: function(resp){
+ if(resp === "true") {
+ alert('howdy');
+ } else {
+ }
+ }
});
}
</script>
Please sign in to comment.
Something went wrong with that request. Please try again.