merge branch master
This commit is contained in:
commit
a6e9a8543c
5 changed files with 30 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
||||||
#-*- coding: UTF-8 -*-
|
#-*- coding: UTF-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -408,12 +408,13 @@ class IOrderItem(ITrack):
|
||||||
shop = Attribute(u'The shop from which the product is ordered.')
|
shop = Attribute(u'The shop from which the product is ordered.')
|
||||||
order = Attribute(u'The order this order item belongs to.')
|
order = Attribute(u'The order this order item belongs to.')
|
||||||
unitPrice = Attribute(u'The basic unit price for one of the product '
|
unitPrice = Attribute(u'The basic unit price for one of the product '
|
||||||
u'items ordered.')
|
u'ites ordered.')
|
||||||
fullPrice = Attribute(u'The full price for the quantity ordered.')
|
fullPrice = Attribute(u'The full price for the quantity ordered.')
|
||||||
quantityShipped = Attribute(u'The total quantity that has been shipped '
|
quantityShipped = Attribute(u'The total quantity that has been shipped '
|
||||||
u'already.')
|
u'already.')
|
||||||
shippingInfo = Attribute(u'A list of mappings, with fields like: '
|
shippingInfo = Attribute(u'A list of mappings, with fields like: '
|
||||||
u'shippingId, shippingDate, quantity, packageId')
|
u'shippingId, shippingDate, quantity, packageId')
|
||||||
|
options = Attribute(u'Product options associated with this order item.')
|
||||||
|
|
||||||
def remove():
|
def remove():
|
||||||
""" Remove the order item from the order or cart.
|
""" Remove the order item from the order or cart.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Order and order item classes.
|
Order and order item classes.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
@ -119,6 +117,10 @@ class OrderItems(object):
|
||||||
def add(self, product, party, shop, order='???', run=0, **kw):
|
def add(self, product, party, shop, order='???', run=0, **kw):
|
||||||
kw['shop'] = self.getUid(shop)
|
kw['shop'] = self.getUid(shop)
|
||||||
existing = self.getCart(party, order, shop, run, product=product)
|
existing = self.getCart(party, order, shop, run, product=product)
|
||||||
|
options = kw.get('options')
|
||||||
|
if options is not None:
|
||||||
|
existing = [item for item in existing
|
||||||
|
if (item.data.get('options') or []) == options]
|
||||||
if existing:
|
if existing:
|
||||||
track = existing[-1]
|
track = existing[-1]
|
||||||
track.modify(track.quantity + kw.get('quantity', 1))
|
track.modify(track.quantity + kw.get('quantity', 1))
|
||||||
|
|
|
@ -36,6 +36,9 @@ class Questionnaire(object):
|
||||||
self.responses = []
|
self.responses = []
|
||||||
self.defaultAnswerRange = 5
|
self.defaultAnswerRange = 5
|
||||||
|
|
||||||
|
def getQuestionGroups(self, party):
|
||||||
|
return self.questionGroups
|
||||||
|
|
||||||
|
|
||||||
class QuestionGroup(object):
|
class QuestionGroup(object):
|
||||||
|
|
||||||
|
@ -95,7 +98,7 @@ class Response(object):
|
||||||
|
|
||||||
def getGroupedResult(self):
|
def getGroupedResult(self):
|
||||||
result = []
|
result = []
|
||||||
for qugroup in self.questionnaire.questionGroups:
|
for qugroup in self.questionnaire.getQuestionGroups(self.party):
|
||||||
score = scoreMax = 0.0
|
score = scoreMax = 0.0
|
||||||
for qu in qugroup.questions:
|
for qu in qugroup.questions:
|
||||||
if qu.questionType not in (None, 'value_selection'):
|
if qu.questionType not in (None, 'value_selection'):
|
||||||
|
@ -131,6 +134,8 @@ class Response(object):
|
||||||
values = [data.values.get(group) for data in teamData]
|
values = [data.values.get(group) for data in teamData]
|
||||||
values = [v for v in values if v is not None]
|
values = [v for v in values if v is not None]
|
||||||
#avg = sum(values) / len(teamData)
|
#avg = sum(values) / len(teamData)
|
||||||
|
if not values:
|
||||||
|
continue
|
||||||
avg = sum(values) / len(values)
|
avg = sum(values) / len(values)
|
||||||
result.append(dict(group=group, average=avg))
|
result.append(dict(group=group, average=avg))
|
||||||
ranks = getRanks([r['average'] for r in result])
|
ranks = getRanks([r['average'] for r in result])
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
Views for displaying media assets.
|
Views for displaying media assets.
|
||||||
|
|
||||||
Authors: Johann Schimpf, Erich Seifert.
|
Authors: Johann Schimpf, Erich Seifert.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
@ -35,6 +33,8 @@ from zope.interface import implements
|
||||||
from cybertools.media.interfaces import IMediaAsset, IFileTransform
|
from cybertools.media.interfaces import IMediaAsset, IFileTransform
|
||||||
from cybertools.storage.filesystem import FileSystemStorage
|
from cybertools.storage.filesystem import FileSystemStorage
|
||||||
|
|
||||||
|
logger = getLogger('cybertools.media.piltransform.PILTransform')
|
||||||
|
|
||||||
|
|
||||||
def mimetypeToPIL(mimetype):
|
def mimetypeToPIL(mimetype):
|
||||||
return mimetype.split("/",1)[-1]
|
return mimetype.split("/",1)[-1]
|
||||||
|
@ -51,8 +51,7 @@ class PILTransform(object):
|
||||||
try:
|
try:
|
||||||
self.im = Image.open(path)
|
self.im = Image.open(path)
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
from logging import getLogger
|
logger.warn(e)
|
||||||
getLogger('cybertools.media.piltransform.PILTransform').warn(e)
|
|
||||||
self.im = None
|
self.im = None
|
||||||
|
|
||||||
def rotate(self, angle, resize):
|
def rotate(self, angle, resize):
|
||||||
|
@ -101,10 +100,17 @@ class PILTransform(object):
|
||||||
ratio = float(ow) / float(oh)
|
ratio = float(ow) / float(oh)
|
||||||
height = int(round(float(width) / ratio))
|
height = int(round(float(width) / ratio))
|
||||||
dims = (width, height)
|
dims = (width, height)
|
||||||
|
try:
|
||||||
self.im.thumbnail(dims, Image.ANTIALIAS)
|
self.im.thumbnail(dims, Image.ANTIALIAS)
|
||||||
|
except IOError, e:
|
||||||
|
logger.warn(e)
|
||||||
|
|
||||||
|
|
||||||
def save(self, path, mimetype):
|
def save(self, path, mimetype):
|
||||||
if self.im is None:
|
if self.im is None:
|
||||||
return
|
return
|
||||||
format = mimetypeToPIL(mimetype)
|
format = mimetypeToPIL(mimetype)
|
||||||
|
try:
|
||||||
self.im.save(path)
|
self.im.save(path)
|
||||||
|
except IOError, e:
|
||||||
|
logger.warn(e)
|
||||||
|
|
|
@ -52,7 +52,7 @@ def workItemStates():
|
||||||
'move', 'cancel', 'modify'),
|
'move', 'cancel', 'modify'),
|
||||||
color='yellow'),
|
color='yellow'),
|
||||||
State('running', 'running',
|
State('running', 'running',
|
||||||
('work', 'finish', 'move', 'cancel', 'modify'),
|
('work', 'finish', 'move', 'cancel', 'modify'), # 'delegate', # ?
|
||||||
color='orange'),
|
color='orange'),
|
||||||
State('done', 'done',
|
State('done', 'done',
|
||||||
('plan', 'accept', 'start', 'work', 'finish', 'delegate',
|
('plan', 'accept', 'start', 'work', 'finish', 'delegate',
|
||||||
|
@ -279,6 +279,9 @@ class WorkItem(Stateful, Track):
|
||||||
if self.state in ('planned', 'accepted', 'delegated', 'moved', 'done'):
|
if self.state in ('planned', 'accepted', 'delegated', 'moved', 'done'):
|
||||||
self.state = self.state + '_x'
|
self.state = self.state + '_x'
|
||||||
self.reindex('state')
|
self.reindex('state')
|
||||||
|
#elif self.state == 'running':
|
||||||
|
# self.doAction('work', userName,
|
||||||
|
# end=(kw.get('end') or getTimeStamp()))
|
||||||
xkw = dict(kw)
|
xkw = dict(kw)
|
||||||
xkw.pop('party', None)
|
xkw.pop('party', None)
|
||||||
delegated = self.createNew('delegate', userName, **xkw)
|
delegated = self.createNew('delegate', userName, **xkw)
|
||||||
|
|
Loading…
Add table
Reference in a new issue