forked from CrowdSourcingReport/CrowdSourcingReport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.py
128 lines (114 loc) · 5.88 KB
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#oggpnosn
#hkhr
import webapp2
from lib import BaseHandler, NGO, Project
import random
from google.appengine.api import mail
class CredibilityCheckHandler(BaseHandler):
def get(self):
parameter = {}
ngoQuery = NGO.query(NGO.credibility == False)
ngoList = ngoQuery.fetch(10)
parameter["ngoList"] = ngoList
self.render("adminCredibilityCheck.html", parameter)
class CredibilityCheckNGOHandler(BaseHandler):
def get(self, userid):
parameter = {}
ngoQuery = NGO.query(NGO.userid == userid)
ngo = ngoQuery.fetch(1)
parameter["ngoList"] = ngo
self.render("adminCredibilityCheckNGOPage.html", parameter)
def post(self, userid):
descriptionAuthenticity = self.request.get("descriptionAuthenticity")
eightygAuthenticity = self.request.get("eightygAuthenticity")
ngoQuery = NGO.query(NGO.userid == userid)
ngoList = ngoQuery.fetch(1)
if descriptionAuthenticity == "on" and eightygAuthenticity == "on":
for ngo in ngoList:
mail.send_mail(sender=" <tanaygahlot@gmail.com>",
to= "<"+ngo.email+">",
subject="Your NGO has been approved",
body="""Dear :"""+ngo.name+"""\nYour csr.com account has been approved. You can now visit
http://www.csr.com/ and sign in using your Google Account to access new features.Please let us know if you have any questions.
The csr.com Team
""")
else:
failiureReport = "\nPlaces where your ngo failed\n"
if descriptionAuthenticity != "on":
failiureReport+=" The Description you provided isnt apt for a site like us.\n"
elif eightygAuthenticity != "off":
failiureReport+=" Your 80G no isnt valid\n"
for ngo in ngoList:
mail.send_mail(sender=" <tanaygahlot@gmail.com>",
to= "<"+ngo.email+">",
subject="Your NGO has failed authentication test",
body="""Dear :"""+ ngo.name + failiureReport +"""Please let us know if you have any questions.
The csr.com Team
""")
class CreateFakeNGOAccount(BaseHandler):
def get(self):
for i in range(100):
ngo = NGO()
ngo.name = str(random.randrange(20,10000))
ngo.credibility = False
ngo.eightygRegistrationNumber = str(random.randrange(1,10000))
ngo.description = str(random.randrange(1,100000000000000000000))
ngo.userid = str(random.randrange(1,1000000))
ngo.email = "tanaygahlot@gmail.com"
ngo.put()
self.response.write("Done!")
class CreateFakeProject(BaseHandler):
def get(self):
for i in range(100):
project = Project()
project.title = str(random.randrange(20,10000))
project.authenticity = False
project.description = str(random.randrange(1,100000000000000000000))
project.ngo = str(random.randrange(1,1000000))
project.put()
self.response.write("Done!")
class AdminHandler(BaseHandler):
def get(self):
self.render("adminHomePage.html")
class AuthenticateHandler(BaseHandler):
def get(self):
parameter = {}
projectQuery = Project.query(Project.authenticity == False)
projectList = projectQuery.fetch(10)
parameter["projectList"] = projectList
self.render("adminAuthenticate.html", parameter)
class AuthenticateProjectHandler(BaseHandler):
def get(self, userid):
parameter = {}
projectQuery = Project.query(Project.userid == userid)
project = projectQuery.fetch(1)
parameter["projectList"] = ngo
self.render("adminCredibilityCheckNGOPage.html", parameter)
def post(self, userid):
descriptionAuthenticity = self.request.get("descriptionAuthenticity")
eightygAuthenticity = self.request.get("eightygAuthenticity")
ngoQuery = NGO.query(NGO.userid == userid)
ngoList = ngoQuery.fetch(1)
if descriptionAuthenticity == "on" and eightygAuthenticity == "on":
for ngo in ngoList:
mail.send_mail(sender=" <tanaygahlot@gmail.com>",
to= "<"+ngo.email+">",
subject="Your NGO has been approved",
body="""Dear :"""+ngo.name+"""\nYour csr.com account has been approved. You can now visit
http://www.csr.com/ and sign in using your Google Account to access new features.Please let us know if you have any questions.
The csr.com Team
""")
else:
failiureReport = "\nPlaces where your ngo failed\n"
if descriptionAuthenticity != "on":
failiureReport+=" The Description you provided isnt apt for a site like us.\n"
elif eightygAuthenticity != "off":
failiureReport+=" Your 80G no isnt valid\n"
for ngo in ngoList:
mail.send_mail(sender=" <tanaygahlot@gmail.com>",
to= "<"+ngo.email+">",
subject="Your NGO has failed authentication test",
body="""Dear :"""+ ngo.name + failiureReport +"""Please let us know if you have any questions.
The csr.com Team
""")
app = webapp2.WSGIApplication([('/admin/CredibilityCheck', CredibilityCheckHandler),('/admin/fake/NGO',CreateFakeNGOAccount),('/admin/fake/Project',CreateFakeProject),('/admin/CredibilityCheck/([0-9]+)', CredibilityCheckNGOHandler), ('/admin', AdminHandler ), ('/admin/Authenticate', AuthenticateHandler), ('/admin/Authenticate/([0-9]+)', AuthenticateProjectHandler)])