Initial commit

This commit is contained in:
Lance Edgar 2017-03-28 23:14:50 -05:00
commit 06be2e2122
20 changed files with 403 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
rattail_tempmon_demo.egg-info/

8
MANIFEST.in Normal file
View file

@ -0,0 +1,8 @@
# -*- mode: conf -*-
include *.rst
recursive-include rattail_tempmon_demo/web/static *.css
recursive-include rattail_tempmon_demo/web/static *.js
recursive-include rattail_tempmon_demo/web/templates *.mako

7
README.rst Normal file
View file

@ -0,0 +1,7 @@
rattail-tempmon-demo
====================
This is a simple demo for Rattail Tempmon. See the `Rattail website`_ for more info.
.. _`Rattail website`: https://rattailproject.org/

View file

@ -0,0 +1,8 @@
# -*- coding: utf-8; -*-
"""
Rattail Tempmon Demo package root
"""
from __future__ import unicode_literals, absolute_import
from ._version import __version__

View file

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
__version__ = u'0.1.0'

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8; -*-
"""
Rattail config extension
"""
from __future__ import unicode_literals, absolute_import
from rattail.config import ConfigExtension
class RattailTempmonDemoConfig(ConfigExtension):
"""
Rattail config extension for Rattail Tempmon Demo
"""
key = 'rattail_tempmon_demo'
def configure(self, config):
# set some default config values
config.setdefault('rattail.mail', 'emails', 'rattail_tempmon_demo.emails')

View file

@ -0,0 +1,11 @@
# -*- coding: utf-8; -*-
"""
Custom email profiles
"""
from __future__ import unicode_literals, absolute_import
from rattail.mail import Email
# bring in some common ones from rattail
from rattail.emails import datasync_error_watcher_get_changes, filemon_action_error

View file

View file

@ -0,0 +1,35 @@
# -*- coding: utf-8; -*-
"""
Rattail Tempmon Demo web app
"""
from __future__ import unicode_literals, absolute_import
from tailbone import app
def main(global_config, **settings):
"""
This function returns a Pyramid WSGI application.
"""
# set some defaults for PostgreSQL
app.provide_postgresql_settings(settings)
# prefer Rattail Tempmon Demo templates over Tailbone; use 'better' theme
settings.setdefault('mako.directories', ['rattail_tempmon_demo.web:templates',
'tailbone:templates/themes/better',
'tailbone:templates',])
# make config objects
rattail_config = app.make_rattail_config(settings)
pyramid_config = app.make_pyramid_config(settings)
# bring in the rest of Rattail Tempmon Demo
pyramid_config.include('rattail_tempmon_demo.web.static')
pyramid_config.include('rattail_tempmon_demo.web.subscribers')
pyramid_config.include('rattail_tempmon_demo.web.views')
# configure PostgreSQL some more
app.configure_postgresql(pyramid_config)
return pyramid_config.make_wsgi_app()

View file

@ -0,0 +1,9 @@
# -*- coding: utf-8; mode: python -*-
"""
Static assets
"""
def includeme(config):
config.include('tailbone.static')
config.add_static_view('rattail_tempmon_demo', 'rattail_tempmon_demo.web:static', cache_max_age=3600)

View file

@ -0,0 +1,18 @@
# -*- coding: utf-8; mode: python -*-
"""
Pyramid event subscribers
"""
from __future__ import unicode_literals, absolute_import
import rattail_tempmon_demo
def add_rattail_tempmon_demo_to_context(event):
renderer_globals = event
renderer_globals['rattail_tempmon_demo'] = rattail_tempmon_demo
def includeme(config):
config.include('tailbone.subscribers')
config.add_subscriber(add_rattail_tempmon_demo_to_context, 'pyramid.events.BeforeRender')

View file

@ -0,0 +1,18 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/themes/better/base.mako" />
<%def name="app_title()">Tempmon Demo</%def>
<%def name="favicon()">
<link rel="icon" type="image/x-icon" href="${request.static_url('tailbone:static/img/rattail.ico')}" />
</%def>
<%def name="header_logo()">
${h.image(request.static_url('tailbone:static/img/rattail.ico'), "Header Logo", height='49')}
</%def>
<%def name="footer()">
${h.link_to("Tempmon Demo {}{}".format(rattail_tempmon_demo.__version__, '' if request.rattail_config.production() else '+dev'), url('about'))}
</%def>
${parent.body()}

View file

@ -0,0 +1,12 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/home.mako" />
<%def name="title()">Home</%def>
<div class="logo">
${h.image(request.static_url('tailbone:static/img/home_logo.png'), "Rattail Logo")}
</div>
<h1 style="text-align: center;">Welcome to the Tempmon Demo</h1>

View file

@ -0,0 +1,17 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/login.mako" />
<%def name="extra_styles()">
${parent.extra_styles()}
<style type="text/css">
#logo {
margin: 40px auto;
}
</style>
</%def>
<%def name="logo()">
${h.image(request.static_url('tailbone:static/img/home_logo.png'), "Rattail Logo", id='logo')}
</%def>
${parent.body()}

View file

@ -0,0 +1,63 @@
## -*- coding: utf-8 -*-
<%def name="main_menu_items()">
% if request.has_any_perm('tempmon.clients.list', 'tempmon.probes.list', 'tempmon.readings.list'):
<li>
<a>Tempmon</a>
<ul>
% if request.has_perm('tempmon.clients.list'):
<li>${h.link_to("Clients", url('tempmon.clients'))}</li>
% endif
% if request.has_perm('tempmon.probes.list'):
<li>${h.link_to("Probes", url('tempmon.probes'))}</li>
% endif
% if request.has_perm('tempmon.readings.list'):
<li>${h.link_to("Readings", url('tempmon.readings'))}</li>
% endif
</ul>
</li>
% endif
% if request.has_any_perm('people.list', 'users.list', 'roles.list', 'settings.list', 'emailprofiles.list'):
<li>
<a>Admin</a>
<ul>
% if request.has_perm('people.list'):
<li>${h.link_to("People", url('people'))}</li>
% endif
% if request.has_perm('users.list'):
<li>${h.link_to("Users", url('users'))}</li>
% endif
% if request.has_perm('roles.list'):
<li>${h.link_to("Roles", url('roles'))}</li>
% endif
% if request.has_perm('settings.list'):
<li>${h.link_to("Settings", url('settings'))}</li>
% endif
% if request.has_perm('emailprofiles.list'):
<li>${h.link_to("Email Profiles", url('emailprofiles'))}</li>
% endif
</ul>
</li>
% endif
% if request.user:
<li>
<a${' class="root-user"' if request.is_root else ''|n}>${request.user}${" ({})".format(inbox_count) if inbox_count else ''}</a>
<ul>
% if request.is_root:
<li class="root-user">${h.link_to("Stop being root", url('stop_root'))}</li>
% elif request.is_admin:
<li class="root-user">${h.link_to("Become root", url('become_root'))}</li>
% endif
<li>${h.link_to("Messages{}".format(" ({})".format(inbox_count) if inbox_count else ''), url('messages.inbox'))}</li>
<li>${h.link_to("Change Password", url('change_password'))}</li>
<li>${h.link_to("Logout", url('logout'))}</li>
</ul>
</li>
% else:
<li>${h.link_to("Login", url('login'))}</li>
% endif
</%def>

View file

@ -0,0 +1,27 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/mobile/base.mako" />
<%def name="app_title()">Tempmon Demo</%def>
<%def name="mobile_usermenu()">
<div id="usermenu" data-role="panel" data-display="overlay">
<ul data-role="listview">
<li data-icon="home">${h.link_to("Home", url('mobile.home'))}</li>
% if request.is_root:
<li class="root-user" data-icon="forbidden">${h.link_to("Stop being root", url('stop_root'), **{'data-ajax': 'false'})}</li>
% elif request.is_admin:
<li class="root-user" data-icon="forbidden">${h.link_to("Become root", url('become_root'), **{'data-ajax': 'false'})}</li>
% endif
<li data-icon="lock">${h.link_to("Logout", url('logout'), **{'data-ajax': 'false'})}</li>
<li data-icon="info">${h.link_to("About {}".format(capture(self.app_title)), url('mobile.about'))}</li>
</ul>
</div>
</%def>
<%def name="mobile_footer()">
<div data-role="footer">
<h4>${h.link_to("Tempmon Demo {}{}".format(rattail_tempmon_demo.__version__, '' if request.rattail_config.production() else '+dev'), url('mobile.about'))}</h4>
</div>
</%def>
${parent.body()}

View file

@ -0,0 +1,7 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/mobile/home.mako" />
<div style="text-align: center;">
${h.image(request.static_url('tailbone:static/img/home_logo.png'), "Rattail Logo", width='400')}
<h3>Welcome to ${self.app_title()}</h3>
</div>

View file

@ -0,0 +1,22 @@
# -*- coding: utf-8; mode: python; -*-
"""
Views
"""
from __future__ import unicode_literals, absolute_import
def includeme(config):
# core views
config.include('rattail_tempmon_demo.web.views.common')
config.include('tailbone.views.auth')
# main table views
config.include('tailbone.views.email')
config.include('tailbone.views.messages')
config.include('tailbone.views.people')
config.include('tailbone.views.roles')
config.include('tailbone.views.settings')
config.include('tailbone.views.users')
config.include('tailbone.views.tempmon')

View file

@ -0,0 +1,29 @@
# -*- coding: utf-8; -*-
"""
Common views
"""
from __future__ import unicode_literals, absolute_import
from tailbone.views import common as base
import rattail_tempmon_demo
class CommonView(base.CommonView):
project_title = "Rattail-Tempmon-Demo"
project_version = rattail_tempmon_demo.__version__ + '+dev'
def get_packages(self):
import rattail_tempmon
packages = super(CommonView, self).get_packages()
packages['rattail-tempmon'] = rattail_tempmon.__version__
for key in packages:
packages[key] = packages[key] + '+dev'
return packages
def includeme(config):
CommonView.defaults(config)

88
setup.py Normal file
View file

@ -0,0 +1,88 @@
# -*- coding: utf-8; -*-
"""
Rattail Tempmon Demo setup script
"""
from __future__ import unicode_literals, absolute_import
import os
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
execfile(os.path.join(here, 'rattail_tempmon_demo', '_version.py'))
README = open(os.path.join(here, 'README.rst')).read()
requires = [
#
# Version numbers within comments below have specific meanings.
# Basically the 'low' value is a "soft low," and 'high' a "soft high."
# In other words:
#
# If either a 'low' or 'high' value exists, the primary point to be
# made about the value is that it represents the most current (stable)
# version available for the package (assuming typical public access
# methods) whenever this project was started and/or documented.
# Therefore:
#
# If a 'low' version is present, you should know that attempts to use
# versions of the package significantly older than the 'low' version
# may not yield happy results. (A "hard" high limit may or may not be
# indicated by a true version requirement.)
#
# Similarly, if a 'high' version is present, and especially if this
# project has laid dormant for a while, you may need to refactor a bit
# when attempting to support a more recent version of the package. (A
# "hard" low limit should be indicated by a true version requirement
# when a 'high' version is present.)
#
# In any case, developers and other users are encouraged to play
# outside the lines with regard to these soft limits. If bugs are
# encountered then they should be filed as such.
#
# package # low high
'psycopg2', # 2.6.2
'rattail', # 0.7.25
'Tailbone', # 0.5.29
]
setup(
name = "rattail-tempmon-demo",
version = __version__,
author = "Lance Edgar",
author_email = "lance@edbob.org",
url = "https://rattailproject.org/",
description = "Demo for Rattail Tempmon",
long_description = README,
classifiers = [
'Private :: Do Not Upload',
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Environment :: Web Environment',
'Framework :: Pyramid',
'Intended Audience :: Developers',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Topic :: Office/Business',
],
install_requires = requires,
packages = find_packages(),
entry_points = {
'rattail.config.extensions': [
'rattail_tempmon_demo = rattail_tempmon_demo.config:RattailTempmonDemoConfig',
],
'paste.app_factory': [
'main = rattail_tempmon_demo.web.app:main',
],
},
)