diff --git a/orchestra/api/options.py b/orchestra/api/options.py index c540784e..a27ba72b 100644 --- a/orchestra/api/options.py +++ b/orchestra/api/options.py @@ -13,6 +13,7 @@ def collectionlink(**kwargs): """ Used to mark a method on a ViewSet collection that should be routed for GET requests. """ + # TODO deprecate in favour of DRF2.0 own method def decorator(func): func.collection_bind_to_methods = ['get'] func.kwargs = kwargs @@ -89,10 +90,10 @@ class LinkHeaderRouter(DefaultRouter): insert_links(viewset, base_name) self.registry.append((prefix, viewset, base_name)) - def insert(self, prefix, name, field, **kwargs): + def insert(self, prefix_or_model, name, field, **kwargs): """ Dynamically add new fields to an existing serializer """ for _prefix, viewset, basename in self.registry: - if _prefix == prefix: + if _prefix == prefix_or_model or viewset.model == prefix_or_model: if viewset.serializer_class is None: viewset.serializer_class = viewset().get_serializer_class() viewset.serializer_class.Meta.fields += (name,) diff --git a/orchestra/apps/resources/__init__.py b/orchestra/apps/resources/__init__.py index e69de29b..e045a6d0 100644 --- a/orchestra/apps/resources/__init__.py +++ b/orchestra/apps/resources/__init__.py @@ -0,0 +1 @@ +default_app_config = 'orchestra.apps.resources.apps.ResourcesConfig' diff --git a/orchestra/apps/resources/apps.py b/orchestra/apps/resources/apps.py new file mode 100644 index 00000000..0f8a6466 --- /dev/null +++ b/orchestra/apps/resources/apps.py @@ -0,0 +1,15 @@ +from django.apps import AppConfig +from django.contrib.contenttypes import generic + + +class ResourcesConfig(AppConfig): + name = 'orchestra.apps.resources' + verbose_name = 'Resources' + + def ready(self): + from .models import Resource + # TODO execute on Resource.save() + relation = generic.GenericRelation('resources.ResourceAllocation') + for resources in Resource.group_by_content_type(): + model = resources[0].content_type.model_class() + model.add_to_class('allocations', relation) diff --git a/orchestra/apps/resources/models.py b/orchestra/apps/resources/models.py index 132343bb..da3cc000 100644 --- a/orchestra/apps/resources/models.py +++ b/orchestra/apps/resources/models.py @@ -103,10 +103,3 @@ class MonitorData(models.Model): def __unicode__(self): return str(self.monitor) - - -#for resources in Resource.group_by_content_type(): -# model = resources[0].content_type.model_class() -# print resources[0].content_type.model_class() -# model.add_to_class('allocations', generic.GenericRelation('resources.ResourceAllocation')) - diff --git a/orchestra/apps/resources/serializers.py b/orchestra/apps/resources/serializers.py new file mode 100644 index 00000000..e357f9e3 --- /dev/null +++ b/orchestra/apps/resources/serializers.py @@ -0,0 +1,27 @@ +from rest_framework import serializers + +from orchestra.api import router + +from .models import Resource, ResourceAllocation + + +class ResourceSerializer(serializers.ModelSerializer): + name = serializers.SerializerMethodField('get_name') + current = serializers.SerializerMethodField('get_current') + allocation = serializers.IntegerField(source='value') + + class Meta: + model = ResourceAllocation + fields = ('name', 'current', 'allocation') + + def get_name(self, instance): + return instance.resource.name + + def get_current(self, instance): + return instance.resource.get_current() + + +for resources in Resource.group_by_content_type(): + model = resources[0].content_type.model_class() + router.insert(model, 'resources', ResourceSerializer, required=False, + source='allocations') diff --git a/orchestra/static/orchestra/css/adminextraprettystyle.css b/orchestra/static/orchestra/css/adminextraprettystyle.css index df03ecb4..6014570b 100644 --- a/orchestra/static/orchestra/css/adminextraprettystyle.css +++ b/orchestra/static/orchestra/css/adminextraprettystyle.css @@ -1,7 +1,8 @@ body { - background:#FBFAF9 url(/static/orchestra/images/page-gradient.png)top left repeat-x; + background: #FBFAF9 url(/static/orchestra/images/page-gradient.png) top left repeat-x; } + #header #branding h1 { margin: 0; padding: 5px 10px; @@ -9,12 +10,16 @@ body { text-indent: 0; height: 31px; font-size: 18px; - color: whitesmoke; font-weight: bold; padding-left: 50px; line-height: 30px; } +#branding h1, #branding h1 a:link, #branding h1 a:visited { + color: #707070; +} + + .version:before { content: "v"; opacity: 0.6; @@ -27,69 +32,6 @@ body { #header #branding:hover a { text-decoration: none; - color: azure; -} - -#header-branding { - background-image: url(/static/admin_tools/images/admin-tools.png); - width: 100%; - z-index: -1; - height: 41px; - position: absolute; -} - -#header-menu { - background: url(/static/admin_tools/images/admin-tools.png) 0 295px; - width: 100%; - z-index: -1; - margin-top: 41px; - height: 41px; - position: absolute; -} - -#header-breadcrumb { - width: 100%; - z-index: -1; - margin-top: 76px; - height: 69px; - position: absolute; - background-attachment: scroll; background-clip: border-box; - background-color: rgb(255, 255, 255); - background-image: url(/static/admin/img/nav-bg-reverse.gif); - background-origin: padding-box; - background-position: 0px -8px; - background-size: auto; - border-bottom-color: rgb(237, 237, 237); - border-bottom-style: solid; - border-bottom-width: 1px; - border-left-color: rgb(153, 153, 153); - border-left-style: none; - border-left-width: 0px; - border-right-color: rgb(153, 153, 153); - border-right-style: none; - border-right-width: 0px; - border-top-color: rgb(153, 153, 153); - border-top-style: none; - border-top-width: 0px; - color: white; - height: 13px; - padding-bottom: 10px; - padding-top: 10px; - background-repeat: repeat-x; - padding-left: 0; - padding-right: 0; -} - -#container { - max-width:1150px; - margin:0 auto; -} - -#header { - background:none; -} - -.dashboard-module { - background-color: white; + color: #9B9B9B; } diff --git a/orchestra/static/orchestra/icons/Utilities-system-monitor.svg b/orchestra/static/orchestra/icons/Utilities-system-monitor.svg index e2a2843e..4f974485 100644 --- a/orchestra/static/orchestra/icons/Utilities-system-monitor.svg +++ b/orchestra/static/orchestra/icons/Utilities-system-monitor.svg @@ -18,8 +18,8 @@ sodipodi:docname="Utilities-system-monitor.svg" version="1.1" inkscape:export-filename="/home/glic3rinu/orchestra/django-orchestra/orchestra/static/orchestra/icons/Utilities-system-monitor.png" - inkscape:export-xdpi="60" - inkscape:export-ydpi="60"> + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + gradientTransform="matrix(0.91076155,0,0,0.97383102,2.1416091,-0.80704338)" /> + gradientTransform="matrix(0.91076155,0,0,0.97383102,2.1416091,-0.80704338)" /> + gradientTransform="matrix(0.91076155,0,0,0.97126624,2.1416091,0.21169805)" /> + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.95629355,0,0,0.95629355,1.048949,1.049722)" /> + d="m 41.618284,42.24213 a 17.576654,5.3538084 0 1 1 -35.1533086,0 17.576654,5.3538084 0 1 1 35.1533086,0 z" + transform="matrix(1.0774684,0,0,0.95830942,-1.7165229,0.26437162)" /> + width="42.803543" + height="39.879177" + x="2.5980954" + y="2.6372454" + rx="4.3664279" + ry="4.3664293" /> + width="35.552952" + height="27.689091" + x="6.2179089" + y="6.291697" + rx="1.6206026" + ry="1.620603" /> + sodipodi:nodetypes="ccccccccccccccccc" + inkscape:connector-curvature="0" /> + width="41.019966" + height="37.913738" + x="3.4910061" + y="3.5881398" + rx="3.9498112" + ry="3.9498122" /> + d="m 12.061328,20.187334 -4.9218779,0 0,2.915501 8.2181809,-0.119536 0.627254,-2.909659 3.198478,12.152902 3.420255,-10.965469 2.409424,5.179382 4.075685,-3.929011 11.794377,-0.119536 -0.71722,-3.738666 -11.857563,-0.119537 -2.91212,3.034276 -3.25184,-7.449919 -2.519675,6.635387 -3.36475,-11.7343027 -4.198608,11.1681877 z" + style="opacity:0.38068183;fill:#ecffd9;fill-opacity:1;fill-rule:evenodd;stroke:#c3ea9b;stroke-width:0.95629388;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0.41618497;stroke-dasharray:none" + inkscape:connector-curvature="0" /> + sodipodi:nodetypes="ccsccc" + inkscape:connector-curvature="0" /> + transform="matrix(0.95629355,0,0,0.95629355,1.228254,1.7071738)"> + sodipodi:nodetypes="ccsssscc" + inkscape:connector-curvature="0" /> + d="m 28.992526,37.544659 -0.09939,1.165177 c -0.03733,0.289893 -7.43e-4,0.603392 0.112246,0.894918 0.361567,0.932882 1.412134,1.396559 2.345017,1.034993 0.932882,-0.361567 1.396559,-1.412134 1.034992,-2.345017 -0.350267,-0.903729 -1.34751,-1.369511 -2.257602,-1.068872 -0.0073,0.0024 -0.02181,0.0088 -0.02914,0.01129 l -1.106128,0.307508 z" + style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible" + inkscape:connector-curvature="0" /> + sodipodi:nodetypes="ccsssscc" + inkscape:connector-curvature="0" /> + sodipodi:nodetypes="ccsssscc" + inkscape:connector-curvature="0" /> + d="m 28.774315,36.953437 -0.09504,1.114252 c -0.03569,0.277222 -7.1e-4,0.577019 0.107341,0.855804 0.345764,0.892109 1.350414,1.33552 2.242524,0.989757 0.892109,-0.345764 1.335521,-1.350415 0.989756,-2.242525 -0.334958,-0.86423 -1.288615,-1.309654 -2.15893,-1.022155 -0.007,0.0023 -0.02086,0.0084 -0.02786,0.0108 l -1.057783,0.294068 z" + style="color:#000000;fill:#e0e2df;fill-opacity:1;fill-rule:nonzero;stroke:#9b9d99;stroke-width:0.95629352;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible" + inkscape:connector-curvature="0" /> + sodipodi:nodetypes="ccsssscc" + inkscape:connector-curvature="0" /> + style="opacity:0.57386361;fill:none;stroke:url(#linearGradient2231);stroke-width:0.95629352;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" /> diff --git a/orchestra/static/orchestra/icons/gauge.svg b/orchestra/static/orchestra/icons/gauge.svg index b9fdd512..806c0dd8 100644 --- a/orchestra/static/orchestra/icons/gauge.svg +++ b/orchestra/static/orchestra/icons/gauge.svg @@ -10,8 +10,8 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="32" - height="32" + width="48" + height="48" id="svg2" version="1.1" inkscape:version="0.48.3.1 r9886" @@ -55,10 +55,10 @@ inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" - transform="translate(0,-1020.3622)"> + transform="translate(0,-1004.3622)"> + height="67.714287" + width="67.714287" />