Пример #1
0
class IProducentWithAdministrators(IProducent):
    administrators = zope.schema.List(
        title = _(u'Producent Administrators'),
        description = _(u'Fill in at least one producent administrator'),
        required = True,
        value_type = zope.schema.Object( title=_('Producent Administrator'), schema=IProducentAdministrator ),
        unique = False
    )
Пример #2
0
class IProducentAdministrators(model.Schema):
    administrators = zope.schema.List(
        title = _(u'Producent Administrators'),
        description = u'Přidejte alespoň jednoho administrátora',
        required = True,
        value_type = zope.schema.Object( title=_('Producent Administrator'), schema=IProducentAdministrator ),
        unique = False,
        min_length = 1,
    )
Пример #3
0
class IProducentMember(model.Schema):
    """ a few fields from IProducentAdministrator """
    fullname = schema.TextLine(
        title=u"Jméno a příjmení",
        description=_(u'help_full_name_creation',
                      default=u"Enter full name, e.g. John Smith."),
        required=True)

    email = schema.ASCIILine(
        title=_(u'label_email', default=u'E-mail'),
        description=u'',
        constraint = register.checkEmailAddress,
        required=True,
    )

    phone = schema.ASCIILine(
        title=_(u'label_phone', default=u'Telephone number'),
        description=_(u'help_phone',
                      default=u"Leave your phone number so we can reach you."),
        required=True,
        constraint = register.checkForRegularTextFactory(r'^[ 0-9\+]*$'),
    )
    
    username = schema.ASCIILine(
        title=_(u'label_user_name', default=u'User Name'),
        description=_(u'help_user_name_creation_casesensitive',
                      default=u"Enter a user name, usually something "
                      "like 'jsmith'. "
                      "No spaces or special characters. "
                      "Usernames and passwords are case sensitive, "
                      "make sure the caps lock key is not enabled. "
                      "This is the name used to log in."),
        required=True,
        constraint = register.checkForRegularTextFactory(r'^[a-z0-9_\.A-Z]{5,32}$'),
    )
    
    password = schema.Password(
        title=_(u'label_password', default=u'Password'),
        description=_(u'help_password_creation',
                      default=u'Enter your new password.'),
        required=True,
    )
    
    password_ctl = schema.Password(
        title=_(u'label_confirm_password',
                default=u'Confirm password'),
        description=_(u'help_confirm_password',
                      default=u"Re-enter the password. "
                      "Make sure the passwords are identical."),
        required=True,
    )
Пример #4
0
class IAdministrator(model.Schema):
    administrator = zope.schema.Object(
        title = _(u'Producent Administrator'),
        description = u"správce přidává editory, upravuje informace o producentovi.",
        required = True,
        schema=IProducentAdministrator,
    )
Пример #5
0
class IAgreementFile(model.Schema, IImageScaleTraversable):
    """
    E-Deposit - file with agreement for producent
    """

    # If you want a schema-defined interface, delete the model.load
    # line below and delete the matching file in the models sub-directory.
    # If you want a model-based interface, edit
    # models/agreement_file.xml to define the content type.

    agreement = NamedBlobFile(
        title=_(u'Agreement'),
        description=_(
            u'Upload file with agreement between National Library and you.'),
        required=False,
    )

    model.primary('agreement')
Пример #6
0
    def handleRegister(self, action):
        print "handle registrer"
        data, errors = self.extractData()
        if errors:
            print "all errors views names", map(lambda err: err.widget.name, errors)
            print self.formErrorsMessage
            print "self.widgets.errors", self.widgets.errors
            self.status = self.formErrorsMessage
            return

        administrator = data['IAdministrator.administrator']
        if api.user.get(username=administrator.username):
            raise ActionExecutionError(Invalid(u"Uživatelské jméno u správce producenta je již použito. Vyplňte jiné."))   
        # check administrator passwords
        if administrator.password_ctl != administrator.password:
            raise ActionExecutionError(Invalid(u"U správce producenta se neshodují zadaná hesla. Vyplňte hesla znovu."))

        editorFields = ['fullname','email','phone','username','password','password_ctl']
        editorValues = map(lambda key: data.get('IEditor.'+key,None), editorFields)

        if filter(lambda value: value, editorValues):
            if False in map(lambda value: bool(value), editorValues):
                raise ActionExecutionError(Invalid(u"Některé položky u editora nejsou vyplněny. Buď vyplňte editorovi všechny položky, nebo je všechny smažte."))
                
            editorData = dict(zip(editorFields, editorValues))
            if editorData['password'] != editorData['password_ctl']:
                raise ActionExecutionError(Invalid(u"U editora se neshodují zadaná hesla. Vyplňte hesla znovu."))
            if api.user.get(username=editorData['username']):
                raise ActionExecutionError(Invalid(u"Uživatelské jméno u editora je již obsazené. Vyplňte jiné."))

        producentsFolder = self.getProducentsFolder()
        # hack for title and description
        data['title'] = data.get('IBasic.title','')
        data['description'] = data.get('IBasic.description','')

        producent = createContentInContainer(producentsFolder, "edeposit.user.producent", **data)

        if filter(lambda value: value, editorValues):
            editorsFolder = producent['producent-editors']
            editorData['title'] = editorData['fullname']
            editor = createContentInContainer(editorsFolder, "edeposit.user.producenteditor", **editorData)


        administratorsFolder = producent['producent-administrators']
        

        administrator.title = getattr(administrator,'fullname',None)
        addContentToContainer(administratorsFolder, administrator, False)

        if producent is not None:
            wft = api.portal.get_tool('portal_workflow')
            wft.doActionFor(producent,'submit')
            # mark only as finished if we get the new object
            self._finishedAdd = True
            IStatusMessage(self.request).addStatusMessage(_(u"Item created"), "info")
            url = "%s/%s" % (api.portal.getSite().absolute_url(), 'register-with-producent-successed')
            self.request.response.redirect(url)
Пример #7
0
 def title(self):
     return _(u"Work Plans for Subject Cataloguers")
Пример #8
0
 def title(self):
     return _(u"Work Plans for Descriptive Cataloguers")
 def title(self):
     return _(u"Choose proper aleph record")
class IAssignedSubjectReviewer(form.Schema):
    reviewer = schema.Choice(
        title=_(u"Reviewer"),
        source=possibleSubjectReviewers,
        required=False,
    )
class IAssignedDescriptiveReviewer(form.Schema):
    reviewer = schema.Choice(
        title=_(u"Reviewer"),
        source=possibleDescriptiveReviewers,
        required=False,
    )
 def title(self):
     return _(u"Waiting for work assignment")
Пример #13
0
class IEnhancedUserDataSchema(Interface):
    """ Use all the fields from the default user data schema, and add various
    extra fields.
    """
    form.fieldset('login',
                  label=_(u"Login"),
                  fields=['username', 'password', 'password_ctl'])

    username = schema.ASCIILine(
        title=_(u'label_user_name', default=u'User Name'),
        description=_(u'help_user_name_creation_casesensitive',
                      default=u"Enter a user name, usually something "
                      "like 'jsmith'. "
                      "No spaces or special characters. "
                      "Usernames and passwords are case sensitive, "
                      "make sure the caps lock key is not enabled. "
                      "This is the name used to log in."))

    password = schema.Password(title=_(u'label_password', default=u'Password'),
                               description=_(
                                   u'help_password_creation',
                                   default=u'Enter your new password.'))

    password_ctl = schema.Password(
        title=_(u'label_confirm_password', default=u'Confirm password'),
        description=_(u'help_confirm_password',
                      default=u"Re-enter the password. "
                      "Make sure the passwords are identical."))

    @invariant
    def passwordsMatch(data):
        if data.password == data.password_ctl:
            return True
        raise PasswordPairInvalid

    form.fieldset(
        'personalinfo',
        label=_(u"Personal Info"),
        fields=['fullname', 'email', 'home_page', 'location', 'phone'])

    fullname = schema.TextLine(
        title=_(u'label_full_name', default=u'Full Name'),
        description=_(u'help_full_name_creation',
                      default=u"Enter full name, e.g. John Smith."),
        required=False)

    email = schema.ASCIILine(title=_(u'label_email', default=u'E-mail'),
                             description=u'',
                             required=True,
                             constraint=checkEmailAddress)

    home_page = schema.TextLine(
        title=_(u'label_homepage', default=u'Home page'),
        description=_(u'help_homepage',
                      default=u"The URL for your external home page, "
                      "if you have one."),
        required=False)

    location = schema.TextLine(title=_(u'label_location', default=u'Location'),
                               description=_(
                                   u'help_location',
                                   default=u"Your location - either city and "
                                   "country - or in a company setting, where "
                                   "your office is located."),
                               required=False)

    phone = schema.TextLine(
        title=_(u'label_phone', default=u'Telephone number'),
        description=_(u'help_phone',
                      default=u"Leave your phone number so we can reach you."),
        required=False,
    )

    form.fieldset('address',
                  label=_(u"Address"),
                  fields=['street', 'city', 'country'])
    street = schema.TextLine(
        title=_(u'label_street', default=u'Street'),
        description=_(u'help_street',
                      default=u"Fill in the street and number."),
        required=False,
    )

    city = schema.TextLine(
        title=_(u'label_city', default=u'City'),
        description=_(u'help_city', default=u"Fill in the city you live in."),
        required=False,
    )

    country = schema.TextLine(
        title=_(u'label_country', default=u'Country'),
        description=_(u'help_country',
                      default=u"Fill in the country you live in."),
        required=False,
    )
    form.fieldset('producent', label=_(u"Producent"), fields=[
        'producent',
    ])

    # form.fieldset(
    #     'producent_info',
    #     label = _(u"Producent's Info"),
    #     fields = ['new_producent',
    #               'producent',
    #               'producent_title',
    #               'producent_home_page',
    #               'producent_location',
    #               'producent_contact',
    #               'producent_agreement',]
    #     )
    # form.fieldset(
    #     'producent_address',
    #     label = _(u"Producent's Address"),
    #     fields = [  'producent_street',
    #                 'producent_city',
    #                 'producent_country',
    #                 ]
    #     )
    # new_producent = schema.Bool(
    #     title=_(u'label_new_producent', default=u'New producent'),
    #     description=_(u'help_new_producent',
    #                   default=u"Do you wan to create new producent?"),
    #     required=False,
    #     )

    #form.widget(producent=AutocompleteFieldWidget)
    producent = schema.Choice(
        title=_(u'label_producent', default=u'Producent'),
        description=_(u'help_producent',
                      default=u"Fill in the producent you work for."),
        required=False,
        source=producent_source,
    )
Пример #14
0
 def title(self):
     return _(u"Prepare Subject Cataloguing")
Пример #15
0
 def title(self):
     return _(u"Prepare Descriptive Cataloguing")
Пример #16
0
 def header(self):
     return _(u"Subject Cataloguing Preparing")
Пример #17
0
 def getOriginalFileContributingPath(producentPath):
     url = os.path.join(producentPath,
                        "originalfile-contributing",
                        "contribute"
     )
     return [{'desc': _("Contribute Original file"), 'href': url}]
Пример #18
0
 def header(self):
     return _(u"Subject Cataloguing Preparing")
 def title(self):
     """This property is used to give the title of the portlet in the
     "manage portlets" screen.
     """
     return _(u"Producent Administrators Portlet")
Пример #20
0
 def title(self):
     """This property is used to give the title of the portlet in the
     "manage portlets" screen.
     """
     return _(u"Producent Administrators Portlet")
 def title(self):
     """This property is used to give the title of the portlet in the
     "manage portlets" screen.
     """
     return _(u"Producent Registering Help")
Пример #22
0
 def header(self):
     return _(u"Descriptive Cataloguing Preparing")
Пример #23
0
 def title(self):
     return _(u"Prepare Subject Cataloguing")
Пример #24
0
 def title(self):
     return _(u"Some Assignment")
class IAssignedDescriptiveCataloguer(form.Schema):
    cataloguer = schema.Choice(
        title=_(u"Cataloguer"),
        source=possibleDescriptiveCataloguers,
        required=False,
    )
Пример #26
0
 def title(self):
     return _(u"Work Plans for Descriptive Cataloguers")
class IAssignedSubjectCataloguer(form.Schema):
    cataloguer = schema.Choice(
        title=_(u"Cataloguer"),
        source=possibleSubjectCataloguers,
        required=False,
    )
Пример #28
0
 def title(self):
     return _(u"Work Plans for Descriptive Reviewers")
Пример #29
0
 def title(self):
     """This property is used to give the title of the portlet in the
     "manage portlets" screen.
     """
     return _(u"E-Deposit: Registering of any eContent")
Пример #30
0
 def title(self):
     return _(u"Work Plans for Subject Cataloguers")
Пример #31
0
 def title(self):
     return _(u"Some Assignment")
Пример #32
0
 def title(self):
     return _(u"Work Plans for Subject Reviewers")
Пример #33
0
 def title(self):
     return _(u"Work Plans for Descriptive Reviewers")
Пример #34
0
 def title(self):
     return _(u"Prepare Descriptive Cataloguing")
Пример #35
0
 def title(self):
     return _(u"Work Plans for Subject Reviewers")
Пример #36
0
class RegistrationAtOnceForm(form.SchemaForm):
    schema = IRegistrationAtOnce
    default_fieldset_label = u"Producent"
    label = u"Registrace producenta"
    description = u"""<p>Vyplněním těchto údajů získáte přístup k aplikaci Národní knihovny, která umožňuje ukládání vašich elektronických publikací, jejich dlouhodobou ochranu a šíření podle Vašich instrukcí.</p>
<p>Pro využívání základních funkcí systému postačí vyplnit tento online formulář. Dalším krokem je uzavření písemné smlouvy, která umožní další funkčnosti včetně řízené distribuce vašich e-publikací.</p>"""

    ignoreContext = True
    enableCSRFProtection = True
    enable_form_tabbing = False

    def extractData(self):
        def getErrorView(widget,error):
            view = zope.component.getMultiAdapter( (error, 
                                                    self.request, 
                                                    widget, 
                                                    widget.field, 
                                                    widget.form, 
                                                    self.context), 
                                                   IErrorViewSnippet)
            view.update()
            widget.error = view
            return view

        data, errors = super(RegistrationAtOnceForm,self).extractData()

        reg_tool = api.portal.get_tool(name='portal_registration')
        
        widgets = self.groups[0].widgets
        username = data.get('administrator_username')
        if username:
            if api.user.get(username = username):
                errors += (getErrorView(widgets.get('administrator_username'),
                                        Invalid(u"Uživatelské jméno je již použito. Vyplňte jiné.")),)
                pass
            
        pwd1 = data.get('administrator_password')
        pwd2 = data.get('administrator_password_ctl')
        if pwd1 and len(pwd1) < 5:
            errors += (getErrorView(widgets.get('administrator_password'), 
                                    Invalid(u"Heslo je krátké. Nejméně 5 znaků.")),)
        if pwd2 and len(pwd2) < 5:
            errors += (getErrorView(widgets.get('administrator_password_ctl'), 
                                    Invalid(u"Heslo je krátké. Nejméně 5 znaků.")),)
        if (pwd1 and pwd2) and (len(pwd1) >= 5 and len(pwd2) >= 5) and  (pwd1 != pwd2):
            errors += (getErrorView(widgets.get('administrator_password'),  Invalid(u"Hesla se neshodují.")),)
            errors += (getErrorView(widgets.get('administrator_password_ctl'),  Invalid(u"Hesla se neshodují.")),)

        email = data.get('administrator_email')
        if email and not reg_tool.isValidEmail(email):
            errors += (getErrorView(widgets.get('administrator_email'),  Invalid(u"Toto není platný email.")),)

        widgets = self.groups[1].widgets
        username = data.get('editor_username')
        if username:
            if api.user.get(username = username):
                errors += (getErrorView(widgets.get('editor_username'),
                                        Invalid(u"Uživatelské jméno je již použito. Vyplňte jiné.")),)
                pass
            
        pwd1 = data.get('editor_password')
        pwd2 = data.get('editor_password_ctl')
        if pwd1 and len(pwd1) < 5:
            errors += (getErrorView(widgets.get('editor_password'), 
                                    Invalid(u"Heslo je krátké. Nejméně 5 znaků.")),)
        if pwd2 and len(pwd2) < 5:
            errors += (getErrorView(widgets.get('editor_password_ctl'), 
                                    Invalid(u"Heslo je krátké. Nejméně 5 znaků.")),)

        if (pwd1 and pwd2) and (len(pwd1) >= 5 and len(pwd2) >= 5) and (pwd1 != pwd2):
            errors += (getErrorView(widgets.get('editor_password'),  Invalid(u"Hesla se neshodují.")),)
            errors += (getErrorView(widgets.get('editor_password_ctl'),  Invalid(u"Hesla se neshodují.")),)

        email = data.get('editor_email')
        if email and not reg_tool.isValidEmail(email):
            errors += (getErrorView(widgets.get('editor_email'),  Invalid(u"Toto není platný email.")),)

        return (data,errors)


    @button.buttonAndHandler(_(u"Register"))
    def handleRegister(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        # zkontrolujeme editora, jesli je neco vyplnene
        editorKeys = [ key for key in data.keys() if key.startswith('editor_') ]
        definedEditorKeys = [ key for key in IRegistrationAtOnce.names() if key.startswith('editor_')]

        if True in [ bool(data[key]) for key in editorKeys]:
            if frozenset(editorKeys) != frozenset(definedEditorKeys):
                raise ActionExecutionError(Invalid(u"Pokud chcete editora, vyplňte všechna jeho políčka."))

            if False in [ bool(data[key]) for key in editorKeys ]:
                raise ActionExecutionError(Invalid(u"Pokud chcete editora, vyplňte všechna jeho políčka."))
            pass

        producentData = dict(zip( ('title','pravni_forma','domicile','ico','dic', 'zastoupen'), 
                                  map(data.__getitem__,('producent_name','pravni_forma','domicile','ico','dic','zastoupen'))))
        producents = api.portal.get()['producents']
        newProducent = createContentInContainer(producents,'edeposit.user.producent',**producentData)

        # username, email, password, properties
        def createUser(data,prefix=""):
            userFields = ('username','password','email')
            kwargs = dict(zip(userFields,map(data.__getitem__, map(prefix.__add__,userFields))))
            propertyFields = ('phone','fullname')
            properties = dict(zip(propertyFields, map(data.__getitem__, map(prefix.__add__, propertyFields))))
            newUser = api.user.create(properties = properties, **kwargs)
            return newUser

        newUser = createUser(data, prefix = "administrator_")

        api.group.add_user(groupname="Producent Editors", username=newUser.id )
        api.group.add_user(groupname="Producent Contributors", username=newUser.id )
        api.group.add_user(groupname="Producent Administrators", username=newUser.id )

        api.user.grant_roles(username=newUser.id,  obj=newProducent,
                             roles=('E-Deposit: Producent Member',
                                    'E-Deposit: Producent Editor',
                                    'E-Deposit: Producent Administrator',
                                    'Editor','Reader'))
        api.user.grant_roles(username=newUser.id,  obj = newProducent['epublications'],
                             roles=('E-Deposit: Producent Member',
                                    'E-Deposit: Producent Editor',
                                    'E-Deposit: Producent Administrator',
                                    'Contributor'))
        
        if True in [ bool(data[key]) for key in editorKeys ]:
            newUser = createUser(data,prefix="editor_")
            api.group.add_user(groupname="Producent Editors", username=newUser.id )
            api.group.add_user(groupname="Producent Contributors", username=newUser.id )
            api.user.grant_roles(username=newUser.id,
                                 obj = newProducent['epublications'],
                                 roles=('E-Deposit: Producent Member',
                                        'E-Deposit: Producent Editor',
                                        'Contributor'))
            api.user.grant_roles(username=newUser.id, obj=newProducent,
                                 roles=('E-Deposit: Producent Member',
                                        'E-Deposit: Producent Editor', 
                                        'Reader'))
        
        wft = api.portal.get_tool('portal_workflow')
        wft.doActionFor(newProducent,'submit')
        
        with api.env.adopt_roles(roles=["E-Deposit: Acquisitor",]):
            wft.doActionFor(newProducent,'approve')
            #wft.doActionFor(newProducent,'generateAgreement')

        IStatusMessage(self.request).addStatusMessage(u"Registrace proběhla úspěšně", "info")
        url = "%s/%s" % (api.portal.getSite().absolute_url(), 'register-with-producent-successed')
        self.request.response.redirect(url)
Пример #37
0
 def title(self):
     """This property is used to give the title of the portlet in the
     "manage portlets" screen.
     """
     return _(u"E-Deposit: Registering of any eContent")
Пример #38
0
 def header(self):
     return _(u"Descriptive Cataloguing Preparing")
Пример #39
0
class IProducentUser(IProducentUserBasic):
    """
    E-Deposit Producent User
    """
    """
    E-Deposit - Producent Administrator
    """
    form.fieldset('personalinfo',
                  label=_(u"Personal Info"),
                  fields=['fullname', 'email', 'phone'])

    # fullname = schema.TextLine(
    #     title=_(u'label_full_name', default=u'Full Name'),
    #     description=_(u'help_full_name_creation',
    #                   default=u"Enter full name, e.g. John Smith."),
    #     required=False)

    # email = schema.ASCIILine(
    #     title=_(u'label_email', default=u'E-mail'),
    #     description=u'',
    #     required=True,
    #     constraint=checkEmailAddress)

    # home_page = schema.TextLine(
    #     title=_(u'label_homepage', default=u'Home page'),
    #     description=_(u'help_homepage',
    #                   default=u"The URL for your external home page, "
    #                   "if you have one."),
    #     required=False)

    # location = schema.TextLine(
    #     title=_(u'label_location', default=u'Location'),
    #     description=_(u'help_location',
    #                   default=u"Your location - either city and "
    #                   "country - or in a company setting, where "
    #                   "your office is located."),
    #     required=False)

    # phone = schema.TextLine(
    #     title=_(u'label_phone', default=u'Telephone number'),
    #     description=_(u'help_phone',
    #                   default=u"Leave your phone number so we can reach you."),
    #     required=False,
    #     )

    # form.fieldset(
    #     'address',
    #     label = _(u"Address"),
    #     fields = ['street','city','country']
    #     )
    # street = schema.TextLine(
    #     title=u"Ulice a číslo",
    #     description=_(u'help_street',
    #                   default=u"Fill in the street and number."),
    #     required=False,
    #     )

    # city = schema.TextLine(
    #     title=_(u'label_city', default=u'City'),
    #     description=_(u'help_city',
    #                   default=u"Fill in the city you live in."),
    #     required=False,
    #     )

    # country = schema.TextLine(
    #     title=_(u'label_country', default=u'Country'),
    #     description=_(u'help_country',
    #                   default=u"Fill in the country you live in."),
    #     required=False,
    #     )

    form.fieldset('login',
                  label=_(u"Login"),
                  fields=['username', 'password', 'password_ctl'])
Пример #40
0
class PasswordPairInvalid(schema.ValidationError):
    __doc__ = _(u'Passwords are not the same.')