예제 #1
0
    def post(self):
        """Handles POST /upload"""
        if self.logged_in and self.current_user.uploader is True:
            filename = self.request.params['data'].filename
            faction_key = int(self.request.get('faction'))
            faction_name = factions.get(faction_key)
            server = self.request.get('server')
            variables = {
                'name': self.current_user.name,
                'filename': filename,
                'server': server,
                'factions': factions,
                'faction': faction_name,
                'servers': None,
                'newData': False,
                'error_faction': False,
                'error_server': False,
                'success': False
            }
            # Filename
            if filename != 'LSE-addon.json':
                self.abort(400)

            ah_data = json.loads(self.request.get('data'))
            # Faction
            if ah_data['LSE']['faction'] != faction_name:
                self.response.write(faction)
                self.response.write(ah_data['LSE']['faction'])
                variables['error_faction'] = True
            # Server
            if ah_data['LSE']['server'] != server:
                variables['error_server'] = True

            if self.current_user.upload_server == 'All':
                variables['servers'] = servers

            if variables.get('error_faction') == False and variables.get(
                    'error_server') == False:
                variables['success'] = True
                scan_date = ah_data['LSE']['date']
                ah = AuctionHouse.query(
                    AuctionHouse.server_name == server,
                    AuctionHouse.faction == faction_key).get()
                if ah.auctions:
                    ah.auctions.update(ah_data['auctions'])
                else:
                    ah.auctions = ah_data['auctions']
                ah.put()

            self.render('upload.html', variables)
        else:
            self.abort(403)
예제 #2
0
 def get(self):
     """Handles GET /settings"""
     if self.logged_in:
         variables = {
             'name': self.current_user.name,
             'server': self.current_user.server,
             'faction': factions.get(self.current_user.faction),
             'servers': servers,
             'factions': factions,
         }
         self.render('settings.html', variables)
     else:
         self.redirect('/sign_in')
예제 #3
0
 def get(self):
     """Handles GET /profile"""
     if self.logged_in:
         variables = {
             'name': self.current_user.name,
             'server': self.current_user.server,
             'faction': factions.get(self.current_user.faction),
             'admin': False,
             'uploader': False
         }
         if self.current_user.admin:
             variables['admin'] = True
         if self.current_user.uploader:
             variables['uploader'] = True
         self.render('profile.html', variables)
     else:
         self.redirect('/')
예제 #4
0
 def post(self):
     if self.logged_in:
         updated_server = self.request.get('server')
         updated_faction = self.request.get('faction')
         self.current_user.server = updated_server
         self.current_user.faction = int(updated_faction)
         self.current_user.put()
         variables = {
             'name': self.current_user.name,
             'server': self.current_user.server,
             'faction': factions.get(self.current_user.faction),
             'servers': servers,
             'factions': factions,
         }
         self.render('settings.html', variables)
     else:
         self.redirect('/sign_in')
예제 #5
0
 def get(self):
     """Handles default landing page"""
     if self.logged_in:
         self.render(
             'home.html', {
                 'name': self.current_user.name,
                 'server': self.current_user.server,
                 'faction': factions.get(self.current_user.faction),
                 'home': True,
                 'page_id': 'home'
             })
     else:
         self.render(
             'home.html', {
                 'servers': servers,
                 'factions': factions,
                 'destination_url': '/settings',
                 'home': True,
                 'page_id': 'home'
             })