forked from CrowdSourcingReport/CrowdSourcingReport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.py
140 lines (123 loc) · 6.17 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
129
130
131
132
133
134
135
136
137
138
139
140
#oggpnosn
#hkhr
#changes are being made here by kethzi and priyanka
import webapp2
from lib import BaseHandler, NGO, Project
import random
from google.appengine.api import mail
import datetime
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)
ngo = ngoQuery.fetch(1)[0]
parameter = {}
if descriptionAuthenticity == "on" and eightygAuthenticity == "on":
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 """)
ngo.credibility = True
ngo.put()
parameter["message"]= "Success Mail Sent!"
self.render("responseAdmin.html", parameter)
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"
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""")
parameter["message"] = "Failure Report Sent!"
self.render("responseAdmin.html", parameter)
class CreateFakeNGOAccount(BaseHandler):
def get(self):
for i in range(100):
ngo = NGO()
ngo.userid = str(random.randrange(1000,10000))
ngo.name = "TG"
ngo.credibility = False
ngo.description = ""
ngo.email = ""
ngo.pancardNumber = ""
ngo.dateOfRegistration = datetime.datetime.now()
ngo.stateOfRegistration = ""
ngo.chiefFunctionary = ""
ngo.chairman = ""
ngo.stateOfOperation = ""
ngo.sectorOfOperation = "ap"
ngo.address = ""
ngo.telephone = "122"
ngo.registrationNumber = "1234"
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,10))
project.category = "Health"
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, urlParameter):
ngo, title = urlParameter.split("_")
parameter = {}
projectQuery = Project.query(Project.ngo == ngo, Project.title == title)
project = projectQuery.fetch(1)[0]
parameter["project"] = project
self.render("adminAuthenticateProjectPage.html", parameter)
def post(self, urlParameter):
ngoUserid, title = urlParameter.split("_")
descriptionAuthenticity = self.request.get("descriptionAuthenticity")
projectQuery = Project.query(Project.ngo == ngoUserid, Project.title == title)
ngoQuery = NGO.query(NGO.userid == ngoUserid)
ngo = ngoQuery.fetch(1)[0]
project = projectQuery.fetch(1)[0]
parameter = {}
if descriptionAuthenticity == "on":
mail.send_mail(sender=" <tanaygahlot@gmail.com>",
to= "<"+ngo.email+">",
subject="Your Project has passed authentication test",
body="""Dear :"""+ ngo.name + "Your Project titled '"+project.title+"' has passed authentication and goes live!\n" +"""Please let us know if you have any questions.The csr.com Team""")
project.authenticity = True
project.put()
parameter["message"]= "Success Mail Sent!"
self.render("responseAdmin.html", parameter)
else:
failiureReport = "\nPlaces where your project failed\n"
failiureReport += " The Description you provided isnt apt for a site like us.\n"
mail.send_mail(sender=" <tanaygahlot@gmail.com>", to= "<"+ngo.email+">", subject="Your Project has failed authentication test",body="""Dear :"""+ ngo.name + failiureReport +"""Please let us know if you have any questions. \nThe csr.com Team""")
parameter["message"]= "Failure Report Sent!"
self.render("responseAdmin.html", parameter)
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_a-zA-Z]+)', AuthenticateProjectHandler)])