Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ Then to really get the most out of the repo, you can access the template mailer.
Some of the pages functionality:<br>
<br>
- Founders can upload their own companies as per normal, using pagelane's sweet form<br>
- You can curate and upload new, white logos on the backend<br>
- You can curate and upload new, white logos on the backend (/dashboard/logo), only once you upload a new logo will the startup be displayed on your page<br>
- To repace a logo, simply upload a new logo, the old one will be overwritten<br>
- Only click "Delete" on /dashboard/logo if you want to completely remove the startup, i.e. its spam <br>
- All data is accessible from the dashboard or through the google cloud console<br>
- you can collect mailers through the early adopter mailing list form<br>
<br>
Expand All @@ -85,7 +87,10 @@ I think you have about 1GB of free storage on GAE, if you upload so many logos t
You can read more about the google cloud platform at http://cloud.google.com
<br>
<br>
..........if all this is too much for you look me up on slack and if I have a minute I'll help you out.
..........if all this is too much for you look me up (@emile - Foundedx) on slack and if I have a minute I'll help you out.
<br>
<br>




Expand Down
165 changes: 144 additions & 21 deletions foundedin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,37 @@ def tweet(status):
#serves the homepage
class HomePage(MainHandler):
def get(self):
curs = Cursor(urlsafe=self.request.get('cursor'))
year = datetime.datetime.now().year
settings = model.Settings.query().get()
mail = model.MandrillApi.query().get()
tw = model.TwitterApi.query().get()
startups = model.Startup.query(model.Startup.approved == True).order(model.Startup.q1).fetch(500)
features = model.Feature.query(model.Feature.front_page == True, model.Feature.live == True).fetch()

pages = model.StaticPage.query().fetch()

#startups = model.Startup.query(model.Startup.approved == True).order(model.Startup.q1).fetch(500)

startups, next_curs, more = model.Startup.query(model.Startup.approved == True).order(model.Startup.q1).fetch_page(500, start_cursor=curs)
if more and next_curs:
next_curs = next_curs.urlsafe()
else:
next_curs = False

if not settings:
self.response.out.write("If you are the admin for this page please navigate to /dashboard and complete the page setup")
else:
self.render("index.html", startups=startups, year=year, settings=settings, mail=mail, tw=tw)
self.render("index.html", startups=startups, year=year, settings=settings, mail=mail, tw=tw, next_curs=next_curs, features=features, pages=pages)

class ViewLogos(MainHandler):
def get(self):
year = datetime.datetime.now().year
settings = model.Settings.query().get()
mail = model.MandrillApi.query().get()
tw = model.TwitterApi.query().get()
startups = model.Startup.query(model.Startup.approved == True).order(model.Startup.q1).fetch(500)

self.render("admin.html", startups=startups, year=year, settings=settings, mail=mail, tw=tw)

# add a startup... completed by prospective startups
class AddStartup(MainHandler):
Expand All @@ -137,6 +158,7 @@ def post(self):
try:
utils.send_notification_mail(q1)
except:
logging.error("no notification sent")
pass

#serve the admin page
Expand All @@ -158,7 +180,20 @@ def get(self):
mail = model.MandrillApi.query().get()
tw = model.TwitterApi.query().get()
year = datetime.datetime.now().year
self.render("about.html", year=year, settings=settings, mail=mail, tw=tw)
pages = model.StaticPage.query().fetch()
self.render("about.html", year=year, settings=settings, mail=mail, tw=tw, pages=pages)

class StaticPage(MainHandler):
def get(self, page_url):
settings = model.Settings.query().get()
mail = model.MandrillApi.query().get()
tw = model.TwitterApi.query().get()
year = datetime.datetime.now().year

page = model.StaticPage.query(model.StaticPage.page_url == page_url).get()
pages = model.StaticPage.query().fetch()
self.render("static_page.html", page=page, pages=pages, settings=settings, tw=tw, mail=mail)


class Dashboard(MainHandler):
def get(self):
Expand All @@ -173,6 +208,7 @@ def post(self):
bg_color = self.request.get("bg_color")
link_color = self.request.get("link_color")
logo_highlight_color = self.request.get("logo_highlight_color")
nav_color = self.request.get("nav_color")
intro_html = self.request.get("intro_html")
in_common_1 = self.request.get("in_common_1")
in_common_2 = self.request.get("in_common_2")
Expand All @@ -190,8 +226,11 @@ def post(self):
seo_description = self.request.get("seo_description")
seo_keywords = self.request.get("seo_keywords")
share_url = self.request.get("share_url")
css = self.request.get("css")
ga = self.request.get("ga")

tw_handle = self.request.get("tw_handle")
auto_tweet = self.request.get("auto_tweet")
tw_short_url = self.request.get("tw_short_url")
tw_consumer_key = self.request.get("tw_consumer_key")
tw_consumer_secret = self.request.get("tw_consumer_secret")
Expand Down Expand Up @@ -219,6 +258,7 @@ def post(self):
bg_color=bg_color,
link_color=link_color,
logo_highlight_color=logo_highlight_color,
nav_color=nav_color,
intro_html=intro_html,
in_common_1=in_common_1,
in_common_2=in_common_2,
Expand All @@ -232,6 +272,8 @@ def post(self):
logo_credit=logo_credit,
logo_credit_name=logo_credit_name,
about_html=about_html,
css=css,
ga=ga,
)
settings.put()
else:
Expand All @@ -244,6 +286,7 @@ def post(self):
settings.bg_color=bg_color
settings.link_color=link_color
settings.logo_highlight_color=logo_highlight_color
settings.nav_color=nav_color
settings.intro_html=intro_html
settings.in_common_1=in_common_1
settings.in_common_2=in_common_2
Expand All @@ -258,6 +301,8 @@ def post(self):
settings.logo_credit=logo_credit
settings.logo_credit_name=logo_credit_name
settings.about_html=about_html
settings.css=css
settings.ga=ga
settings.put()

tw = model.TwitterApi.query().get()
Expand All @@ -270,6 +315,7 @@ def post(self):
tw_consumer_secret=tw_consumer_secret,
tw_access_token_key=tw_access_token_key,
tw_access_token_secret=tw_access_token_secret,
auto_tweet=auto_tweet,
)
tw.put()
else:
Expand All @@ -279,6 +325,7 @@ def post(self):
tw.tw_consumer_secret=tw_consumer_secret
tw.tw_access_token_key=tw_access_token_key
tw.tw_access_token_secret=tw_access_token_secret
tw.auto_tweet=auto_tweet
tw.put()

mail = model.MandrillApi.query().get()
Expand Down Expand Up @@ -318,6 +365,34 @@ def get(self):
startups = model.Startup.query().order(-model.Startup.q1).fetch(500)
self.render("dashboard_logo.html", startups=startups)

class DashboardStaticPage(MainHandler):
def get(self):

pages = model.StaticPage.query().fetch()

self.render("dashboard_static_page.html", pages=pages)

def post(self):
html = self.request.get("html")
title = self.request.get("title")
page_url = self.request.get("page_url")
pid = self.request.get("pid")

page_url = utils.check_alphanumeric(page_url)

if pid:
page = model.StaticPage.get_by_id(int(pid))
page.html = html
page.title = title
page.page_url = page_url
page.put()
else:
page = model.StaticPage(html=html, page_url=page_url, title=title)
page.put()

self.redirect("/dashboard/static_page")


class DashboardFeaturedArticles(MainHandler):
def get(self):
articles = model.Feature.query().fetch()
Expand All @@ -337,6 +412,22 @@ def post(self):
founder = self.request.get_all("founder")
podcast = self.request.get("podcast")
startup_id = self.request.get("startup_id")
front_page = self.request.get("display_on_front_page")
feature_external = self.request.get("feature_external")

logging.error(".... front page")
logging.error(front_page)

if front_page == "yes":
front_page = True
else:
front_page = False

if feature_external == "yes":
feature_external=True
else:
feature_external = False

startup = model.Startup.get_by_id(int(startup_id))

founder_list = []
Expand All @@ -359,7 +450,7 @@ def post(self):
}
founder_list.append(obj)

f = model.Feature(description=description, founder=founder_list, podcast=podcast, startup=startup.key)
f = model.Feature(description=description, founder=founder_list, podcast=podcast, startup=startup.key, front_page=front_page, feature_external=feature_external)
f.put()
self.redirect("/dashboard/featured_articles")

Expand All @@ -377,6 +468,17 @@ def post(self, feature_id):
podcast = self.request.get("podcast")
startup_id = self.request.get("startup_id")
startup = model.Startup.get_by_id(int(startup_id))
front_page = self.request.get("display_on_front_page")
feature_external = self.request.get("feature_external")

if front_page == "yes":
front_page = True
else:
front_page = False
if feature_external == "yes":
feature_external=True
else:
feature_external = False

feature_id = feature_id

Expand Down Expand Up @@ -405,6 +507,8 @@ def post(self, feature_id):
feature.founder = founder_list
feature.podcast = podcast
feature.startup = startup.key
feature.front_page = front_page
feature.feature_external = feature_external

feature.put()
self.redirect("/dashboard/featured_articles")
Expand Down Expand Up @@ -505,6 +609,9 @@ def get(self):
class EarlyAdopter(MainHandler):
def post(self):
ea = self.request.get("ea")
settings = model.Settings.query().get()
mail = model.MandrillApi.query().get()
tw = model.TwitterApi.query().get()

existing_email = model.EarlyAdopter.query(model.EarlyAdopter.ea == ea).get()

Expand All @@ -515,7 +622,7 @@ def post(self):
ea_id = ea.key.id()

t = jinja_env.get_template("mailer.html")
html = t.render(ea_id=ea_id)
html = t.render(ea_id=ea_id, settings=settings, tw=tw, mail=mail)

utils.send_mail(ea.ea, ea_id, html)

Expand Down Expand Up @@ -549,8 +656,6 @@ class Upload(blobstore_handlers.BlobstoreUploadHandler):
def post(self, startup_id):
upload_files = self.get_uploads('new_logo')

logging.error(upload_files)

blob_info = upload_files[0]
blob_key = blob_info.key()

Expand All @@ -571,29 +676,43 @@ def post(self, startup_id):

year = datetime.datetime.now().year

if startup.q4:
if int(startup.q2) == year:
status = "New #startup on %s: %s via %s" % ( tw.tw_short_url, startup.q4, tw.tw_handle )
#status = "Check out the hot new SA #startup, %s, via @foundedinsa bit.ly/1ugm5eG" % startup.q4
else:
status = "Featured #startup on %s: %s via %s" % ( tw.tw_short_url, startup.q4, tw.tw_handle )

auto_tweet = tw.auto_tweet
if not auto_tweet:
status = "New #startup on %s: %s via %s" % ( tw.tw_short_url, startup.q4, tw.tw_handle )
else:
if int(startup.q2) == year:
status = "New #startup on %s: %s via %s" % ( tw.tw_short_url, startup.q4, tw.tw_handle )
status = auto_tweet.replace("*MYHANDLE*", tw.tw_handle)
if startup.q4:
status = status.replace("*SUHANDLE*", startup.q4)
else:
status = status.replace("*SUHANDLE*", '')

if tw.tw_short_url:
status = status.replace("*SHORTURL*", tw.tw_short_url)
else:
status = "Featured #startup on %s: %s via %s" % ( tw.tw_short_url, startup.q4, tw.tw_handle )
if tw.tw_handle:
status = status.replace("*SHORTURL*", tw.tw_handle)
else:
status = status.replace("*SHORTURL*", '')
status = status.replace("*SUNAME*", startup.q1)

# if startup.q4:
# if int(startup.q2) == year:
# status = "New #startup on %s: %s via %s" % ( tw.tw_short_url, startup.q4, tw.tw_handle )
# else:
# status = "Featured #startup on %s: %s via %s" % ( tw.tw_short_url, startup.q4, tw.tw_handle )
# else:
# if int(startup.q2) == year:
# status = "New #startup on %s: %s via %s" % ( tw.tw_short_url, startup.q4, tw.tw_handle )
# else:
# status = "Featured #startup on %s: %s via %s" % ( tw.tw_short_url, startup.q4, tw.tw_handle )

try:
tweet(status)
#pass
except tweepy.TweepError as e:
logging.error(e.response.status)


#status = "Checkout the hot new SA startup, %s" % startup.q4

#tweet(serving_url, status)

self.redirect("/dashboard/logo")

class UploadFeature(blobstore_handlers.BlobstoreUploadHandler):
Expand Down Expand Up @@ -798,15 +917,19 @@ def get(self):
('/', HomePage),
('/add_startup', AddStartup),
('/admin', Admin),
('/view_logos', ViewLogos),
('/archive', Archive),
#('/tweet/(\w+)', TweetStartup),
('/about', About),
('/page/(\w+)', StaticPage),
('/dashboard', Dashboard),
('/dashboard/startups', DashboardStartups),
('/dashboard/logo', DashboardLogo),
('/dashboard/feature', DashboardFeature),
('/dashboard/feature_edit/(\w+)', DashboardFeatureEdit),
('/dashboard/featured_articles', DashboardFeaturedArticles),
('/dashboard/static_page', DashboardStaticPage),

('/feature_golive/(\w+)', FeatureGoLive),
('/feature_deactivate/(\w+)', FeatureDeactivate),
('/feature/(\w+)', Feature),
Expand Down
Binary file modified foundedin/main.pyc
Binary file not shown.
Loading