Esempio n. 1
0
 def get(self):
     outlets = Outlet.all().filter('target =', self.account).fetch(100)
     if len(self.request.path.split('/')) > 2:
         source = Account.get_by_hash(self.request.path.split('/')[-1])
         channel = Channel.get_by_source_and_target(source, self.account)
         self.render('templates/source.html', locals())
     else:
         enabled_channels = Channel.get_all_by_target(self.account).order('-count').filter('status =', 'enabled')
         self.render('templates/sources.html', locals())
Esempio n. 2
0
    def initialize(self, request, response):
        super(RequestHandler, self).initialize(request, response)
        self.user = users.get_current_user()
        if self.user:
            self.login_url = None
            self.logout_url = users.create_logout_url("/")
            self.account = Account.all().filter("user ="******"DesktopNotifier")
                o.set_name("Default Desktop Notifier")
                o.put()

            # This is to update existing accounts before outlets
            if not self.account.get_default_outlet():
                # Create default Desktop Notifier
                o = Outlet(target=self.account, type_name="DesktopNotifier")
                o.set_name("Default Desktop Notifier")
                o.put()
                for channel in Channel.get_all_by_target(self.account):
                    if not channel.outlet:
                        channel.outlet = o
                        channel.put()

        else:
            self.logout_url = None
            self.account = None
            self.login_url = users.create_login_url(request.path)

        # Hide the Get Started tip
        if request.query_string == "hide":
            self.account.started = True
            self.account.put()
Esempio n. 3
0
    def get(self):
        if self.request.path.endswith(".ListenURL"):
            filename = self.request.path.split("/")[-1]
            outlet = filename.split(".")[0]

            self.account.started = True
            self.account.put()

            self.response.headers["Content-Type"] = "text/plain"
            self.response.headers["Content-disposition"] = "attachment; filename=%s.ListenURL" % outlet
            self.response.out.write("http://%s/%s/listen/%s\n" % (API_HOST, API_VERSION, outlet))
        else:
            types = outlet_types.all
            outlets = Outlet.all().filter("target =", self.account)
            self.render("templates/outlets.html", locals())
Esempio n. 4
0
    def get(self):
        if self.request.path.endswith('.ListenURL'):
            filename = self.request.path.split('/')[-1]
            outlet = filename.split('.')[0]
            
            self.account.started = True
            self.account.put()

            self.response.headers['Content-Type'] = 'text/plain'
            self.response.headers['Content-disposition'] = 'attachment; filename=%s.ListenURL' % outlet
            self.response.out.write("http://%s/%s/listen/%s\n" % (API_HOST, API_VERSION, outlet))
        else:
            types = outlet_types.all
            outlets = Outlet.all().filter('target =', self.account)
            self.render('templates/outlets.html', locals())
Esempio n. 5
0
 def get(self):
     outlets = Outlet.all().filter("target =", self.account).fetch(100)
     if len(self.request.path.split("/")) > 2:
         source = Account.get_by_hash(self.request.path.split("/")[-1])
         channel = Channel.get_by_source_and_target(source, self.account)
         self.render("templates/source.html", locals())
     else:
         enabled_channels = Channel.get_all_by_target(self.account).order("-count").filter("status =", "enabled")
         # TODO: remove me after a while. this is to fix my poor reference management
         for c in enabled_channels:
             try:
                 c.outlet
             except:
                 c.outlet = None
                 c.put()
         self.render("templates/sources.html", locals())
Esempio n. 6
0
    def get(self):
        if self.request.path.endswith('.ListenURL'):
            filename = self.request.path.split('/')[-1]
            outlet = filename.split('.')[0]

            self.account.started = True
            self.account.put()

            self.response.headers['Content-Type'] = 'text/plain'
            self.response.headers[
                'Content-disposition'] = 'attachment; filename=%s.ListenURL' % outlet
            self.response.out.write("http://%s/%s/listen/%s\n" %
                                    (API_HOST, API_VERSION, outlet))
        else:
            types = outlet_types.all
            outlets = Outlet.all().filter('target =', self.account)
            self.render('templates/outlets.html', locals())
Esempio n. 7
0
 def get(self):
     outlets = Outlet.all().filter('target =', self.account).fetch(100)
     if len(self.request.path.split('/')) > 2:
         source = Account.get_by_hash(self.request.path.split('/')[-1])
         channel = Channel.get_by_source_and_target(source, self.account)
         self.render('templates/source.html', locals())
     else:
         enabled_channels = Channel.get_all_by_target(
             self.account).order('-count').filter('status =', 'enabled')
         # TODO: remove me after a while. this is to fix my poor reference management
         for c in enabled_channels:
             try:
                 c.outlet
             except:
                 c.outlet = None
                 c.put()
         self.render('templates/sources.html', locals())
Esempio n. 8
0
    def post(self):
        action = self.request.get("action")
        source = Account.get_by_hash(self.request.get("source"))
        channel = Channel.get_by_source_and_target(source, self.account)
        if action == "approve":
            channel.status = "enabled"
            channel.put()
        elif action == "delete":
            channel.delete()
        elif action == "route":
            outlet = Outlet.get_by_hash(self.request.get("outlet"))
            channel.outlet = outlet
            channel.put()

        if "return" in self.request.query_string:
            self.redirect("/sources/%s" % self.request.get("source"))
        else:
            self.redirect("/sources")
Esempio n. 9
0
 def post(self):
     action = self.request.get('action')
     source = Account.get_by_hash(self.request.get('source'))
     channel = Channel.get_by_source_and_target(source, self.account)
     if action == 'approve':
         channel.status = 'enabled'
         channel.put()
     elif action == 'delete':
         channel.delete()
     elif action == 'route':
         outlet = Outlet.get_by_hash(self.request.get('outlet'))
         channel.outlet = outlet
         channel.put()
         
     if 'return' in self.request.query_string:
         self.redirect('/sources/%s' % self.request.get('source'))
     else:
         self.redirect('/sources')
Esempio n. 10
0
    def post(self):
        action = self.request.get('action')
        source = Account.get_by_hash(self.request.get('source'))
        channel = Channel.get_by_source_and_target(source, self.account)
        if action == 'approve':
            channel.status = 'enabled'
            channel.put()
        elif action == 'delete':
            channel.delete()
        elif action == 'route':
            outlet = Outlet.get_by_hash(self.request.get('outlet'))
            channel.outlet = outlet
            channel.put()

        if 'return' in self.request.query_string:
            self.redirect('/sources/%s' % self.request.get('source'))
        else:
            self.redirect('/sources')
Esempio n. 11
0
 def get_default_outlet(self):
     return Outlet.all().filter("target =", self).filter("type_name =", "DesktopNotifier").order("-created").get()
Esempio n. 12
0
 def post(self):
     action = self.request.get("action")
     if action == "add":
         o = Outlet(target=self.account, type_name=self.request.get("type"))
         o.setup(self.request.POST)
         o.put()
     elif action == "remove":
         o = Outlet.get_by_hash(self.request.get("outlet"))
         o.delete()
     elif action == "rename":
         name = self.request.get("name")
         if name:
             o = Outlet.get_by_hash(self.request.get("outlet"))
             o.name = name
             o.put()
     self.redirect("/outlets")
Esempio n. 13
0
 def post(self):
     action = self.request.get('action')
     if action == 'add':
         o = Outlet(target=self.account, type_name=self.request.get('type'))
         o.setup(self.request.POST)
         o.put()
     elif action == 'remove':
         o = Outlet.get_by_hash(self.request.get('outlet'))
         o.delete()
     elif action == 'rename':
         name = self.request.get('name')
         if name:
             o = Outlet.get_by_hash(self.request.get('outlet'))
             o.name = name
             o.put()
     self.redirect('/outlets')
Esempio n. 14
0
    def initialize(self, request, response):
        super(RequestHandler, self).initialize(request, response)
        self.user = users.get_current_user()
        if self.user:
            self.login_url = None
            self.logout_url = users.create_logout_url('/')
            self.account = Account.all().filter('user ='******'DesktopNotifier')
                o.set_name("Default Desktop Notifier")
                o.put()

            # This is to update existing accounts before outlets
            if not self.account.get_default_outlet():
                # Create default Desktop Notifier
                o = Outlet(target=self.account, type_name='DesktopNotifier')
                o.set_name("Default Desktop Notifier")
                o.put()
                for channel in Channel.get_all_by_target(self.account):
                    if not channel.outlet:
                        channel.outlet = o
                        channel.put()

        else:
            self.logout_url = None
            self.account = None
            self.login_url = users.create_login_url(request.path)

        # Hide the Get Started tip
        if request.query_string == 'hide':
            self.account.started = True
            self.account.put()
Esempio n. 15
0
 def get_default_outlet(self):
     return Outlet.all().filter('target =', self).filter(
         'type_name =', 'DesktopNotifier').order('-created').get()
Esempio n. 16
0
 def post(self):
     action = self.request.get('action')
     if action == 'add':
         o = Outlet(target=self.account, type_name=self.request.get('type'))
         o.setup(self.request.POST)
         o.put()
     elif action == 'remove':
         o = Outlet.get_by_hash(self.request.get('outlet'))
         o.delete()
     elif action == 'rename':
         name = self.request.get('name')
         if name:
             o = Outlet.get_by_hash(self.request.get('outlet'))
             o.name = name
             o.put()
     self.redirect('/outlets')