예제 #1
0
 def menu(self):
     archetypes_badge = None
     n = len(deck.load_decks('NOT d.reviewed'))
     if n > 0:
         archetypes_badge = {'url': url_for('edit_archetypes'), 'text': n}
     resources_submenu = []
     if (rotation.next_rotation() - dtutil.now()) < datetime.timedelta(
             7) or (rotation.next_supplemental() -
                    dtutil.now()) < datetime.timedelta(7):
         resources_submenu += [{
             'name': gettext('Rotation Tracking'),
             'url': url_for('rotation')
         }]
     resources_submenu += [{
         'name': gettext('Rotation Changes'),
         'url': url_for('rotation_changes')
     }, {
         'name': gettext('Rotation Speculation'),
         'url': url_for('rotation_speculation')
     }, {
         'name': gettext('Discord Chat'),
         'url': 'https://discord.gg/H6EHdHu'
     }, {
         'name': gettext('External Links'),
         'url': url_for('resources')
     }, {
         'name':
         gettext('Log In'),
         'url':
         url_for('authenticate', target=request.url)
     }, {
         'name': gettext('Log Out'),
         'url': url_for('logout')
     }]
     menu = [{
         'name':
         gettext('Metagame'),
         'url':
         url_for('home'),
         'badge':
         archetypes_badge,
         'submenu': [{
             'name': gettext('Latest Decks'),
             'url': url_for('decks')
         }, {
             'name': gettext('Archetypes'),
             'url': url_for('archetypes'),
             'badge': archetypes_badge
         }, {
             'name': gettext('People'),
             'url': url_for('people')
         }, {
             'name': gettext('Cards'),
             'url': url_for('cards')
         }, {
             'name': gettext('Past Seasons'),
             'url': url_for('seasons')
         }]
     }, {
         'name':
         gettext('League'),
         'url':
         url_for('league'),
         'submenu': [
             {
                 'name': gettext('League Info'),
                 'url': url_for('league')
             },
             {
                 'name': gettext('Sign Up'),
                 'url': url_for('signup')
             },
             {
                 'name': gettext('Report'),
                 'url': url_for('report')
             },
             {
                 'name': gettext('Records'),
                 'url': url_for('current_league')
             },
             {
                 'name': gettext('Retire'),
                 'url': url_for('retire')
             },
         ]
     }, {
         'name':
         gettext('Competitions'),
         'url':
         url_for('competitions'),
         'submenu': [{
             'name': gettext('Competition Results'),
             'url': url_for('competitions')
         }, {
             'name': gettext('Tournament Info'),
             'url': url_for('tournaments')
         }, {
             'name': gettext('Leaderboards'),
             'url': url_for('tournament_leaderboards')
         }, {
             'name': gettext('Gatherling'),
             'url': 'https://gatherling.com/'
         }, {
             'name': gettext('Hosting'),
             'url': url_for('hosting')
         }]
     }, {
         'name': gettext('Resources'),
         'url': url_for('resources'),
         'submenu': resources_submenu
     }, {
         'name':
         gettext('About'),
         'url':
         url_for('about'),
         'submenu': [{
             'name': gettext('What is Penny Dreadful?'),
             'url': url_for('about')
         }, {
             'name': gettext('About pennydreadfulmagic.com'),
             'url': url_for('about_pdm')
         }, {
             'name': gettext('FAQs'),
             'url': url_for('faqs')
         }, {
             'name': gettext('Community Guidelines'),
             'url': url_for('community_guidelines')
         }]
     }, {
         'name': gettext('Admin'),
         'admin_only': True,
         'url': url_for('admin'),
         'submenu': admin.menu()
     }]
     for item in menu:
         item['has_submenu'] = item.get('submenu') is not None
         item['is_external'] = item.get('url', '').startswith(
             'http') and '://pennydreadfulmagic.com/' not in item['url']
         for subitem in item.get('submenu', []):
             subitem['is_external'] = subitem.get('url', '').startswith(
                 'http'
             ) and '://pennydreadfulmagic.com/' not in subitem['url']
     return menu
예제 #2
0
def admin_home():
    menu = admin.menu()
    view = Admin(menu)
    return view.page()