Example #1
0
class Action(models.Action):
    label = _t('Grid')
    all_layers = True
    author = 'Pawel T. Jochym'
    email = '*****@*****.**'
    init = staticmethod(init)
    pil = staticmethod(make_grid)
    version = '0.2'
    tags = [_t('size'), _t('filter')]
    update_size = True
    __doc__ = _t('Make n x m matrix of image')

    def interface(self, fields):
        fields[_t('Columns')] = self.SliderField(2, 1, 10)
        fields[_t('Rows')] = self.SliderField(2, 1, 10)
        fields[_t('Scale to Keep Size')] = self.BooleanField(False)
        fields[_t('Column Line Width')] = \
            self.PixelField('0 px', choices=CHOICES)
        fields[_t('Row Line Width')] = \
            self.PixelField('0 px', choices=CHOICES)
        fields[_t('Line Color')] = self.ColorField('#FFFFFF')
        fields[_t('Line Opacity')] = self.SliderField(0, 0, 100)

    def values(self, info):
        #size
        x0, y0 = info['size']
        dpi = info['dpi']
        x1 = self.get_field('Columns', info)
        y1 = self.get_field('Rows', info)
        #parameters
        return {
            'old_size': (x0, y0),
            'grid': (x1, y1),
            'scale': self.get_field('Scale to Keep Size', info),
            'col_line_width': self.get_field_size(
                'Column Line Width', info, y0, dpi),
            'row_line_width': self.get_field_size(
                'Row Line Width', info, x0, dpi),
            'line_color': self.get_field('Line Color', info),
            'line_opacity': \
                int(255 * self.get_field('Line Opacity', info) / 100.0),
        }

    def get_relevant_field_labels(self):
        relevant = [
            'Columns', 'Rows', 'Scale to Keep Size', 'Column Line Width',
            'Row Line Width'
        ]
        col_line_width = self.get_field_string('Column Line Width').strip()
        if col_line_width:
            col_line_width = col_line_width.split()[0]
        row_line_width = self.get_field_string('Row Line Width').strip()
        if row_line_width:
            row_line_width = row_line_width.split()[0]
        if not (col_line_width in ZERO and row_line_width in ZERO):
            relevant.extend(['Line Color', 'Line Opacity'])
        return relevant

    icon = \
'x\xda\x01\xcd\x0c2\xf3\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x000\x00\
Example #2
0
class Action(models.Action):
    label = _t('Warm Up')
    author = 'Pawel T. Jochym'
    email = '*****@*****.**'
    init = staticmethod(init)
    pil = staticmethod(warmup)
    version = '0.2'
    tags = [_t('filter'), _t('color')]
    __doc__ = _t('Colorize midtones of an image')

    def interface(self, fields):
        fields[_t('Midtone')] = self.ColorField('#805d40')
        fields[_t('Brighten')] = self.SliderField(50, 0, 100)
        fields[_t('Amount')] = self.SliderField(50, 1, 100)

    icon = \
'x\xda\x01<\n\xc3\xf5\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x000\x00\
Example #3
0
 def interface(self, fields):
     fields[_t('Columns')] = self.SliderField(2, 1, 10)
     fields[_t('Rows')] = self.SliderField(2, 1, 10)
     fields[_t('Scale to Keep Size')] = self.BooleanField(False)
     fields[_t('Column Line Width')] = \
         self.PixelField('0 px', choices=CHOICES)
     fields[_t('Row Line Width')] = \
         self.PixelField('0 px', choices=CHOICES)
     fields[_t('Line Color')] = self.ColorField('#FFFFFF')
     fields[_t('Line Opacity')] = self.SliderField(0, 0, 100)
Example #4
0
 def interface(self, fields):
     fields[_t('Columns')] = self.SliderField(2, 1, 10)
     fields[_t('Rows')] = self.SliderField(2, 1, 10)
     fields[_t('Scale to Keep Size')] = self.BooleanField(False)
     fields[_t('Column Line Width')] = \
         self.PixelField('0 px', choices=CHOICES)
     fields[_t('Row Line Width')] = \
         self.PixelField('0 px', choices=CHOICES)
     fields[_t('Line Color')] = self.ColorField('#FFFFFF')
     fields[_t('Line Opacity')] = self.SliderField(0, 0, 100)
Example #5
0
def getContent(req, ids):
    user = current_user
    node = q(Node).get(ids[0])

    if "sortfiles" in user.hidden_edit_functions or not node.has_write_access():
        req.setStatus(httpstatus.HTTP_FORBIDDEN)
        return req.getTAL("web/edit/edit.html", {}, macro="access_error")

    if "globalsort" in req.params:
        node.set("sortfield", req.params["globalsort"])
    collection_sortfield = node.get("sortfield")
    db.session.commit()

    sortchoices = _sort.get_sort_choices(container=node, off="off", t_off=_t(req, "off"), t_desc=_t(req, "descending"))

    return req.getTAL("web/edit/modules/sortfiles.html", dict(
            node=node,
            collection_sortfield=collection_sortfield,
            sortchoices=tuple(sortchoices),
            name=node.name,
        ), macro="edit_sortfiles")
Example #6
0
def getContent(req, ids):
    logg.error("publish.getContent")
    user = current_user
    publishdir = q(Node).get(ids[0])
    ret = ""

    errorids = []
    publisherror = []
    changes = []
    if "dopublish" in req.params.keys():
        logg.debug("dopublish")
        num_req_err_nodes = 0
        num_db_err_nodes = 0
        num_rights_err_nodes = 0
        objlist = []
        for key in req.params.keys():
            if key.isdigit():
                objlist.append(key)
                src = q(Node).get(req.params.get("id"))

        for obj_id in objlist:
            remove_from_src = False
            obj = q(Node).get(obj_id)
            metadatatype = obj.metadatatype
            mask_validated = False
            for mask in metadatatype.getMasks(type="edit"): # check required fields
                if mask.has_read_access() and mask.getName() == obj.system_attrs.get("edit.lastmask"):
                    for f in mask.validateNodelist([obj]):
                        errorids.append(f)
                    mask_validated = True

            logg.error(errorids)
            if len(errorids)>0: # object faulty
                num_req_err_nodes +=1
                # if object faulty, it is not necessary to do the rest of error handling for this object
                continue

            if not mask_validated:
                msg = "user %r going to publish node %r without having validated edit.lastmask" % (user, obj)
                logg.warning(msg)
                # should we validate standard edit mask here?

            for dest_id in req.params.get("destination", "").split(","):
                if not dest_id: # no destination given
                    continue

                dest = q(Node).get(dest_id)

                # XXX: this error handling should be revised, I think...

                error = False # general rights error
                if not src.has_read_access():
                    logg.error("Error in publishing of node %r: source position %r has no read access.", obj.id, src.id)
                    error = True
                if not dest.has_write_access():
                    logg.error("Error in publishing of node %r: destination %r has no write access.", obj.id, dest.id)
                    error = True
                if not obj.has_write_access():
                    logg.error("Error in publishing of node %r: object has no write access.", obj.id)
                    error = True
                if not isinstance(dest, Container) or dest == src:
                    # cannot happen normally due to selection tree
                    logg.error("Error in publishing of node %r: destination %r is not a directory.", obj.id, dest.id)
                    error = True

                if not error:
                    if not obj.is_descendant_of(dest):
                        dest.children.append(obj)
                        remove_from_src = True

                        if dest.id not in changes:
                            changes.append(dest.id)
                        if src.id not in changes:
                            changes.append(src.id)
                        logg.info("%s published %s (%s, %s) from src %s (%s, %s) to dest %s (%s, %s)", user.login_name,
                                  obj.id, obj.name, obj.type,
                                  src.id, src.name, src.type,
                                  dest.id, dest.name, dest.type)
                    else:
                        num_rights_err_nodes += 1
                        errorids.append(obj.id)
                        logg.error("Error in publishing of node {}: Destination node {} is child of node.".format(obj_id, dest.id))
                else:
                    # error already logged
                    num_rights_err_nodes += 1
                    errorids.append(obj.id)

            if remove_from_src:
                try:
                    src.children.remove(obj)
                    db.session.commit()
                except:
                    num_db_err_nodes += 1
                    logg.exception("Error in publishing of node {}: Database error".format(obj.id))
                    errorids.append(obj.id)


        # error messages for publishing assistant
        if num_req_err_nodes > 0:
            if num_req_err_nodes < 2:
                publisherror.append(_t(_lang(req), "error_publish_single_node"))
            else:
                publisherror.append(_t(_lang(req), "error_publish_multiple_nodes"))
        if num_rights_err_nodes > 0:
            if num_rights_err_nodes < 2:
                publisherror.append(_t(_lang(req), "error_publish_rights_single"))
            else:
                publisherror.append(_t(_lang(req), "error_publish_rights_multiple"))
        if num_db_err_nodes > 0:
            if num_db_err_nodes < 2:
                publisherror.append(_t(_lang(req), "error_publish_database_single"))
            else:
                publisherror.append(_t(_lang(req), "error_publish_database_multiple"))

        v = {}
        v["id"] = publishdir.id
        v["change"] = changes
        ret += req.getTAL("web/edit/modules/publish.html", v, macro="reload")

    # build normal window
    stddir = ""  # preset value for destination ids
    stdname = ""

    v = {"id": publishdir.id,
         "stddir": stddir,
         "stdname": stdname,
         "showdir": showdir(req,
                            publishdir,
                            publishwarn=None,
                            markunpublished=1,
                            faultyidlist=errorids,
                            ),
         "basedir": q(Collections).one(),
         "script": "var currentitem = '%s';\nvar currentfolder = '%s'" % (publishdir.id, publishdir.id), "idstr": ids,
         "faultyerrlist": publisherror,
        }
    v["csrf"] = req.csrf_token.current_token
    ret += req.getTAL("web/edit/modules/publish.html", v, macro="publish_form")
    return ret
Example #7
0
 def interface(self, fields):
     fields[_t('Midtone')] = self.ColorField('#805d40')
     fields[_t('Brighten')] = self.SliderField(50, 0, 100)
     fields[_t('Amount')] = self.SliderField(50, 1, 100)
 def interface(self, fields):
     fields[_t("Midtone")] = self.ColorField("#805d40")
     fields[_t("Brighten")] = self.SliderField(50, 0, 100)
     fields[_t("Amount")] = self.SliderField(50, 1, 100)
Example #9
0
 def interface(self, fields):
     fields[_t('Midtone')] = self.ColorField('#805d40')
     fields[_t('Brighten')] = self.SliderField(50, 0, 100)
     fields[_t('Amount')] = self.SliderField(50, 1, 100)