diff --git a/webapp/main.py b/webapp/main.py index 700c41e..0b0cd82 100755 --- a/webapp/main.py +++ b/webapp/main.py @@ -99,7 +99,7 @@ def get(self, pagename=None): values.update( {'total_size':slide_stat.total_size} ) # storage stats - total_micro = (float(values['total_size']) / 1024**2)*100 + total_micro = int((float(values['total_size']) / 1024**2)*100) values.update( {'total_micro': range(total_micro)} ) values.update( {'remaining_micro': range(100-total_micro)} ) @@ -130,6 +130,36 @@ def get(self, pagename=None): helpers.render(self, "overview.html",values) return + if pagename in ['/machines','/machines/']: + # --------------------------------------------------------------- + # Machines Page + # --------------------------------------------------------------- + total_machines = Machines.all().count() + values.update ( {'total_machines': total_machines} ) + + if total_machines>0: + values.update({'machines_start':Machines.all().order('created').fetch(1)[0].created}) + values.update( {'machines':Machines.all().fetch(1000)} ) + else: + values.update({'machines_start':'a time unknown'}) + + helpers.render(self, "machines.html",values) + return + + def post(self, pagename=None): + if not users.is_current_user_admin(): + self.redirect("/") + + if pagename == '/machines/add': + # --------------------------------------------------------------- + # Add Machines + # --------------------------------------------------------------- + name = self.request.get('name') + machine = Machines(name=name, enabled=True, passphrase=helpers.gimme_garbage(12)) + machine.put() + + self.redirect('/home/machines') + def main(): diff --git a/webapp/models.py b/webapp/models.py index 28dfceb..126f22d 100644 --- a/webapp/models.py +++ b/webapp/models.py @@ -13,4 +13,5 @@ class SlideStats(db.Model): class Machines(db.Model): name = db.StringProperty() enabled = db.BooleanProperty() - passphrase = db.StringProperty() \ No newline at end of file + passphrase = db.StringProperty() + created = db.DateTimeProperty(auto_now_add=True) \ No newline at end of file diff --git a/webapp/models.pyc b/webapp/models.pyc index 9babe98..54ea0ba 100644 Binary files a/webapp/models.pyc and b/webapp/models.pyc differ diff --git a/webapp/static/style.css b/webapp/static/style.css index 0af5066..8e8280e 100644 --- a/webapp/static/style.css +++ b/webapp/static/style.css @@ -89,4 +89,10 @@ body{ #over_stats{ padding:0px 40px; font-size:1.6em; -} \ No newline at end of file +} + +#machine_list input { border: 1px solid #aaa; width:100%;} +#machine_list .m_head { width:auto; margin:0px 20px; font-size:1.4em; } +#machine_list p {text-align:center; } +#machine_list .m_head span { border-right:1px solid #aaa; } +#machine_list p span { display:inline-block; padding:2px 10px; width:15%; } \ No newline at end of file diff --git a/webapp/views/skeleton.html b/webapp/views/skeleton.html index bb9d85e..021b856 100644 --- a/webapp/views/skeleton.html +++ b/webapp/views/skeleton.html @@ -19,10 +19,10 @@ {% block menu %}