Changeset 85 for cleverbox/branches

Show
Ignore:
Timestamp:
07/10/06 13:10:56 (6 years ago)
Author:
trivoallan
Message:
  • User cannot choose client directory anymore
  • LDAP password is automatically set in apache conf
  • User is asked to enable project at project creation
Location:
cleverbox/branches/0.1/cleverbox
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • cleverbox/branches/0.1/cleverbox/scripts/admin.py

    r82 r85  
    66import sys 
    77import traceback 
     8import re 
    89from trac import util 
    910from trac.scripts.admin import TracAdmin 
     
    249250        if not self._client_exists(client_name): 
    250251 
     252            # Client name cannot contain strokes 
     253            if client_name.count('-') != 0: 
     254                print "** Client's identifier can not contain the '-' character." 
     255                return 
     256 
    251257            # Information collection 
    252258            collected_infos = { 'full_name'    : None, 
     
    254260                                'ftp_password' : None } 
    255261 
    256             print 
    257             print "Creating a new client." 
    258             print "Let's collect some informations about him : " 
    259             print 
    260             print "  Please enter client's full name." 
    261             print "  This will be used in several interface screens and in emails." 
    262             print 
    263  
    264             dfn = client_name.capitalize() 
    265             collected_infos['full_name'] = raw_input('Full Name [%s]> ' % dfn).strip() or dfn 
    266  
    267             print 
    268             print "  Please enter client's home directory." 
    269             print "  All data regarding client's projects will be stored in there." 
    270             print 
    271  
    272             dhd = os.path.join(self.getConfig('clients_root', 'general'), client_name) 
    273             collected_infos['home_dir'] = raw_input('Home Directory [%s]> ' % dhd).strip() or dhd 
     262            collected_infos['home_dir'] = os.path.join(self.getConfig('clients_root', 'general'), client_name) 
    274263 
    275264            # A few checks before effectively creating client 
     
    280269                print "Directory %s is not writable or already exists, aborting." % collected_infos['home_dir'] 
    281270                raise os.error 
     271 
     272 
     273            print 
     274            print "Creating a new client." 
     275            print "Let's collect some informations about him : " 
     276            print 
     277            print "  Please enter client's full name." 
     278            print "  This will be used in several interface screens and in emails." 
     279            print 
     280 
     281            dfn = client_name.capitalize() 
     282            collected_infos['full_name'] = raw_input('Full Name [%s]> ' % dfn).strip() or dfn 
    282283 
    283284            print 
     
    554555 
    555556        # Restrict to requested client 
     557        pattern = re.compile('(\w+)-(.*)') 
    556558        if (client_name): 
    557559            client_projects = [] 
    558             for p in list_projects: 
    559                 if p.rsplit('-')[0] == client_name: 
    560                     client_projects.append(p) 
     560            for project_name in list_projects: 
     561                matches = pattern.findall(project_name) 
     562                if (client_name == matches[0][0]): 
     563                    client_projects.append(matches[0][1]) 
    561564            list_projects = client_projects 
    562565 
    563         # Filter out the "client-" part 
    564         filtered_list = [] 
    565         for p in list_projects: 
    566             filtered_list.append(p.rsplit('-')[1]) 
    567  
    568         return filtered_list 
     566        return list_projects 
    569567 
    570568    def _do_project_disable(self, args): 
     
    697695                traceback.print_exc() 
    698696 
     697            # -- Enable client ? 
     698            print "Project has been created. Do you want to enable it ?" 
     699            print 
     700            enable_project = raw_input('Enable project ? [y/N]> ').strip() or False 
     701 
     702            if enable_project == 'y': 
     703                self._do_project_enable((client_name, project_name)) 
     704 
    699705        else: 
    700706            self.do_help('project') 
     
    764770       'project_name'  : infos['short_name'], 
    765771       'clients_root'  : self.getConfig('clients_root', 'general'), 
    766        'ldap_password' : '<LDAP_PASSWORD>' } 
     772       'ldap_password' : self.getConfig('ldap_password', 'general') } 
    767773 
    768774        apache_conf_filepath = os.path.join( self.envname, 'projects-available', '%s-%s' % (infos['client'], infos['short_name']) ) 
     
    936942        comp = [] 
    937943 
    938         # "enable" subcommand's first argument is client's name 
     944        # "disable" subcommand's first argument is client's name 
    939945        if not args or (len(args) <= 1 and args[0] not in self._get_clients()): 
    940946            comp = self._get_clients() 
    941         # "enable" subcommand second argument is project's name 
     947        # "disable" subcommand second argument is project's name 
    942948        else : 
    943949            comp = self._get_projects(args[0], 'enabled') 
     
    948954        comp = [] 
    949955 
    950         # "enable" subcommand's first argument is client's name 
     956        # "remove" subcommand's first argument is client's name 
    951957        if not args or (len(args) <= 1 and args[0] not in self._get_clients()): 
    952958            comp = self._get_clients() 
    953         # "enable" subcommand second argument is project's name 
     959        # "remove" subcommand second argument is project's name 
    954960        else : 
    955961            comp = self._get_projects(args[0]) 
     
    983989        try: 
    984990            if (os.path.isdir(directory)): 
     991                os.chown(directory, uid, gid) 
    985992                direntries = os.listdir(directory) 
    986993                for direntry in direntries: