Ignore:
Timestamp:
6 Mar 2017, 16:37:31 (8 years ago)
Author:
uli
Message:

flake8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/permissions.py

    r14602 r14603  
    1 ## $Id$
    2 ##
    3 ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
    4 ## This program is free software; you can redistribute it and/or modify
    5 ## it under the terms of the GNU General Public License as published by
    6 ## the Free Software Foundation; either version 2 of the License, or
    7 ## (at your option) any later version.
    8 ##
    9 ## This program is distributed in the hope that it will be useful,
    10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
    11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12 ## GNU General Public License for more details.
    13 ##
    14 ## You should have received a copy of the GNU General Public License
    15 ## along with this program; if not, write to the Free Software
    16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    17 ##
     1# $Id$
     2#
     3# Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
     4# This program is free software; you can redistribute it and/or modify
     5# it under the terms of the GNU General Public License as published by
     6# the Free Software Foundation; either version 2 of the License, or
     7# (at your option) any later version.
     8#
     9# This program is distributed in the hope that it will be useful,
     10# but WITHOUT ANY WARRANTY; without even the implied warranty of
     11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12# GNU General Public License for more details.
     13#
     14# You should have received a copy of the GNU General Public License
     15# along with this program; if not, write to the Free Software
     16# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
     17#
    1818import grok
    1919from zope.component import getUtilitiesFor
     
    2222from waeup.kofa.interfaces import ILocalRolesAssignable
    2323
     24
    2425class Public(grok.Permission):
    2526    """The Public or everyone-can-do-this-permission is being applied
     
    2728    """
    2829    grok.name('waeup.Public')
     30
    2931
    3032class Anonymous(grok.Permission):
     
    3537    grok.name('waeup.Anonymous')
    3638
     39
    3740class Authenticated(grok.Permission):
    3841    """The Authenticated permission is applied to pages
     
    4043    """
    4144    grok.name('waeup.Authenticated')
     45
    4246
    4347class ViewAcademics(grok.Permission):
     
    4852    grok.name('waeup.viewAcademics')
    4953
     54
    5055class ManageAcademics(grok.Permission):
    5156    """The ManageAcademics permission is applied to all edit/manage
     
    5560    grok.name('waeup.manageAcademics')
    5661
     62
    5763class ManagePortal(grok.Permission):
    5864    """The ManagePortal permission is used for very few pages
    59     (e.g. the DatacenterSettings page). Only PortalManagers have this 
     65    (e.g. the DatacenterSettings page). Only PortalManagers have this
    6066    permission. It is furthermore used to control delete methods of container
    6167    pages in the Academic Section. The ManageAcademics permission,
     
    6773    grok.name('waeup.managePortal')
    6874
     75
    6976class ManageUsers(grok.Permission):
    7077    """The ManageUsers permission is a real superuser permission
     
    7279    user accounts. Editing a user account includes the option to assign
    7380    or remove roles. That means that a user with this permission can lock out
    74     other users by either removing their account or by removing 
     81    other users by either removing their account or by removing
    7582    permissions.
    7683    """
    7784    grok.name('waeup.manageUsers')
     85
    7886
    7987class ShowStudents(grok.Permission):
     
    8997    grok.name('waeup.showStudents')
    9098
     99
    91100class ClearAllStudents(grok.Permission):
    92101    """The ClearAllStudents permission allows to clear all students
     
    95104    grok.name('waeup.clearAllStudents')
    96105
     106
    97107class EditScores(grok.Permission):
    98108    """The EditScores permission allows to edit scores in course tickets.
    99109    """
    100110    grok.name('waeup.editScores')
     111
    101112
    102113class TriggerTransition(grok.Permission):
     
    106117    grok.name('waeup.triggerTransition')
    107118
     119
    108120class EditUser(grok.Permission):
    109121    """The EditUser permission is required for editing
     
    111123    """
    112124    grok.name('waeup.editUser')
     125
    113126
    114127class ManageDataCenter(grok.Permission):
     
    119132    grok.name('waeup.manageDataCenter')
    120133
     134
    121135class ImportData(grok.Permission):
    122     """The ImportData permission allows to batch process (import) any kind of 
     136    """The ImportData permission allows to batch process (import) any kind of
    123137    portal data except for user data. The User Data processor
    124138    requires also the ManageUsers permission.
     
    126140    grok.name('waeup.importData')
    127141
     142
    128143class ExportData(grok.Permission):
    129144    """The ExportData permission allows to export any kind of portal data.
     
    131146    grok.name('waeup.exportData')
    132147
     148
    133149class ExportPaymentsOverview(grok.Permission):
    134150    grok.name('waeup.exportPaymentsOverview')
    135151
     152
    136153class ExportBursaryData(grok.Permission):
    137154    grok.name('waeup.exportBursaryData')
    138155
     156
    139157class ViewTranscript(grok.Permission):
    140158    grok.name('waeup.viewTranscript')
     159
    141160
    142161class ManagePortalConfiguration(grok.Permission):
     
    146165    grok.name('waeup.managePortalConfiguration')
    147166
     167
    148168class ManageACBatches(grok.Permission):
    149169    """The ManageACBatches permission allows to view and
     
    152172    grok.name('waeup.manageACBatches')
    153173
     174
    154175class PutBiometricDataPermission(grok.Permission):
    155176    """This permission allows to upload/change biometric data.
     
    157178    grok.name('waeup.putBiometricData')
    158179
     180
    159181class GetBiometricDataPermission(grok.Permission):
    160182    """This permission allows to read biometric data.
     
    167189class ApplicationsManager(grok.Role):
    168190    """The local ApplicationsManager role can be assigned at applicants
    169     container and at department level. At department level an Applications 
    170     Manager can manage all applicants which desire to study a programme 
     191    container and at department level. At department level an Applications
     192    Manager can manage all applicants which desire to study a programme
    171193    offered by the department (1st Choice Course of Study).
    172194
    173     At container level (local) Applications Managers gain permissions
    174     which allow to manage the container and all applicants inside the container.
    175     At container level the permission set of this local role corresonds with
    176     the permission set of the same-named global role.
     195    At container level (local) Applications Managers gain permissions which
     196    allow to manage the container and all applicants inside the container.  At
     197    container level the permission set of this local role corresonds with the
     198    permission set of the same-named global role.
    177199    """
    178200    grok.name('waeup.local.ApplicationsManager')
     
    182204                     'waeup.payApplicant')
    183205
     206
    184207class DepartmentManager(grok.Role):
    185208    """The local DepartmentManager role can be assigned at faculty or
     
    196219                     'waeup.exportData')
    197220
     221
    198222class DepartmentOfficer(grok.Role):
    199223    """The local DepartmentOfficer role can be assigned at faculty or
     
    211235                     'waeup.exportPaymentsOverview')
    212236
     237
    213238class ClearanceOfficer(grok.Role):
    214239    """The local ClearanceOfficer role can be assigned at faculty or
     
    227252                     'waeup.clearAllStudents')
    228253
     254
    229255class LocalStudentsManager(grok.Role):
    230256    """The local LocalStudentsManager role can be assigned at faculty or
     
    242268                     'waeup.exportData')
    243269
     270
    244271class LocalWorkflowManager(grok.Role):
    245272    """The local LocalWorkflowManager role can be assigned at faculty level.
     
    257284                     'waeup.exportData')
    258285
     286
    259287class UGClearanceOfficer(grok.Role):
    260288    """UG Clearance Officers are regular Clearance Officers with restricted
     
    269297                     'waeup.clearAllStudents')
    270298
     299
    271300class PGClearanceOfficer(grok.Role):
    272301    """PG Clearance Officers are regular Clearance Officers with restricted
     
    281310                     'waeup.clearAllStudents')
    282311
     312
    283313class CourseAdviser100(grok.Role):
    284314    """The local CourseAdviser100 role can be assigned at faculty,
    285     department or certificate level. The role allows to view all data and 
    286     to list or export all student data within the faculty, department 
     315    department or certificate level. The role allows to view all data and
     316    to list or export all student data within the faculty, department
    287317    or certificate the local role is assigned.
    288318
     
    297327                     'waeup.exportData')
    298328
     329
    299330class CourseAdviser200(grok.Role):
    300331    """Same as CourseAdviser100 but for level 200.
     
    306337                     'waeup.exportData')
    307338
     339
    308340class CourseAdviser300(grok.Role):
    309341    """Same as CourseAdviser100 but for level 300.
     
    315347                     'waeup.exportData')
    316348
     349
    317350class CourseAdviser400(grok.Role):
    318351    """Same as CourseAdviser100 but for level 400.
     
    324357                     'waeup.exportData')
    325358
     359
    326360class CourseAdviser500(grok.Role):
    327361    """Same as CourseAdviser100 but for level 500.
     
    333367                     'waeup.exportData')
    334368
     369
    335370class CourseAdviser600(grok.Role):
    336371    """Same as CourseAdviser100 but for level 600.
     
    342377                     'waeup.exportData')
    343378
     379
    344380class CourseAdviser700(grok.Role):
    345381    """Same as CourseAdviser100 but for level 700.
     
    351387                     'waeup.exportData')
    352388
     389
    353390class CourseAdviser800(grok.Role):
    354391    """Same as CourseAdviser100 but for level 800.
     
    359396                     'waeup.viewAcademics',
    360397                     'waeup.exportData')
     398
    361399
    362400class Lecturer(grok.Role):
     
    372410                     'waeup.exportData')
    373411
     412
    374413class Owner(grok.Role):
    375414    """Each user 'owns' her/his user object and gains permission to edit
     
    380419    grok.permissions('waeup.editUser')
    381420
     421
    382422# Site Roles
    383 
    384423class AcademicsOfficer(grok.Role):
    385424    """An Academics Officer can view but not edit data in the
     
    393432    grok.title(u'Academics Officer (view only)')
    394433    grok.permissions('waeup.viewAcademics')
     434
    395435
    396436class AcademicsManager(grok.Role):
     
    405445                     'waeup.manageAcademics')
    406446
     447
    407448class ACManager(grok.Role):
    408449    """This is the role for Access Code Managers.
     
    413454    grok.title(u'Access Code Manager')
    414455    grok.permissions('waeup.manageACBatches')
     456
    415457
    416458class DataCenterManager(grok.Role):
     
    424466    grok.permissions('waeup.manageDataCenter')
    425467
     468
    426469class ImportManager(grok.Role):
    427470    """An Import Manager is a Data Center Manager who is also allowed
    428     to batch process (import) data. All batch processors (importers) are 
     471    to batch process (import) data. All batch processors (importers) are
    429472    available except for the User Processor. This processor requires the
    430473    Users Manager role too. The ImportManager role includes the
     
    436479                     'waeup.importData')
    437480
     481
    438482class ExportManager(grok.Role):
    439483    """An Export Manager is a Data Center Manager who is also allowed
     
    446490                     'waeup.exportData')
    447491
     492
    448493class BursaryOfficer(grok.Role):
    449494    """Bursary Officers can export bursary data. They can't access the
     
    455500                     'waeup.viewAcademics',
    456501                     'waeup.exportBursaryData')
     502
    457503
    458504class UsersManager(grok.Role):
     
    465511    grok.permissions('waeup.manageUsers',
    466512                     'waeup.editUser')
     513
    467514
    468515class WorkflowManager(grok.Role):
     
    508555                     'waeup.viewTranscript',
    509556                     'waeup.viewDocuments', 'waeup.manageDocuments',
    510                      'waeup.managePortalConfiguration', 'waeup.viewApplication',
     557                     'waeup.managePortalConfiguration',
     558                     'waeup.viewApplication',
    511559                     'waeup.manageApplication', 'waeup.handleApplication',
    512560                     'waeup.viewApplicantsTab', 'waeup.payApplicant',
     
    514562                     'waeup.viewStudent', 'waeup.manageStudent',
    515563                     'waeup.clearStudent', 'waeup.payStudent',
    516                      'waeup.clearStudentFinancially',  # not used in base package
     564                     'waeup.clearStudentFinancially',  # not used in base pkg
    517565                     'waeup.uploadStudentFile', 'waeup.showStudents',
    518566                     'waeup.clearAllStudents',
     
    530578                     )
    531579
     580
    532581class CCOfficer(grok.Role):
    533582    """The role of the Computer Center Officer is basically a copy
     
    545594    grok.name('waeup.CCOfficer')
    546595    grok.title(u'Computer Center Officer')
    547     grok.permissions(#'waeup.managePortal',
    548                      #'waeup.manageUsers',
    549                      'waeup.viewAcademics', 'waeup.manageAcademics',
    550                      #'waeup.manageACBatches',
    551                      'waeup.manageDataCenter',
    552                      #'waeup.importData',
    553                      'waeup.exportData',
    554                      'waeup.viewTranscript',
    555                      'waeup.viewDocuments', 'waeup.manageDocuments',
    556                      'waeup.managePortalConfiguration', 'waeup.viewApplication',
    557                      'waeup.manageApplication', 'waeup.handleApplication',
    558                      'waeup.viewApplicantsTab', 'waeup.payApplicant',
    559                      'waeup.viewApplicationStatistics',
    560                      'waeup.viewStudent', 'waeup.manageStudent',
    561                      'waeup.clearStudent', 'waeup.payStudent',
    562                      'waeup.uploadStudentFile', 'waeup.showStudents',
    563                      'waeup.clearAllStudents',
    564                      'waeup.editScores',
    565                      #'waeup.triggerTransition',
    566                      'waeup.validateStudent',
    567                      'waeup.viewStudentsContainer',
    568                      'waeup.handleAccommodation',
    569                      'waeup.viewHostels', 'waeup.manageHostels',
    570                      #'waeup.editUser',
    571                      #'waeup.loginAsStudent',
    572                      'waeup.handleReports',
    573                      'waeup.manageReports',
    574                      #'waeup.manageJobs',
    575                      )
     596    grok.permissions(
     597        # 'waeup.managePortal',
     598        # 'waeup.manageUsers',
     599        'waeup.viewAcademics',
     600        'waeup.manageAcademics',
     601        # 'waeup.manageACBatches',
     602        'waeup.manageDataCenter',
     603        # 'waeup.importData',
     604        'waeup.exportData',
     605        'waeup.viewTranscript',
     606        'waeup.viewDocuments', 'waeup.manageDocuments',
     607        'waeup.managePortalConfiguration', 'waeup.viewApplication',
     608        'waeup.manageApplication', 'waeup.handleApplication',
     609        'waeup.viewApplicantsTab', 'waeup.payApplicant',
     610        'waeup.viewApplicationStatistics',
     611        'waeup.viewStudent', 'waeup.manageStudent',
     612        'waeup.clearStudent', 'waeup.payStudent',
     613        'waeup.uploadStudentFile', 'waeup.showStudents',
     614        'waeup.clearAllStudents',
     615        'waeup.editScores',
     616        # 'waeup.triggerTransition',
     617        'waeup.validateStudent',
     618        'waeup.viewStudentsContainer',
     619        'waeup.handleAccommodation',
     620        'waeup.viewHostels', 'waeup.manageHostels',
     621        # 'waeup.editUser',
     622        # 'waeup.loginAsStudent',
     623        'waeup.handleReports',
     624        'waeup.manageReports',
     625        # 'waeup.manageJobs',
     626        )
     627
    576628
    577629def get_all_roles():
     
    579631    """
    580632    return getUtilitiesFor(IRole)
     633
    581634
    582635def get_waeup_roles(also_local=False):
     
    601654        yield item
    602655
     656
    603657def get_waeup_role_names():
    604658    """Get the ids of all Kofa roles.
     
    609663    """
    610664    return sorted([x.id for x in get_waeup_roles()])
     665
    611666
    612667class LocalRolesAssignable(grok.Adapter):
     
    654709        return sorted(list_of_dict, key=lambda x: x['name'])
    655710
     711
    656712def get_all_users():
    657713    """Get a list of dictionaries.
     
    660716    for key, val in users:
    661717        yield(dict(name=key, val=val))
     718
    662719
    663720def get_users_with_local_roles(context):
     
    674731        raise StopIteration
    675732    for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
    676         user = grok.getSite()['users'].get(user_name,None)
     733        user = grok.getSite()['users'].get(user_name, None)
    677734        user_title = getattr(user, 'title', user_name)
    678735        local_role_title = getattr(
    679736            dict(get_all_roles()).get(local_role, None), 'title', None)
    680         yield dict(user_name = user_name,
    681                    user_title = user_title,
    682                    local_role = local_role,
    683                    local_role_title = local_role_title,
    684                    setting = setting)
     737        yield dict(user_name=user_name,
     738                   user_title=user_title,
     739                   local_role=local_role,
     740                   local_role_title=local_role_title,
     741                   setting=setting)
     742
    685743
    686744def get_users_with_role(role, context):
     
    694752        raise StopIteration
    695753    for user_name, setting in role_map.getPrincipalsForRole(role):
    696         user = grok.getSite()['users'].get(user_name,None)
     754        user = grok.getSite()['users'].get(user_name, None)
    697755        user_title = getattr(user, 'title', user_name)
    698756        user_email = getattr(user, 'email', None)
    699         yield dict(user_name = user_name,
    700                    user_title = user_title,
    701                    user_email = user_email,
    702                    setting = setting)
     757        yield dict(user_name=user_name,
     758                   user_title=user_title,
     759                   user_email=user_email,
     760                   setting=setting)
Note: See TracChangeset for help on using the changeset viewer.