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