Ejemplo n.º 1
0
    def get(self, number):
        if not isAdmin(): return self.redirect('/')

        if isMasterDB():
            return self.redirect('/')

        number = int(number)
        q = taskqueue.Queue('populate')

        def enqueue(start, end):
            params = {"start": start, "end": end}
            q.add(
                taskqueue.Task(url='/dashboard/__db_populate/worker',
                               params=params))

        start = 0
        end = 0
        batchSize = 40  #just copying nate

        for i in range(batchSize, number, batchSize):
            end = i
            enqueue(start, end)
            start = end

        if end < number:
            enqueue(end, number)

        self.response.write("Enqueued {0} hackers.".format(number))
Ejemplo n.º 2
0
	def post(self):
		if not isAdmin(): return self.redirect('/')
		audience = None if self.request.get('audience') == '' else self.request.get('audience')
		message = Message(audience=audience)
		if self.request.get('email'):
			message.email_subject = self.request.get('email-subject')
			if self.request.get('email-name'):
				message.email_from_template = True
				message.email_html = self.request.get('email-name')
			else:
				message.email_html = self.request.get('email-html')
		if self.request.get('sms'):
			message.sms_text = self.request.get('sms-text')
		if self.request.get('show-in-day-of'):
			message.day_of_html = self.request.get('day-of-html')
			message.show_in_day_of = True
		if self.request.get('test'):
			recip = self.request.get('test-recipient')
			if '@' in recip:
				message.send_to_email(recip)
				self.response.write("Sent email")
			elif len(recip) > 0:
				message.send_to_phone(recip)
				self.response.write("Sent SMS")
		else:
			message.put()
			message.kick_off()
			self.response.write(template("messages_dashboard.html", {"status": "Sent!"}))
Ejemplo n.º 3
0
    def get(self, number):
        if not isAdmin():
            return self.redirect("/")

        if isMasterDB():
            return self.redirect("/")

        number = int(number)
        q = taskqueue.Queue("populate")

        def enqueue(start, end):
            params = {"start": start, "end": end}
            q.add(taskqueue.Task(url="/dashboard/__db_populate/worker", params=params))

        start = 0
        end = 0
        batchSize = 40  # just copying nate

        for i in range(batchSize, number, batchSize):
            end = i
            enqueue(start, end)
            start = end

        if end < number:
            enqueue(end, number)

        self.response.write("Enqueued {0} hackers.".format(number))
 def get(self):
     logging.info("HIT HANDLER")
     if config.isAdmin():
         deferred.defer(updateSchema)
         self.response.out.write('Schema migration successfully initiated.')
     else:
         self.response.out.write("Must be an admin")
Ejemplo n.º 5
0
 def get(self):
     logging.info("HIT HANDLER")
     if config.isAdmin():
         deferred.defer(updateSchema)
         self.response.out.write('Schema migration successfully initiated.')
     else:
         self.response.out.write("Must be an admin")
Ejemplo n.º 6
0
    def get(self, number):
        if not isAdmin(): return self.redirect('/')

        if isMasterDB():
            return self.redirect('/')

        number = int(number)

        ndb.delete_multi(Hacker.query().fetch(limit=number, keys_only=True))
        self.response.write("Eliminated {0} hackers.".format(number))
Ejemplo n.º 7
0
    def get(self, number):
        if not isAdmin():
            return self.redirect("/")

        if isMasterDB():
            return self.redirect("/")

        number = int(number)

        ndb.delete_multi(Hacker.query().fetch(limit=number, keys_only=True))
        self.response.write("Eliminated {0} hackers.".format(number))
Ejemplo n.º 8
0
    def get(self):
        if not onTeam(): return self.redirect('/')

        keys = list(set(list(hacker_keys) + list(personal_info_keys) + list(non_required_keys) + ['status', 'admit_priority', 'rsvpd', 'checked_in', 'has_resume', 'secret', 'address1', 'address2', 'city', 'state', 'country', 'zip']))
        if (not self.request.get('include_personally_identifiable_info')) or not isAdmin():
            for key in personal_info_keys:
                keys.remove(key)
        self.response.headers['Content-Type'] = 'text/csv; charset=utf-8'
        writer = csv.DictWriter(self.response, fieldnames=keys)
        writer.writeheader()
        for hacker in Hacker.query():
          writer.writerow({key: unicode(val).encode('utf-8') for key, val in hacker.asDict(keys).iteritems()})
Ejemplo n.º 9
0
def _session():
    if isLoggedIn() and isAdmin():
        u = User.query.get(session["uid"])
        form = SessionForm(request.form)
        if form.validate_on_submit():
            s = Session(form.count.data)
            db.session.add(s)
            db.session.commit()
        return render_template("session.html",
                               scores=getSessionScores(),
                               user=u,
                               form=form)
    else:
        return redirect(url_for("login"))
Ejemplo n.º 10
0
    def get(self):

        if not onTeam():
            logging.info("Not authorized")
            return self.redirect('/')

        isQA = envIsQA()
        isDev = envIsDev()

        self.response.write(
            template(
                "dashboard.html", {
                    "envIsDev": isDev,
                    "isQA": isQA,
                    "admin": isAdmin(),
                    "onTeam": onTeam(),
                    "logout": users.create_logout_url('/')
                }))
Ejemplo n.º 11
0
    def post(self):
        if not isAdmin(): return self.redirect('/')
        parsed_request = json.loads(self.request.body) # Angular apparently only sends json as text not as 'JSON'
        emails = parsed_request.get('emails')
        for address in emails:
            hacker = Hacker.query(Hacker.email == address).fetch()
            if hacker:
                for h in hacker: # should only be one
                    if parsed_request.get('change') == "Accept":
                        if h.admitted_email_sent_date == None:
                            accept_hacker(h)

                    if parsed_request.get('change') == "Remove":
                        deletedHacker.createDeletedHacker(h, "manual")
                        h.key.delete()

                    if parsed_request.get('change') == 'Waitlist':
                        if h.admitted_email_sent_date == None:
                            waitlist_hacker(h)
Ejemplo n.º 12
0
    def post(self):
        if not isAdmin(): return self.redirect('/')
        parsed_request = json.loads(
            self.request.body
        )  # Angular apparently only sends json as text not as 'JSON'
        emails = parsed_request.get('emails')
        for address in emails:
            hacker = Hacker.query(Hacker.email == address).fetch()
            if hacker:
                for h in hacker:  # should only be one
                    if parsed_request.get('change') == "Accept":
                        if h.admitted_email_sent_date == None:
                            accept_hacker(h)

                    if parsed_request.get('change') == "Remove":
                        deletedHacker.createDeletedHacker(h, "manual")
                        h.key.delete()

                    if parsed_request.get('change') == 'Waitlist':
                        if h.admitted_email_sent_date == None:
                            waitlist_hacker(h)
Ejemplo n.º 13
0
	def get(self):
		if not isAdmin(): return self.redirect('/')
		self.response.write(template("messages_dashboard.html", {}))
Ejemplo n.º 14
0
 def get(self):
   if not isAdmin(): return self.redirect('/')
   self.response.write(template("ranking.html"))
Ejemplo n.º 15
0
    def get(self):

        if not onTeam():
            logging.info("Not authorized")
            return self.redirect('/')

        isQA = envIsQA()
        isDev = envIsDev()

        self.response.write(template("dashboard.html", {"envIsDev" : isDev, "isQA" : isQA, "admin" : isAdmin(), "onTeam" : onTeam(), "logout" : users.create_logout_url('/')}))
Ejemplo n.º 16
0
 def get(self):
     if not isAdmin(): return self.redirect('/')
     self.response.write(template("ranking.html"))
Ejemplo n.º 17
0
def _choose():
    if isLoggedIn() and isAdmin():
        u = User.query.get(session["uid"])
        return render_template("choose.html", user=u)
    else:
        return redirect(url_for("login"))