示例#1
0
 def post(self, author, plando):
     user = users.get_current_user()
     if user:
         dispname = user.email().partition("@")[0]
         if dispname == author:
             id = author + ":" + plando
             seedLines = self.request.POST["seed"]
             desc = self.request.POST["desc"]
             old_name = paramVal(self, "old_name")
             seed = Seed.from_plando(seedLines.split("!"), author, plando,
                                     desc)
             res = seed.put()
             if res and old_name and old_name != plando:
                 old_seed = Seed.get_by_id("%s:%s" % (author, old_name))
                 if not old_seed:
                     print "ERROR: couldn't find old seed when trying to rename!"
                 else:
                     old_seed.key.delete()
             self.response.headers['Content-Type'] = 'text/plain'
             self.response.status = 200
             self.response.out.write(res)
         else:
             print "ERROR: Auth failed, logged in as %s, trying to edit %s's seed" % (
                 dispname, author)
             self.response.status = 401
     else:
         print "ERROR: no auth D:"
         self.response.status = 401
示例#2
0
 def get(self, author, plando):
     path = os.path.join(os.path.dirname(__file__), 'map/build/index.html')
     template_values = {
         'app': "plandoBuilder",
         'title': "Plandomizer Editor " + PLANDO_VER,
         'seed_name': plando
     }
     owner = False
     user = users.get_current_user()
     if user:
         dispname = user.email().partition("@")[0]
         owner = dispname == author
     id = author + ":" + plando
     if not owner:
         self.redirect('/login')
     else:
         seed = Seed.get_by_id(id)
         template_values['user'] = dispname
         template_values['authed'] = "True"
         if seed:
             template_values['seed_desc'] = seed.description
             template_values['seed_hidden'] = seed.hidden or False
             template_values['seed_data'] = "\n".join(
                 seed.to_plando_lines())
         self.response.out.write(template.render(path, template_values))
示例#3
0
    def get(self, author, plando):
        user = users.get_current_user()
        dispname = "Guest"
        if user:
            dispname = user.email().partition("@")[0]
        id = author + ":" + plando
        seed = Seed.get_by_id(id)
        if seed:
            hidden = seed.hidden or False
            if not (hidden and dispname != author):
                self.response.status = 200
                self.response.headers['Content-Type'] = 'text/html'
                path = os.path.join(os.path.dirname(__file__),
                                    'map/build/index.html')
                template_values = {
                    'app': "seedDisplay",
                    'title': "%s by %s" % (plando, author),
                    'players': seed.players,
                    'seed_data': seed.to_lines()[0],
                    'seed_name': plando,
                    'author': author,
                    'authed': True,
                    'seed_desc': seed.description,
                    'user': dispname,
                    'game_id': get_open_gid()
                }
                if hidden:
                    template_values['seed_hidden'] = True

                self.response.out.write(template.render(path, template_values))
                return
        self.response.status = 404
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write("seed not found")
示例#4
0
 def get(self, author, old_name, new_name):
     user = users.get_current_user()
     if user:
         dispname = user.email().partition("@")[0]
         if dispname == author:
             old_seed = Seed.get_by_id("%s:%s" % (author, old_name))
             if not old_seed:
                 print "ERROR: couldn't find old seed when trying to rename!"
                 self.response.status = 404
                 return
             new_seed = clone_entity(old_seed,
                                     id="%s:%s" % (author, new_name),
                                     name=new_name)
             if new_seed.put():
                 if not paramFlag(self, "cp"):
                     old_seed.key.delete()
                 self.redirect('/plando/%s/%s' % (author, new_name))
             else:
                 print "ERROR: Failed to rename seed"
                 self.response.status = 500
         else:
             print "ERROR: Auth failed, logged in as %s, trying to edit %s's seed" % (
                 dispname, author)
             self.response.status = 401
     else:
         print "ERROR: no auth D:"
         self.response.status = 401
示例#5
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        seeds = Seed.query(Seed.hidden != True)

        out = '<html><head><title>All Plando Authors</title></head><body><h5>All Seeds</h5><ul style="list-style-type:none;padding:5px">'
        authors = Counter([seed.author for seed in seeds])
        for author, cnt in authors.most_common():
            if cnt > 0:
                url = "%s/plando/%s" % (base_site, author)
                out += '<li style="padding:2px"><a href="%s">%s</a> (%s plandos)</li>' % (
                    url, author, cnt)
        out += "</ul></body></html>"
        self.response.out.write(out)
示例#6
0
 def get(self, author, seed_name):
     user = users.get_current_user()
     if user:
         dispname = user.email().partition("@")[0]
         if dispname == author:
             seed = Seed.get_by_id("%s:%s" % (author, seed_name))
             if seed:
                 seed.key.delete()
                 self.redirect('/plando/%s' % author)
             else:
                 print "ERROR: couldn't find seed!"
                 self.response.status = 404
         else:
             print "ERROR: Auth failed, logged in as %s, trying to edit %s's seed" % (
                 dispname, author)
             self.response.status = 401
     else:
         print "ERROR: no auth D:"
         self.response.status = 401
示例#7
0
 def get(self, author, plando):
     owner = False
     user = users.get_current_user()
     if user:
         dispname = user.email().partition("@")[0]
         owner = dispname == author
     id = author + ":" + plando
     seed = Seed.get_by_id(id)
     if seed:
         gid = paramVal(self, "gid")
         pid = paramVal(self, "pid")
         syncFlag = "Sync%s.%s" % (gid, pid)
         self.response.status = 200
         self.response.headers['Content-Type'] = 'application/x-gzip'
         self.response.headers[
             'Content-Disposition'] = 'attachment; filename=randomizer.dat'
         self.response.out.write("\n".join(
             seed.to_lines(player=int(pid), extraFlags=[syncFlag])))
     else:
         self.response.status = 404
         self.response.headers['Content-Type'] = 'text/plain'
         self.response.out.write("seed not found")
示例#8
0
    def get(self, author):
        self.response.headers['Content-Type'] = 'text/html'
        owner = False
        user = users.get_current_user()
        if user:
            dispname = user.email().partition("@")[0]
            owner = dispname == author

        query = Seed.query(Seed.author == author)
        if not owner:
            query = query.filter(Seed.hidden != True)
        seeds = query.fetch()

        if len(seeds):
            out = '<html><head><title>Seeds by %s</title></head><body><div>Seeds by %s:</div><ul style="list-style-type:none;padding:5px">' % (
                author, author)
            for seed in seeds:
                url = "%s/plando/%s/%s" % (base_site, author, seed.name)
                flags = ",".join(seed.flags)
                out += '<li style="padding:2px"><a href="%s">%s</a>: %s (%s players, %s)' % (
                    url, seed.name, seed.description, seed.players, flags)
                if owner:
                    out += ' <a href="%s/edit">Edit</a>' % url
                    if seed.hidden:
                        out += " (hidden)"
                out += "</li>"
            out += "</ul></body></html>"
            self.response.write(out)
        else:
            if owner:
                self.response.write(
                    "<html><body>You haven't made any seeds yet! <a href='/plando/%s/newseed/edit'>Start a new seed</a></body></html>"
                    % author)
            else:
                self.response.write(
                    '<html><body>No seeds by user %s</body></html>' % author)
示例#9
0
                    ['entidad_federativa_nacimiento']['cve_agee'])
            }
            # CURP and RFC Fix
            data['informacion_general']['curp'] = generate.GenerateCURP(
                **kwargs).data
            # RFC
            data['informacion_general']['rfc'] = generate.GenerateRFC(
                **kwargs).data
            return data

        with benchmark('data faker'):

            document_samples = Seed(
                name='samples',
                props={'s': number_of_samples * years},
                state={'count1': 0},
                next_state=lambda seed: {'count1': seed.state.count + 1},
                initial_value=lambda seed, node: number_of_samples * years,
                next_value=lambda seed, node: seed.value
                if seed.state.count1 % seed.props.s != 0 else seed.reset(node))

            personal_info = Seed(
                name='informacion_personal',
                props={'y': years + 1},
                state={'count2': 1},
                next_state=lambda seed: {'count2': seed.state.count2 + 1},
                initial_value=get_initial_pi,
                next_value=next_personal_info)

            data_faker = DataFaker(path_to_file, path_to_schema,
                                   path_to_catalogs)
            data_faker.add_seed(document_samples)