def get(self): searchableClasses = models.getSearchableClasses() # They may have sent a single comma-delimited "keys" arg or a sequence of "key" args. keys = self.request.get('keys') if keys: keys = keys.split(',') else: keys = self.request.get_all('key') allObjects = \ [ self.getAuthorizedModelOfClasses(self.VIEW, searchableClasses, useKey=thisKey, returnNone=True) \ for thisKey in keys ] allObjects = [ao for ao in allObjects if ao is not None] # Sometimes we got a campaign key, but really want characters. if self.request.get('usecharacters'): characterObjects = [] [characterObjects.extend(ao.characters) for ao in allObjects] allObjects.extend(characterObjects) objectsXML = ''.join([ao.toXML() for ao in allObjects]) return self.sendXML( '<MultipleKeys>%(objectsXML)s</MultipleKeys>' % locals(), False)
def get(self): #isExternalEmbed = self.request.referrer.find(self.request.host_url) user = users.get_current_user() try: model, isMigrated = self.getAuthorizedModelOfClasses( self.VIEW, models.getSearchableClasses(), returnMigrated=True) except ValueError: return self.response.out.write(\ """ <html> <head> <link rel="stylesheet" href="/TIME_TOKEN/css/combo.css" type="text/css" media="screen, projection" /> <link rel="stylesheet" href="/TIME_TOKEN/css/blueprint/print.css" type="text/css" media="print" /> <!--[if lt IE 8]><link rel="stylesheet" href="/TIME_TOKEN/css/blueprint/ie.css" type="text/css" media="screen, projection" /><![endif]--> <script type="text/javascript" language="javascript" src="/TIME_TOKEN/js/combo.js"></script> <script> Event.observe(document, 'dom:loaded', function() { sizeParentIframeToMyContainer(20); pageAuth(); initializeEnvironmentalElements(); }); </script> </head> <body class="Page"> <div class="container"> <div id="searchBar" class="span-24 last"> <div class="span-12"> <span class="FirstLeft"> Invisible iPlay4e! </span> </div> <div class="span-12 last" style="text-align:right;"> <span class="ForeignOnly" style="display:none;margin-right: 8px;"> <b id="nicknameDisplay"></b> <script type="text/javascript" language="javascript"> registerAuthHandler(function(json) { var nameDisplay = null; if (json.nickname) nameDisplay = json.nickname; if (json.prefs && json.prefs.handle) nameDisplay = json.prefs.handle; if (nameDisplay) $('nicknameDisplay').update(nameDisplay + ' | '); }); </script> <u><a class="SignInOut list" style="text-decoration:none;" href="#"><img src="/TIME_TOKEN/images/DivLoadingSpinner.gif"/></a></u> </span> </div> </div> <div class="span-24 last"> <div class="FirstLeft" style="padding-top:20px;"> Sorry, but this iPlay4e item doesn't exist, or you aren't authorized to view it. </div> </div> <div id="paginationBar" class="span-24 last"> </div> </body> """) return self.sendXML(model.toXML(), isMigrated)
def get(self): #isExternalEmbed = self.request.referrer.find(self.request.host_url) user = users.get_current_user() try: model, isMigrated = self.getAuthorizedModelOfClasses(self.VIEW, models.getSearchableClasses(), returnMigrated=True) except ValueError: return self.response.out.write(\ """ <html> <head> <link rel="stylesheet" href="/TIME_TOKEN/css/combo.css" type="text/css" media="screen, projection" /> <link rel="stylesheet" href="/TIME_TOKEN/css/blueprint/print.css" type="text/css" media="print" /> <!--[if lt IE 8]><link rel="stylesheet" href="/TIME_TOKEN/css/blueprint/ie.css" type="text/css" media="screen, projection" /><![endif]--> <script type="text/javascript" language="javascript" src="/TIME_TOKEN/js/combo.js"></script> <script> Event.observe(document, 'dom:loaded', function() { sizeParentIframeToMyContainer(20); pageAuth(); initializeEnvironmentalElements(); }); </script> </head> <body class="Page"> <div class="container"> <div id="searchBar" class="span-24 last"> <div class="span-12"> <span class="FirstLeft"> Invisible iPlay4e! </span> </div> <div class="span-12 last" style="text-align:right;"> <span class="ForeignOnly" style="display:none;margin-right: 8px;"> <b id="nicknameDisplay"></b> <script type="text/javascript" language="javascript"> registerAuthHandler(function(json) { var nameDisplay = null; if (json.nickname) nameDisplay = json.nickname; if (json.prefs && json.prefs.handle) nameDisplay = json.prefs.handle; if (nameDisplay) $('nicknameDisplay').update(nameDisplay + ' | '); }); </script> <u><a class="SignInOut list" style="text-decoration:none;" href="#"><img src="/TIME_TOKEN/images/DivLoadingSpinner.gif"/></a></u> </span> </div> </div> <div class="span-24 last"> <div class="FirstLeft" style="padding-top:20px;"> Sorry, but this iPlay4e item doesn't exist, or you aren't authorized to view it. </div> </div> <div id="paginationBar" class="span-24 last"> </div> </body> """) return self.sendXML(model.toXML(), isMigrated)
def get(self): try: model = self.getAuthorizedModelOfClasses(self.VIEW, models.getSearchableClasses()) except ValueError: return self.jsonError('Missing iplay4e item') if model.__class__ is models.Campaign: return self.getCampaign(model) else: self.getCharacter(model)
def get(self): self.response.headers['Content-Type'] = 'text/javascript' user = users.get_current_user() try: model = self.getAuthorizedModelOfClasses(self.DELETE, models.getSearchableClasses()) except ValueError: return model.delete() if self.request.referrer.count('/search/'): return self.response.out.write('parent.location.reload();') else: return self.response.out.write('parent.location = "%s"' \ % self.request.referrer.replace('%s/main' % self.request.get('key'), ''))
def get(self): newData, currentUser = self.request.get("dnd4eData", ""), users.get_current_user() if not newData: return self.javascriptError("First choose a file from Character Builder (.dnd4e) or Monster Builder (.rtf)") if not currentUser: return self.javascriptError("Please sign in to upload files") model = self.getAuthorizedModelOfClasses(self.DELETE, models.getSearchableClasses()) model.wotcData = newData model.ip4XML = None # Finalize the model to see if the provided file was any good. try: model.buildDom(testing=True) except (ValueError, RuntimeError), errorMessage: return self.javascriptError("Invalid file - are your Builders up to date?")
def get(self): model = self.getAuthorizedModelOfClasses(self.DELETE, models.getSearchableClasses()) model.ip4XML = None # This will cause the dnd4e data to get reparsed. model.put() self.response.out.write(\ """ <html> <script type="text/javascript" language="javascript"> replaceDone = function() { window.parent.location.reload(); }; </script> </head> <body onload="replaceDone();"> </body> </html> """ % locals())
def get(self): owner = self.request.get('owner', None) if not owner: return self.javascriptError('You must supply a new email address to change the owner') try: newOwner = models.EmailToUser.emailsToGoodUsers([owner])[0] except IndexError: return self.javascriptError('Invalid email address %(email)s provided' % locals()) model = self.getAuthorizedModelOfClasses(self.ADMIN, models.getSearchableClasses(), returnNone=True) if model is None: key = self.request.get('key', None) return self.javascriptError('Invalid object key %(key)s provided' % locals()) model.owner = newOwner model.putAndUpdateCampaigns() return self.reloadTop()
def get(self): owner = self.request.get("owner", None) if not owner: return self.javascriptError("You must supply a new email address to change the owner") try: newOwner = models.EmailToUser.emailsToGoodUsers([owner])[0] except IndexError: return self.javascriptError("Invalid email address %(email)s provided" % locals()) model = self.getAuthorizedModelOfClasses(self.ADMIN, models.getSearchableClasses(), returnNone=True) if model is None: key = self.request.get("key", None) return self.javascriptError("Invalid object key %(key)s provided" % locals()) model.owner = newOwner model.putAndUpdateCampaigns() return self.reloadTop()
def get(self): retDict = {} user, url = users.get_current_user(), self.request.get( 'url', self.request.referrer) if not user: retDict['url'] = users.create_login_url(url) return self.response.out.write(simplejson.dumps(retDict)) # Most of our return keys come from the Google user proper. retDict.update({ 'url': users.create_logout_url(url), 'id': user.user_id(), 'email': user.email(), 'nickname': user.nickname(), 'isAdmin': users.is_current_user_admin() and 1 or 0, }) # Return donation-related values from the DonatingUser model. donatingUserObj = models.DonatingUser.fromUser(user) retDict.update({ 'reminderDate': str(donatingUserObj.nextDonationRequest or 0), 'hasDonated': (not donatingUserObj.nonDonating) and 1 or 0, }) # Retrieve the characters and campaigns for this user (XXX should probably be at-need for optimization...) retDict['characters'], retDict['campaigns'] = [], [] mySearch = SearchModels.SearchResult.SearchRequest().setUser(user) [ { 'Campaign': retDict['campaigns'], models.VERSIONED_CHARACTER_CLASS: retDict['characters'], }[o.modelType].append(\ { 'title':o.title, 'subtitle':o.subtitle, 'key':o.modelKey, 'isOwner':(o.owner==user and 1 or 0), }) \ for o in mySearch.setTypes([ c.__name__ for c in models.getSearchableClasses()]).get() \ ] userPrefs = models.UserPreferences.getPreferencesForUser(user) retDict['prefs'] = dict([(k, (getattr(userPrefs, k) or '')) for k in userPrefs.properties().keys() if k != 'owner']) self.response.out.write(simplejson.dumps(retDict))
def get(self): retDict = {} user, url = users.get_current_user(), self.request.get('url', self.request.referrer) if not user: retDict['url'] = users.create_login_url(url) return self.response.out.write(simplejson.dumps(retDict)) # Most of our return keys come from the Google user proper. retDict.update({ 'url': users.create_logout_url(url), 'id': user.user_id(), 'email': user.email(), 'nickname': user.nickname(), 'isAdmin': users.is_current_user_admin() and 1 or 0, }) # Return donation-related values from the DonatingUser model. donatingUserObj = models.DonatingUser.fromUser(user) retDict.update({ 'reminderDate': str(donatingUserObj.nextDonationRequest or 0), 'hasDonated': (not donatingUserObj.nonDonating) and 1 or 0, }) # Retrieve the characters and campaigns for this user (XXX should probably be at-need for optimization...) retDict['characters'], retDict['campaigns'] = [], [] mySearch = SearchModels.SearchResult.SearchRequest().setUser(user) [ { 'Campaign': retDict['campaigns'], models.VERSIONED_CHARACTER_CLASS: retDict['characters'], }[o.modelType].append(\ { 'title':o.title, 'subtitle':o.subtitle, 'key':o.modelKey, 'isOwner':(o.owner==user and 1 or 0), }) \ for o in mySearch.setTypes([ c.__name__ for c in models.getSearchableClasses()]).get() \ ] userPrefs = models.UserPreferences.getPreferencesForUser(user) retDict['prefs'] = dict([ (k,(getattr(userPrefs, k) or '')) for k in userPrefs.properties().keys() if k != 'owner' ]) self.response.out.write(simplejson.dumps(retDict))
def get(self): newData, currentUser = self.request.get('dnd4eData', ''), users.get_current_user() if not newData: return self.javascriptError( 'First choose a file from Character Builder (.dnd4e) or Monster Builder (.rtf)' ) if not currentUser: return self.javascriptError('Please sign in to upload files') model = self.getAuthorizedModelOfClasses(self.DELETE, models.getSearchableClasses()) model.wotcData = newData model.ip4XML = None # Finalize the model to see if the provided file was any good. try: model.buildDom(testing=True) except (ValueError, RuntimeError), errorMessage: return self.javascriptError( 'Invalid file - are your Builders up to date?')
def get(self): searchableClasses = models.getSearchableClasses() # They may have sent a single comma-delimited "keys" arg or a sequence of "key" args. keys = self.request.get('keys') if keys: keys = keys.split(',') else: keys = self.request.get_all('key') allObjects = \ [ self.getAuthorizedModelOfClasses(self.VIEW, searchableClasses, useKey=thisKey, returnNone=True) \ for thisKey in keys ] allObjects = [ ao for ao in allObjects if ao is not None ] # Sometimes we got a campaign key, but really want characters. if self.request.get('usecharacters'): characterObjects = [] [ characterObjects.extend(ao.characters) for ao in allObjects ] allObjects.extend(characterObjects) objectsXML = ''.join([ ao.toXML() for ao in allObjects ]) return self.sendXML('<MultipleKeys>%(objectsXML)s</MultipleKeys>' % locals(), False)
def get(self): model = self.getAuthorizedModelOfClasses(self.DELETE, models.getSearchableClasses()) model.isPublic = True model.put() self.redirect(self.request.referrer)