Ejemplo n.º 1
0
 def get_nav_items(self):
   items = [('Home', '/'),
            ('Competitions', [
                ('Nationals', '/nationals/2018'),
                ('Regional Championships', '/regional'),
            ]),
            ('Competitors', [
                ('State Rankings', '/state_rankings'),
            ]),
            ('Organizers', [
                ('CubingUSA Supported Competitions', '/supported'),
            ]),
            ('About', [
                ('About CubingUSA', '/about'),
                ('Who we are', '/about/who'),
                ('Donations', '/about/donations'),
                ('Contact Us', '/about/contact'),
                ('Logo', '/about/logo'),
                ('Public Documents', '/about/documents'),
            ]),
           ]
   if self.user and self.user.HasAnyRole(Roles.AdminRoles()):
     admin_list = [('Edit Users', '/admin/edit_users')]
     items.append(('Admin', admin_list))
   return items
Ejemplo n.º 2
0
def CanEditLocation(user, editor):
    if not editor:
        return False
    if editor.HasAnyRole(Roles.AdminRoles()):
        return True
    if user == editor:
        last_update = (UserLocationUpdate.query(
            UserLocationUpdate.user == user.key).order(
                -UserLocationUpdate.update_time).get())
        if last_update and datetime.datetime.now(
        ) - last_update.update_time < datetime.timedelta(days=365):
            return False
        return True
    else:
        return False
Ejemplo n.º 3
0
from src.handlers.admin.update_championships import UpdateChampionshipsHandler
from src.handlers.admin.update_states import UpdateStatesHandler
from src.handlers.admin.upload_users import UploadUsersHandler
from src.handlers.admin.get_wca_export import GetExportHandler
from src.handlers.admin.app_settings import AppSettingsHandler
from src.handlers.basic import BasicHandler
from src.handlers.login import LoginHandler
from src.handlers.login import LoginCallbackHandler
from src.handlers.login import LogoutHandler
from src.handlers.oauth import AuthenticateHandler
from src.models.user import Roles

app = webapp2.WSGIApplication([
    webapp2.Route('/',
                  handler=BasicHandler('admin/index.html',
                                       permitted_roles=Roles.AdminRoles())),
    webapp2.Route('/authenticate', handler=AuthenticateHandler),
    webapp2.Route('/login', handler=LoginHandler, name='login'),
    webapp2.Route('/login_callback',
                  handler=LoginCallbackHandler,
                  name='login_callback'),
    webapp2.Route('/logout', handler=LogoutHandler, name='logout'),
    webapp2.Route('/post_import_mutations',
                  handler=PostImportMutationsHandler),
    webapp2.Route('/update_championships', handler=UpdateChampionshipsHandler),
    webapp2.Route('/update_states', handler=UpdateStatesHandler),
    webapp2.Route(
        '/upload_users', handler=UploadUsersHandler, name='upload_users'),
    webapp2.Route('/wca/get_export', handler=GetExportHandler),
    webapp2.Route('/assign_role/<user_id:.*>/<role:.*>',
                  handler=AssignRoleHandler),
Ejemplo n.º 4
0
 def PermittedRoles(self):
   return Roles.AdminRoles()
Ejemplo n.º 5
0
def CanViewRoles(user, viewer):
    if not viewer:
        return False
    return (viewer.HasAnyRole(Roles.DelegateRoles())
            or viewer.HasAnyRole(Roles.AdminRoles()))
Ejemplo n.º 6
0
 def PermittedRoles(self):
   return Roles.AdminRoles() + Roles.DelegateRoles()
Ejemplo n.º 7
0
def CanEditLocation(user, editor):
    if not editor:
        return False
    if editor.HasAnyRole(Roles.AdminRoles()):
        return True
    return user == editor