Skip to content

Commit

Permalink
Remove login: admin from _internal handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
fatlotus committed Apr 1, 2016
1 parent 3ff5d9a commit 6dd69e6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
4 changes: 0 additions & 4 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ handlers:
script: caravel.app
login: admin
secure: always
- url: /_internal/.*
script: caravel.app
login: admin
secure: always
- url: /login.*
script: caravel.app
login: required
Expand Down
4 changes: 4 additions & 0 deletions caravel/daemons/delete_old_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
"""

from caravel import app, model
from google.appengine.api import users


@app.route('/_internal/collect_garbage')
def collect_garbage():
if not users.is_current_user_admin():
return "???"

model.Photo.remove_old_photos()

return "ok"
4 changes: 4 additions & 0 deletions caravel/daemons/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from caravel import app, model
import itertools
import datetime
from google.appengine.api import users


def grouper(iterable, n, fillvalue=None):
Expand All @@ -17,6 +18,9 @@ def grouper(iterable, n, fillvalue=None):

@app.route("/_internal/migrate_schema")
def migrate_schema():
if not users.is_current_user_admin():
return "???"

horizon = datetime.datetime.now() - model.Listing.MARK_AS_OLD_AFTER

q = model.Listing.query(
Expand Down
7 changes: 6 additions & 1 deletion caravel/daemons/nag_moderators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
from caravel import app, model, utils
from caravel.utils import emails
from flask import render_template
from google.appengine.api import users


@app.route('/_internal/nag_moderators')
def nag_moderators():
if not users.is_current_user_admin():
return "???"

listings = list(model.UnapprovedListing().query())
inquiries = list(model.UnapprovedInquiry().query())
pending = listings + inquiries
Expand All @@ -20,7 +25,7 @@ def nag_moderators():
subject="{} Inquiries, {} Listings Pending".format(
len(inquiries), len(listings)),
text=render_template("email/nag_moderators.txt",
listings=listings, inquiries=inquiries),
listings=listings, inquiries=inquiries),
html=None
)

Expand Down
3 changes: 2 additions & 1 deletion caravel/tests/test_listings.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def test_post_inquiry(self):
self.assertEqual(self.emails, [])

# Notify the moderators that something has happened.
self.get("/_internal/nag_moderators")
with self.google_apps_user("admin@uchicago.edu"):
self.get("/_internal/nag_moderators")

# Ensure that the moderators received the right email.
self.assertEqual(
Expand Down
3 changes: 2 additions & 1 deletion caravel/tests/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def test_migrate_from_old(self):
self.assertEquals(listing.version, 12)

# Trigger an update cronjob.
self.get("/_internal/migrate_schema")
with self.google_apps_user("admin@uchicago.edu"):
self.get("/_internal/migrate_schema")

# Verify that we have now changed on disk.
listing = Listing.get_by_key_name("my-listing-name")
Expand Down

0 comments on commit 6dd69e6

Please sign in to comment.