-
Notifications
You must be signed in to change notification settings - Fork 1
/
profiles.py
49 lines (38 loc) · 1.46 KB
/
profiles.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
import logging
import string
import wsgiref.handlers
from google.appengine.api import users
from google.appengine.ext import db
from dbinterface import DataStoreInterface
from stringFormatter import StringFormatter
from google.appengine.ext import webapp
from util.sessions import Session
import render
from datastore import Posts
class ProfilesHandler(webapp.RequestHandler):
def get(self):
datastore = DataStoreInterface()
formatter = StringFormatter()
path = self.request.query_string.replace('company=', '')
posts = datastore.getPosts(path, 25)
companies = datastore.getCompanyInfo(path)
company = datastore.getCompanyName(path)
info=''
for c in companies:
info = formatter.formatCompanyInfo(c)
postList=[]
for p in posts:
postList.append(formatter.formatPost(p, p.dbProfileName))
render.doRender(self, 'profiles.html', {'posts': postList, 'company': company , 'info': info, 'profileName' : path})
def post(self):
datastore = DataStoreInterface()
email = self.request.get('txtEmail').strip()
profileName = self.request.query_string.replace('company=', '')
datastore.addEmailSubscriber(profileName, email)
self.redirect('profiles.html?company='+profileName)
class ImageHandler(webapp.RequestHandler):
def get(self):
image = db.get(self.request.get("img_id"))
if image.dbFile:
self.response.headers['Content-Type'] = 'image/jpeg'
self.response.out.write(image.dbFile)