Example #1
0
 def updateForm(self):
     super(ENMSUpdateUser, self).updateForm()
     mnr = self.fieldWidgets.get('form.field.mnr')
     pw = self.fieldWidgets.get('form.field.passwort')
     confirm = self.fieldWidgets.get('form.field.confirm')
     mnr.template = ChameleonPageTemplateFile('templates/mnr.cpt')
     pw.template = ChameleonPageTemplateFile('templates/password.cpt')
     confirm.template = ChameleonPageTemplateFile('templates/password.cpt')
Example #2
0
class ENMSCreateUser(uvcsite.browser.Form):
    """ Simple Form which displays values from a Dict"""
    grok.context(ENMSLister)
    grok.require('uvc.ManageCoUsers')

    label = "Mitbenutzer anlegen"
    description = "Nutzen Sie diese Form um einen neuen Mitbenutzer anzulegen"

    ignoreContent = False

    mnr_template = ChameleonPageTemplateFile('templates/mnr.cpt')

    @property
    def fields(self):
        return base.Fields(self.context.user_schema)

    def updateForm(self):
        super(ENMSCreateUser, self).updateForm()
        self.fieldWidgets.get('form.field.mnr').template = self.mnr_template

    def getNextNumber(self, groups):
        all_azs = []
        for group in groups:
            all_azs.append(group['az'])
        if not all_azs:
            return 1
        return int(max(all_azs)) + 1

    def getDefaultData(self):
        principal = self.request.principal.id
        um = getUtility(IUserManagement)
        all_users = self.getNextNumber(um.getUserGroups(principal))
        user = principal + '-' + str(all_users).zfill(2)
        rollen = [x for x in self.context.__parent__.keys()]
        return {'mnr': user, 'rollen': rollen}

    def update(self):
        data = self.getDefaultData()
        self.setContentData(base.DictDataManager(data))

    @base.action(_("Anlegen"))
    def anlegen(self):
        data, errors = self.extractData()
        if errors:
            self.flash('Es sind Fehler aufgetreten', type='error')
            return
        um = getUtility(IUserManagement)
        um.addUser(**data)
        # Setting Home Folder Rights
        for role in data.get('rollen'):
            principal_roles = IPrincipalRoleManager(
                self.context.__parent__[role])
            principal_roles.assignRoleToPrincipal('uvc.Editor',
                                                  data.get('mnr'))
        self.flash(_('Der Mitbenutzer wurde gespeichert'))
        principal = self.request.principal
        homeFolder = IHomeFolder(principal)
        self.redirect(self.url(homeFolder, '++enms++'))
Example #3
0
class PersonalPreferences(PersonalPreferencesViewlet):
    grok.order(1)
    grok.name('personalpreferencesviewlet')
    grok.layer(IAdHocLayer)
    grok.require('zope.View')
    base_template = ChameleonPageTemplateFile(
        'templates/personalpreferences.cpt')

    def render(self):
        return self.base_template.render(self)
Example #4
0
class Altdaten(uvcsite.TablePage):
    """ """
    grok.baseclass()
    template = ChameleonPageTemplateFile('templates/altdaten.cpt')
    grok.title(u'Alte Dokumente')

    cssClasses = {'table': 'tablesorter'}
    title = u"Alte Dokumente"
    description = u"Hier finden Sie die vor dem 30.Mai.2011 erstellten Unfallanzeigen."

    object_type = ""

    @property
    def values(self):
        raise NotImplementedError
Example #5
0
class RequestToken(uvcsite.Page):
    grok.context(IMyHomeFolder)
    grok.name('request_token')
    grok.require('uvc.EditContent')

    client_id = "novareto"
    client_secret = "test"

    template = ChameleonPageTemplateFile('templates/request.cpt')

    @property
    def token_endpoint(self):
        config = getProductConfiguration('oauth2')
        return config.get('token_endpoint', False)

    def login(self):
        params = {
            "grant_type": "password",
            "client_id": self.client_id,
            "client_secret": self.client_secret,
            "username": self.request.form.get('username', ''),
            "password": self.request.form.get('password', ''),
        }
        try:
            response = urllib2.urlopen(self.token_endpoint, urlencode(params))
        except HTTPError as he:
            if he.code == 400:
                error_body = json.loads(he.read())
                return 400, error_body, None
            if he.code == 401:
                return 401, None, None
        except URLError as e:
            print e
            return 503, no_service, None

        token = json.load(response)
        return 200, None, token

    def update(self):
        self.action = self.request.getURL()
        method = self.request.method.lower()
        if method == 'post':
            self.code, self.error, self.token = self.login()
        else:
            self.code = None
            self.error = None
            self.token = None
Example #6
0
class FieldMacros(FieldMacros):
    grok.layer(IUKHAdHocLayer)
    template = ChameleonPageTemplateFile('templates/fieldtemplates.cpt')
Example #7
0
 def get_template(filename, dir):
     dir = path.join(path.dirname(dir), 'templates')
     return ChameleonPageTemplateFile(filename, dir)
Example #8
0
class FieldMacros(grok.View):
    grok.context(Interface)
    grok.layer(ISiguvTheme)

    template = ChameleonPageTemplateFile("templates/fieldtemplates.cpt")
Example #9
0
class WithFooTemplateNoExists(WithFooTemplate):
    template = ChameleonPageTemplateFile('templates/nothere.cpt')
Example #10
0
class WithFooTemplate(grokcore.view.View):
    grokcore.component.context(zope.interface.Interface)

    template = ChameleonPageTemplateFile('templates/foo.cpt')
Example #11
0
 def updateForm(self):
     super(ENMSCreateUser, self).updateForm()
     self.fieldWidgets.get('form.field.mnr').template = (
         ChameleonPageTemplateFile('templates/mnr.cpt'))
Example #12
0
class FieldMacros(grok.View):
    grok.context(Interface)
    template = ChameleonPageTemplateFile('templates/fieldtemplates.cpt')
Example #13
0
class FormMacros(grok.View):
    grok.context(Interface)
    template = ChameleonPageTemplateFile('templates/formtemplate.cpt')
Example #14
0
def getTemplate(path):
    return ChameleonPageTemplateFile(os.path.join(TEMPLATES, path))
Example #15
0
 def get_template(filename, dir):
     return ChameleonPageTemplateFile(path.join(path.dirname(dir), filename))