Changeset 359

Show
Ignore:
Timestamp:
Fri Jan 4 17:47:49 2008
Author:
Brian
Message:

Update server to use current versions of Data and StartupData?.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • server/trunk/update/server/Data.py

    r176 r359  
    98 98 # 060725 - Alex - added AddAlias and UpdateAliases  
    99 99 # 060802 - Brian - added Task's StartHour to check change  
      100 # 060826 - Alex - allow AddReportType to change column labels after all  
      101 # 070328 - Brian - Change SetCellValue so that it will not change protected cells  
      102 # 070731 - Alex - hide assignment or dependency records that point to a deleted task or resource (somewhat ad hoc)  
    100 103  
    101 104 import datetime, calendar  
     
    136 139     return locals()  
    137 140  
    138   App = None  # the application itself  
      141 App = None  # the application itself (deprecated)  
    138 141 ActiveReport = 1  # ReportID of most recently active frame  
    139 142  
     
    145 148 Path = ""               # Directory containing executed program, look for option file here  
    146 149  
    147   ##def CreateEmptyTables():  
    148   ##    global Database, Project, Task, Dependency, Report, ReportColumn, ReportRow  
    149   ##    global Resource, Assignment, Holiday, ReportType, ColumnType, OtherData, Other, NextID  
    150   ##    Database = {}  
    151   ##    Project = {}  
    152   ##    Task = {}  
    153   ##    Dependency = {}  
    154   ##    Report = {}  
    155   ##    ReportColumn = {}  
    156   ##    ReportRow = {}  
    157   ##    Resource = {}  
    158   ##    Assignment = {}  
    159   ##    Holiday = {}  
    160   ##    ReportType = {}  
    161   ##    ColumnType = {}  
    162   ##    OtherData = {}  # used in updates  
    163   ##    Other = {}  
    164   ##    NextID = {}  
    165    
    166 150 # save impact of change until it can be addressed  
    167 151 ChangedCalendar = False  # will affect calendar hours tables (gantt will have to be redone, too)  
     
    185 169 Option = StartupData.GanttPVOptions()  
    186 170  
    187   ##Option = {  'AutoGantt' : True,  # Delay calculation of calendar and schedule changes  
    188   ##            'ConfirmScripts': True,  # scripts should display a confirm dialog  
    189   ##            'ScriptDirectory': None,  # where script directory is located  
    190   ###           'HelpfulWarnings': True,  # display warning popups  -- do I want to do this?  
    191   ### ProjecReport Colors  
    192   ##            'ParentColor': ( 153, 153, 255 ),  
    193   ##            'ChildColor': ( 238, 238, 238 ),  
    194   ##            'HiddenColor': ( 204, 204, 204 ),  
    195   ##            'DeletedColor': ( 255, 102, 204 ),  
    196   ### Gantt Chart Colors  
    197   ### background  
    198   ##            'WorkDay': (230, 230, 230),  
    199   ##            'WorkDaySelected': (153, 204, 255),  # make this lighter  # maybe use white only for the selected column?  
    200   ##            'NotWorkDay': (204, 204, 204),  # more light focused on the selection  
    201   ##            'NotWorkDaySelected': (136, 187, 238),  
    202   ### bars  
    203   ##            'PlanBar': (0, 153, 102),   # green  # maybe use same color for selected & not  
    204   ##            'PlanBarSelected': (0, 153, 102),  
    205   ##            'ActualBar': (0, 0, 255),    # yellow?  
    206   ##            'ActualBarSelected': (0, 0, 255),  
    207   ##            'BaseBar': (0, 255, 0),   # green?  
    208   ##            'BaseBarSelected': (0, 255, 0),  
    209   ##            'CompletionBar': None,  # based on BaseBar or PlanBar  
    210   ##            'CompletionBarSelected': None,  
    211   ##  
    212   ###           'ResourceProblem': None,  
    213   ###           'ResourceProblemSelected': None,  
    214   ##        }  
    215 171  
    216 172 # -------------- Setup Empty and Sample databases  
     
    218 174 # reserved table column names: 'Table', 'ID', 'zzStatus', anything ending with 'ID", anything starting with 'xx'  
    219 175  
    220   ##def SetOther():  
    221   ##    """ These are the values that only occur once in the database """  
    222   ##    OtherData[1] = { 'ID' : 1,  
    223   ##        'WeekHours' : (8, 8, 8, 8, 8, 0, 0),  # hours per day, MTWHFSS  
    224   ##        }  
    225   ##    Database['OtherData'] = OtherData  
    226   ##    Database['NextID'] = NextID  
    227   ##    Database['Prerequisite'] = Database['Task']  # synonym for Task  
    228   ##  
    229   ##def FillTable(name, t, Columns, Data):  
    230   ##    """ Utility routine to load sample (or initial) data into database """  
    231   ##    for i, d in enumerate(Data):  
    232   ##        id = i+1  
    233   ##        t[id] = {}  
    234   ##        t[id]['ID'] = id  
    235   ##  
    236   ##        for c, r in zip( Columns, d ):  
    237   ##            if r or r == 0:  
    238   ##                t[id][c] = r  
    239   ##    NextID[name] = len(Data) + 1  
    240   ##    Database[name] = t  
    241    
    242   ##def SetTypes():  
    243   ##    """ Create default report types """  
    244   ##    # ReportType  
    245   ##    # Also ( allow user to select from this report type's columns also )  
    246   ##    Columns = ( 'Also', 'Name', 'TableA', 'TableB', 'Label' )  
    247   ##    Data = ( ( None, 'Project', 'Project' ),  
    248   ##             ( 1,    'Project/Report', 'Project', 'Report' ),  
    249   ##             ( None, 'Task', 'Task' ),  
    250   ##             ( 3,    'Task/Assignment', 'Task', 'Assignment' ),  
    251   ##             ( 3,    'Task/Dependency', 'Task', 'Dependency' ),  
    252   ##             ( None, 'Report', 'Report' ),  
    253   ##             ( 6,    'Report/ReportColumn', 'Report', 'ReportColumn' ),  
    254   ##             ( None, 'Resource', 'Resource' ),  
    255   ##             ( 8,    'Resource/Assignment', 'Resource', 'Assignment' ),  
    256   ##             ( None, 'Holiday', 'Holiday'),  
    257   ##             ( None, 'ReportType', 'ReportType' ),  
    258   ##             ( 11, 'ReportType/ColumnType', 'ReportType', 'ColumnType' ),  
    259   ##            )  
    260   ##    FillTable('ReportType', ReportType, Columns, Data)  
    261   ##  
    262   ##    # ColumnType  
    263   ##    # DataType ( i = integer, t = text, d = date, g = graphic )  
    264   ##    # AccessType ( da = direct table a, db = direct table b, bi = indirect, s = special )  
    265   ##    # Edit ( True = allow user to change value, False = display only column )  
    266   ##    Columns = ('ReportTypeID', 'DataType', 'AccessType', 'T', 'Edit', 'Width', 'Name', 'Label')  
    267   ##    Data = ( ( 1, 'i', 'd', 'A', False, None, 'ID' ),                # Project  
    268   ##             ( 1, 't', 'd', 'A', True,  140, 'Name' ),  
    269   ##             ( 1, 'd', 'd', 'A', True,  80, 'StartDate', 'Start Date' ),  
    270   ##             ( 1, 'd', 'd', 'A', True,  80, 'TargetEndDate', 'Target\nEnd Date' ),  
    271   ##             ( 2, 'i', 'd', 'B', False, None, 'ID' ),                # Project/Report  
    272   ##             ( 2, 't', 'd', 'B', True,  140, 'Name'),  
    273   ##             ( 3, 'i', 'd', 'A', False, None, 'ID' ),                # Task  
    274   ##             ( 3, 'i', 'd', 'A', False, 80, 'ProjectID', 'Project\nID' ),  
    275   ##             ( 3, 't', 'd', 'A', True,  140, 'Name' ),  
    276   ##             ( 3, 'd', 'd', 'A', True,  80, 'StartDate', 'Start Date' ),  
    277   ##             ( 3, 'i', 'd', 'A', True,  80, 'DurationHours', 'Duration' ),  
    278   ##             ( 3, 'd', 'd', 'A', False, 80, 'CalculatedStartDate', 'Start Date\n(Calculated)' ),  
    279   ##             ( 3, 'd', 'd', 'A', False, 80, 'CalculatedEndDate', 'End Date\n(Calculated)' ),  
    280   ##             ( 3, 'g', 's', 'X', False, None, 'Day/Gantt' ),  
    281   ##             ( 3, 'i', 's', 'X', False, None, 'Day/Hours' ),  
    282   ##             ( 4, 'i', 'd', 'B', False, None, 'ID' ),                # Task/Assignment  
    283   ##             ( 4, 't', 'i', 'B', True,  140, 'Resource/Name' ),  
    284   ##             # ( 4, 'i', 's', 'x', False, None, 'Day/Hours' ),  
    285   ##             ( 5, 'i', 'd', 'B', False, None, 'ID' ),                # Task/Dependency  
    286   ##             ( 5, 't', 'i', 'B', True,  140, 'Prerequisite/Name' ),  
    287   ##             # ( 5, 'i', 's', 'X', False, None, 'Day/Hours' ),  
    288   ##             ( 6, 'i', 'd', 'A', False, None, 'ID' ),                # Report  
    289   ##             ( 6, 't', 'd', 'A', True,  140, 'Name' ),  
    290   ##             # ( 6, 't', 'd', 'a', False, 80, 'TableA', 'Table\nA' ),  
    291   ##             ( 6, 't', 'd', 'A', False, 80, 'SelectColumn', 'Select\nColumn' ),  
    292   ##             ( 6, 'i', 'd', 'A', False, 80, 'SelectValue', 'Select\nValue' ),  
    293   ##             ( 6, 'i', 'd', 'A', False, None, 'ProjectID', 'Project\nID' ),  
    294   ##             ( 7, 'i', 'd', 'B', False, None, 'ID' ),                # Report/ReportColumn  
    295   ##             ( 7, 'i', 'd', 'B', True,  40, 'Width' ),  
    296   ##             ( 7, 't', 'd', 'B', True,  140, 'Label' ),  
    297   ##             # ( 7, ' 'A', 'TypeA', 'B', 'TypeB', 'Time',  
    298   ##             ( 7, 'i', 'd', 'B', True,  40, 'Periods' ),  
    299   ##             ( 7, 'd', 'd', 'B', True,  80, 'FirstDate', 'First\nDate' ),  
    300   ##             ( 8, 'i', 'd', 'A', False, None, 'ID' ),                # Resource  
    301   ##             ( 8, 't', 'd', 'A', True,  80, 'ShortName', 'Short\nName' ),  
    302   ##             ( 8, 't', 'd', 'A', True,  140, 'Name' ),  
    303   ##             ( 9, 'i', 'd', 'B', False, None, 'ID' ),                # Resource/Assignment  
    304   ##             ( 9, 't', 'i', 'B', True,  140, 'Task/Name' ),  
    305   ##             ( 9, 'i', 's', 'X', False, None, 'Day/Hours' ),  
    306   ##             ( 10, 'i', 'd', 'A', False, None, 'ID' ),               # Holiday  
    307   ##             ( 10, 't', 'd', 'A', True,  140, 'Name' ),  
    308   ##             ( 10, 'd', 'd', 'A', True,  80, 'Date' ),  
    309   ##             ( 10, 'i', 'd', 'A', True,  40, 'Hours' ),  
    310   ##             ( 11, 'i', 'd', 'A', False, None, 'ID' ),               # ReportType  
    311   ##             ( 11, 'i', 'd', 'A', False, 40, 'Also' ),  
    312   ##             ( 11, 't', 'd', 'A', False, 140, 'Name' ),  # 42  
    313   ##             ( 11, 't', 'd', 'A', False, 100, 'TableA', 'Table\nA' ),  
    314   ##             ( 11, 't', 'd', 'A', False, 100, 'TableB', 'Table\nB' ),  
    315   ##             ( 11, 't', 'd', 'A', True,  120, 'Label' ),  
    316   ##             ( 12, 'i', 'd', 'B', False, None, 'ID' ),               # ColumnType  
    317   ##             # ( 12, 'i', 'd', 'B', False, None, 'ReportTypeID', 'Report Type\nID' ),  
    318   ##             ( 12, 't', 'd', 'B', False, None, 'DataType', 'Data Type' ),  
    319   ##             ( 12, 't', 'd', 'B', False, None, 'AccessType', 'Access Type' ),  
    320   ##             ( 12, 'b', 'd', 'B', False, None, 'Edit' ),  
    321   ##             ( 12, 't', 'd', 'B', False, 140, 'Name' ),  
    322   ##             ( 12, 't', 'd', 'B', True,  140, 'Label' ),  
    323   ##            )  
    324   ##    FillTable('ColumnType', ColumnType, Columns, Data)  
    325    
    326 176 def SetEmptyData():  
    327       global Database  
    328    
      177     global Database, FileName  
    329 178     Database = StartupData.GanttPVData()  
      179     FileName = None  
    330 180  
    331 181     # CloseReports()  
     
    333 183     # MakeReady()  
    334 184  
    335   ##def SetEmptyData():  
    336   ##    """ Create empty data tables that are ready to use """  
    337   ##    global FileName, Database, UndoStack, RedoStack, ChangedData  
    338   ##    if debug: print "Start SetEmptyData"  
    339   ##  
    340   ##    FileName = None  # Filename of current database  
    341   ##    CreateEmptyTables()  
    342   ##    UndoStack = []  
    343   ##    RedoStack = []  
    344   ##    ChangedData = False  
    345   ##  
    346   ##    # fill in tables w/ no default values  
    347   ##    Database['Dependency'] = Dependency  
    348   ##    Database['Resource'] = Resource  
    349   ##    Database['Assignment'] = Assignment  
    350   ##    Database['Holiday'] = Holiday  
    351   ##    NextID['Dependency'] = 1  
    352   ##    NextID['Resource'] = 1  
    353   ##    NextID['Assignment'] = 1  
    354   ##    NextID['Holiday'] = 1  
    355   ##  
    356   ##    # Project  
    357   ##    Columns = ('Name', 'StartDate', 'TargetEndDate')  
    358   ##    Data = ( ( 'All Projects',),  
    359   ##             ( 'New Project',),  
    360   ##           )  
    361   ##    FillTable('Project', Project, Columns, Data)  
    362   ##  
    363   ##    # Task  
    364   ##    Columns = ('ProjectID', 'Name' )  
    365   ##    Data = ( ( 2, 'First Task' ),  
    366   ##           )  
    367   ##    FillTable('Task', Task, Columns, Data)  
    368   ##  
    369   ##    # Report  
    370   ##    Columns = ('ReportTypeID', 'Name', 'FirstColumn', 'FirstRow', 'SelectColumn', 'SelectValue', 'ProjectID')  
    371   ##     
    372   ##    # TableB must contain a column that is named TableA + "ID" that can be used to link the tables  
    373   ##    # SelectColumn must be in TableA  
    374   ##    Data = ( ( 2, 'Project/Report List', 1, 1, None, None, 1 ),  
    375   ##                ( 12, 'Report Options', 4, 8, None, None, 1 ),  
    376   ##                ( 8, 'Resource List', 5, 0,  None, None, 1 ),  
    377   ##                ( 3, 'Gantt Chart', 6, 4, 'ProjectID', 2, 2 ),  
    378   ##            )  
    379   ##    FillTable('Report', Report, Columns, Data)  
    380   ##    #  
    381   ##    Columns = ('ColumnTypeID', 'ReportID', 'NextColumn', 'Width', 'Label', 'A', 'TypeA', 'B', 'TypeB', 'Time', 'Periods', 'FirstDate')  
    382   ##    Data = ( ( 2, 1, 2, 140,         'Name',                 'Name',         'CHAR',         'Name','CHAR',  '', 0, '' ),  
    383   ##                ( 3, 1, 3, 80,          'Start Date',           'StartDate',    'DATE',         '','',          '', 0, '' ),  
    384   ##                ( 4, 1, 0, 80,          'Target Date',          'TargetEndDate', 'DATE',        '','',          '', 0, '' ),  
    385   ##                ( 42, 2, 12, 140,       'Name',                 'Name',         'CHAR',         '','',          '', 0, '' ),  
    386   ##                ( 32, 3, 0, 140,        'Name',                 'Name',         'CHAR',         '','',          '', 0, '' ),  
    387   ##                ( 9, 4, 7, 140,         'Name',                 'Name',         'CHAR',         '','',          '', 0, '' ),  
    388   ##                ( 10, 4, 8, 80,         'Start Date',           'StartDate',    'DATE',         '','',          '', 0, '' ),  
    389   ##                ( 11, 4, 9, 80,         'Duration',             'DurationHours', 'INT',         '','',          '', 0, '' ),  
    390   ##                ( 12, 4, 10, 80,        'Start Date\n(Calculated)', 'CalculatedStartDate', 'DATE',      '','',          '', 0, '' ),  
    391   ##                ( 13, 4, 11, 80,        'End Date\n(Calculated)', 'CalculatedEndDate', 'DATE',  '','',          '', 0, '' ),  
    392   ##                ( 14, 4, 0, None,       '',                     '',             'CHART',        '','',          'Day', 21, GetToday() ),  
    393   ##                (  50, 2, None, 140, None, None, None, None, None, None, None, None )  
    394   ##            )  
    395   ##    FillTable('ReportColumn', ReportColumn, Columns, Data)  
    396   ##  
    397   ##    # dump of file (didn't use this, just edited the above  
    398   ##    # Columns = ( 'ColumnTypeID', 'ReportID', 'NextColumn', 'Width', 'Label', 'A', 'TypeA', 'B', 'TypeB', 'Time', 'Periods', 'FirstDate' )  
    399   ##    # Data = (  
    400   ##    #         (  2, 1, 2, 140, 'Name', 'Name', 'CHAR', 'Name', 'CHAR', '', 0, '' )  
    401   ##    #         (  3, 1, 3, 80, 'Start Date', 'StartDate', 'DATE', '', '', '', 0, '' )  
    402   ##    #         (  4, 1, 0, 80, 'Target Date', 'TargetEndDate', 'DATE', '', '', '', 0, '' )  
    403   ##    #         (  42, 2, 12, 140, 'Name', 'Name', 'CHAR', '', '', '', 0, '' )  
    404   ##    #         (  32, 3, 0, 140, 'Name', 'Name', 'CHAR', '', '', '', 0, '' )  
    405   ##    #         (  9, 4, 7, 140, 'Name', 'Name', 'CHAR', '', '', '', 0, '' )  
    406   ##    #         (  10, 4, 8, 80, 'Start Date', 'StartDate', 'DATE', '', '', '', 0, '' )  
    407   ##    #         (  11, 4, 9, 80, 'Duration', 'DurationHours', 'INT', '', '', '', 0, '' )  
    408   ##    #         (  12, 4, 10, 80, 'Start Date\n(Calculated)', 'CalculatedStartDate', 'DATE', '', '', '', 0, '' )  
    409   ##    #         (  13, 4, 11, 80, 'End Date\n(Calculated)', 'CalculatedEndDate', 'DATE', '', '', '', 0, '' )  
    410   ##    #         (  14, 4, 0, None, '', '', 'CHART', '', '', 'Day', 21, '2004-04-13' )  
    411   ##    #         (  50, 2, None, 140, None, None, None, None, None, None, None, None )  
    412   ##    #         )  
    413   ##    #         FillTable(' ReportColumn ',  ReportColumn , Columns, Data)  
    414   ##  
    415   ##    # old version  
    416   ##    # Columns = ('ReportID', 'TableName', 'TableID', 'NextRow')  
    417   ##    # Data = (  
    418   ##    #         (1, 'Project', 1,  2 ),  
    419   ##    #         (1, 'Project', 2,  3 ),  
    420   ##    #         (1, 'Report', 4, 0 ),  # lists only the gantt chart report  
    421   ##    #         (4, 'Task', 1, 0 ),  
    422   ##    #         )  
    423   ##    # FillTable('ReportRow', ReportRow, Columns, Data)  
    424   ##  
    425   ##    Columns = ( 'ReportID', 'TableName', 'TableID', 'NextRow', 'Hidden' )  
    426   ##    Data = ( (  1, 'Project', 1, 5, None ),  
    427   ##             (  1, 'Project', 2, 3, None ),  
    428   ##             (  1, 'Report', 4, 0, None ),  
    429   ##             (  4, 'Task', 1, 0, None ),  
    430   ##             (  1, 'Report', 1, 6, None ),  
    431   ##             (  1, 'Report', 2, 7, True ),  
    432   ##             (  1, 'Report', 3, 2, None ),  
    433   ##             (  2, 'ReportType', 1, 20, None ),  
    434   ##             (  2, 'ReportType', 2, 24, None ),  
    435   ##             (  2, 'ReportType', 3, 26, None ),  
    436   ##             (  2, 'ReportType', 4, 35, None ),  
    437   ##             (  2, 'ReportType', 5, 37, None ),  
    438   ##             (  2, 'ReportType', 6, 39, True ),  
    439   ##             (  2, 'ReportType', 7, 44, True ),  
    440   ##             (  2, 'ReportType', 8, 49, None ),  
    441   ##             (  2, 'ReportType', 9, 52, None ),  
    442   ##             (  2, 'ReportType', 10, 55, None ),  
    443   ##             (  2, 'ReportType', 11, 59, True ),  
    444   ##             (  2, 'ReportType', 12, 65, True ),  
    445   ##             (  2, 'ColumnType', 1, 21, None ),  
    446   ##             (  2, 'ColumnType', 2, 22, None ),  
    447   ##             (  2, 'ColumnType', 3, 23, None ),  
    448   ##             (  2, 'ColumnType', 4, 9, None ),  
    449   ##             (  2, 'ColumnType', 5, 25, None ),  
    450   ##             (  2, 'ColumnType', 6, 10, None ),  
    451   ##             (  2, 'ColumnType', 7, 27, None ),  
    452   ##             (  2, 'ColumnType', 8, 28, None ),  
    453   ##             (  2, 'ColumnType', 9, 29, None ),  
    454   ##             (  2, 'ColumnType', 10, 30, None ),  
    455   ##             (  2, 'ColumnType', 11, 31, None ),  
    456   ##             (  2, 'ColumnType', 12, 32, None ),  
    457   ##             (  2, 'ColumnType', 13, 33, None ),  
    458   ##             (  2, 'ColumnType', 14, 34, None ),  
    459   ##             (  2, 'ColumnType', 15, 11, True ),  
    460   ##             (  2, 'ColumnType', 16, 36, None ),  
    461   ##             (  2, 'ColumnType', 17, 12, None ),  
    462   ##             (  2, 'ColumnType', 18, 38, None ),  
    463   ##             (  2, 'ColumnType', 19, 13, None ),  
    464   ##             (  2, 'ColumnType', 20, 40, True ),  
    465   ##             (  2, 'ColumnType', 21, 41, True ),  
    466   ##             (  2, 'ColumnType', 22, 42, True ),  
    467   ##             (  2, 'ColumnType', 23, 43, True ),  
    468   ##             (  2, 'ColumnType', 24, 14, True ),  
    469   ##             (  2, 'ColumnType', 25, 45, True ),  
    470   ##             (  2, 'ColumnType', 26, 46, True ),  
    471   ##             (  2, 'ColumnType', 27, 47, True ),  
    472   ##             (  2, 'ColumnType', 28, 48, True ),  
    473   ##             (  2, 'ColumnType', 29, 15, True ),  
    474   ##             (  2, 'ColumnType', 30, 50, None ),  
    475   ##             (  2, 'ColumnType', 31, 51, None ),  
    476   ##             (  2, 'ColumnType', 32, 16, None ),  
    477   ##             (  2, 'ColumnType', 33, 53, None ),  
    478   ##             (  2, 'ColumnType', 34, 54, None ),  
    479   ##             (  2, 'ColumnType', 35, 17, True ),  
    480   ##             (  2, 'ColumnType', 36, 56, None ),  
    481   ##             (  2, 'ColumnType', 37, 57, None ),  
    482   ##             (  2, 'ColumnType', 38, 58, None ),  
    483   ##             (  2, 'ColumnType', 39, 18, None ),  
    484   ##             (  2, 'ColumnType', 40, 60, True ),  
    485   ##             (  2, 'ColumnType', 41, 61, True ),  
    486   ##             (  2, 'ColumnType', 42, 62, True ),  
    487   ##             (  2, 'ColumnType', 43, 63, True ),  
    488   ##             (  2, 'ColumnType', 44, 64, True ),  
    489   ##             (  2, 'ColumnType', 45, 19, True ),  
    490   ##             (  2, 'ColumnType', 46, 66, True ),  
    491   ##             (  2, 'ColumnType', 47, 67, True ),  
    492   ##             (  2, 'ColumnType', 48, 68, True ),  
    493   ##             (  2, 'ColumnType', 49, 69, True ),  
    494   ##             (  2, 'ColumnType', 50, 70, True ),  
    495   ##             (  2, 'ColumnType', 51, 0, True ),  
    496   ##           )  
    497   ##    FillTable('ReportRow',  ReportRow , Columns, Data)  
    498   ##    #  
    499   ##    SetTypes()  
    500   ##    SetOther()  
    501   ##    if debug: print "End SetEmptyData"  
    502    
    503   ### set up sample database  
    504   ##def SetSampleData():  
    505   ##    """ Fill data tables with sample/demonstration data """  
    506   ##    global FileName, Database, UndoStack, RedoStack, ChangedData  
    507   ##    if debug: print "Start SetSampleData"  
    508   ##  
    509   ##    FileName = None  # Filename of current database  
    510   ##    CreateEmptyTables()  
    511   ##    UndoStack = []  
    512   ##    RedoStack = []  
    513   ##    ChangedData = False  
    514   ##    #  
    515   ##    Columns = ('Name', 'StartDate', 'TargetEndDate')  
    516   ##    Data = ( ( 'All Projects', None, None ),  
    517   ##             ( 'Big Project', '2004-04-04', '2004-12-04'),  
    518   ##             ( 'Important Project', '2004-04-04', '2004-12-04')  
    519   ##           )  
    520   ##    FillTable('Project', Project, Columns, Data)  
    521   ##    #  
    522   ##    Columns = ('ProjectID', 'Name', 'StartDate', 'DurationHours',  
    523   ##            'CalculatedStartDate', 'CalculatedEndDate', 'CalculatedDurationHours' )  
    524   ##    Data = ( ( 2, 'First Task', '2003-12-31', 12, '2004-04-04', '2004-04-14', 10 ),  
    525   ##             ( 2, 'Second Task', None, None, '2004-04-14', '2004-04-19', 10 ),  
    526   ##             ( 2, 'Third Task', None, None, '2004-04-19', '2004-04-20', 10 ),  
    527   ##             ( 3, 'Only Task', '2004-04-04', None, '2004-04-04', '2004-04-14', 10 )  
    528   ##           )  
    529   ##    FillTable('Task', Task, Columns, Data)  
    530   ##    #  
    531   ##    Columns = ('PrerequisiteID', 'TaskID', 'Name')  
    532   ##    Data = ( ( 1, 2 ),  
    533   ##             ( 2, 3 )  
    534   ##           )  
    535   ##    FillTable('Dependency', Dependency, Columns, Data)  
    536   ##    #  
    537   ##    Columns = ('ReportTypeID', 'Name', 'FirstColumn', 'FirstRow', 'TableA', 'TableB', 'SelectColumn', 'SelectValue', 'ProjectID')  
    538   ##    # TableB must contain a column that is named TableA + "ID" that can be used to link the tables  
    539   ##    # SelectColumn must be in TableA  
    540   ##    Data = ( ( 2, 'Project/Report List', 1, 1, 'Project', 'Report', None, None, None ),  
    541   ##             ( 12, 'Report Column Options', 4, 0 ),  
    542   ##             ( 8, 'Resource List', 5, 3, 'Resource', None, None, None, None ),  
    543   ##             ( 3, 'Gantt Chart', 6, 4, 'Task', None, 'ProjectID', 2, 2 ),  
    544   ##           )  
    545   ##    FillTable('Report', Report, Columns, Data)  
    546   ##    #  
    547   ##    Columns = ('ColumnTypeID', 'ReportID', 'NextColumn', 'Width', 'Label', 'A', 'TypeA', 'B', 'TypeB', 'Time', 'Periods', 'FirstDate')  
    548   ##    Data = ( ( 2, 1, 2, 140,         'Name',                 'Name',         'CHAR',         'Name','CHAR',  '', 0, '' ),  
    549   ##             ( 3, 1, 3, 80,          'Start Date',           'StartDate',    'DATE',         '','',          '', 0, '' ),  
    550   ##             ( 4, 1, 0, 80,          'Target Date',          'TargetEndDate', 'DATE',        '','',          '', 0, '' ),  
    551   ##             ( 42, 2, 0, 140,        'Name',                 'Name',         'CHAR',         '','',          '', 0, '' ),  
    552   ##             ( 32, 3, 0, 140,        'Name',                 'Name',         'CHAR',         '','',          '', 0, '' ),  
    553   ##             ( 9, 4, 7, 140,         'Name',                 'Name',         'CHAR',         '','',          '', 0, '' ),  
    554   ##             ( 10, 4, 8, 80,         'Start Date',           'StartDate',    'DATE',         '','',          '', 0, '' ),  
    555   ##             ( 11, 4, 9, 80,         'Duration',             'DurationHours', 'INT',         '','',          '', 0, '' ),  
    556   ##             ( 14, 4, 0, None,       '',                     '',             'CHART',        '','',          'Day', 10, '2003-12-30' ),  
    557   ##           )  
    558   ##    FillTable('ReportColumn', ReportColumn, Columns, Data)  
    559   ##    #  
    560   ##    Columns = ('ReportID', 'TableName', 'TableID', 'NextRow')  
    561   ##    Data = ( ( 1,  'Project', 1,  2 ),  
    562   ##             ( 1,  'Report', 1, 7 ),  
    563   ##             ( 3,  'Resource', 1, 0 ),  
    564   ##             ( 4,  'Task', 1, 5 ),  
    565   ##             ( 4,  'Task', 2, 6 ),  
    566   ##             ( 4,  'Task', 3, 0 ),  
    567   ##             ( 1,  'Report', 2, 8 ),  
    568   ##             ( 1,  'Report', 3, 9 ),  
    569   ##             ( 1,  'Project', 2, 10 ),  
    570   ##             ( 1,  'Report', 4, 11 ),  
    571   ##             ( 1,  'Project', 3, 0 ),  
    572   ##           )  
    573   ##    FillTable('ReportRow', ReportRow, Columns, Data)  
    574   ##    #  
    575   ##    Columns = ('ShortName', 'Name')  
    576   ##    Data = ( ( 'Brian', 'Brian Christensen' ),  
    577   ##             ( 'Alex', 'Alexander Christensen' ),  
    578   ##            )  
    579   ##    FillTable('Resource', Resource, Columns, Data)  
    580   ##    #  
    581   ##    Columns = ('ResourceID', 'TaskID')  
    582   ##    Data = ( ( 1, 1 ),  
    583   ##           )  
    584   ##    FillTable('Assignment', Assignment, Columns, Data)  
    585   ##    #  
    586   ##    Columns = ('Date', 'Hours')  
    587   ##    Data = ( ( '2004-03-12', 0 ),  
    588   ##           )  
    589   ##    FillTable('Holiday', Holiday, Columns, Data)  
    590   ##  
    591   ##    SetTypes()  
    592   ##    SetOther()  
    593   ##    if debug: print "End SetSampleData"  
    594    
    595 185 # ---------  
    596 186  
     
    675 265         if ctid:  
    676 266             change['ID'] = ctid  # if column type already exists, change this to an update instead of an add  
    677               if change.has_key('Label'): del change['Label']  # don't change label on existing column type, is test necessary?  
      267             # if change.has_key('Label'): del change['Label']  # don't change label on existing column type, is test necessary?  
      268                 # was intended to preserve translations; no longer needed  
    678 269             if 'zzStatus' not in change:  
    679 270                 change['zzStatus'] = None  # default to active status  
     
    747 338     rt = ReportType.get(reporttypeid, {})  
    748 339     suggestion = rt.get("SuggestedColumns", "")  
    749       defaults = [rt.get('Name'), 'Name', None, None]  
      340     # if not suggestion:  
      341     #     also = rt.get("also")  
      342     #     also_rt = ReportType.get(reporttypeid, {})  
      343     #     also_name = also_rt.get("Name")  
      344     #     if also_name:  
      345     #         suggestion = "%s;" % also_name  
      346     defaults = [rt.get("Name"), 'Name', None, None]  
    750 347     columns = []  
    751 348     for column_string in suggestion.split(";"):  
     
    753 350         elements = [(v or defaults[k]) for k, v in enumerate(elements)]  
    754 351         elements += defaults[len(elements):]  
    755           rtname, ctname, width, periods = elements[:4]  
      352  
      353         rtname, ctname, width, periods = elements[:len(defaults)]  
      354             # number of values extracted must equal len(defaults)  
      355         if not (rtname and ctname):  
      356             continue  
    756 357  
    757 358         column = {'Table': 'ReportColumn', 'ColumnTypeID': (rtname, ctname)}  
     
    852 453 def RefreshReports():  
    853 454     pass  
    854   ##    if debug: print "Start RefreshReports"  
    855   ##    for k, v in OpenReports.items():  # deleted reports are closed during this loop  
    856   ##        if debug: print 'reportid', k  
    857   ##        if not v: continue  
    858   ##        if Report[k].get('zzStatus') == 'deleted':  
    859   ##            CloseReport(k)  
    860   ##        if k != 1: v.SetReportTitle()  # only grid reports  
    861   ##        Menu.AdjustMenus(v)  
    862   ##        v.Refresh()  
    863   ##        v.Report.Refresh()  # update displayed data (needed for Main on Windows, not needed on Mac)  
    864   ##    if debug: print "End RefreshReports"  
    865 455  
    866 456 # ----- undo and redo  
     
    959 549                 if newval or newval == 0:  
    960 550                     record[c] = newval  
    961                   else:  
      551                 elif c in record:  
    961 551                     del record[c]  
    962 552         if len(undo) > 2:  
     
    1021 611     else:  
    1022 612         HoursPerDay = HoursPerWeek.__truediv__(DaysPerWeek)  
    1023           AllowDaysUnit = (DaysPerWeek == WorkWeek.count(HoursPerDay))  
      613         AllowDaysUnit = True  
      614         # AllowDaysUnit = (DaysPerWeek == WorkWeek.count(HoursPerDay))  
    1024 615  
    1025 616     if debug: print 'end UpdateWorkWeek'  
     
    1913 1504     tid = rr['TableID']  
    1914 1505  
    1915       ctid = ReportColumn[colid].get('ColumnTypeID')  
      1506     rc = ReportColumn[colid]  
      1507     ctid = rc.get('ColumnTypeID')  
    1916 1508     ct = ColumnType[ctid]  
    1917 1509  
      1510     # is all protection set by the column type?  
      1511     if not ct.get('Edit'):  # don't apply changes to protected cells  
      1512         return 0  
      1513  
    1918 1514     type = ct.get('DataType', 't')  
    1919 1515  
     
    2011 1607     change[column] = v  
    2012 1608     Update(change)  
    2013       return column  
      1609     label = rc.get('Label') or ct.get('Label') or ct.get('Name')  
      1610     label = label.replace('\n', ' ')  
      1611     return label  # for undo message  
    2014 1612     # SetUndo(column)  
    2015 1613  
     
    2019 1617     pass  
    2020 1618  
    2021   ##    # self is either a list or a table behind a grid  
    2022   ##    # create local pointers to database  
    2023   ##    self.data = Database  
    2024   ##    # pointers to one record  
    2025   ##    self.report = self.data["Report"][reportid]  
    2026   ##    reporttypeid = self.report['ReportTypeID']  
    2027   ##    #if debug: print 'reporttypeid', reporttypeid  
    2028   ##    self.reporttype = self.data["ReportType"][reporttypeid]  
    2029   ##    # pointers to tables  
    2030   ##    self.reportcolumn = self.data["ReportColumn"]  
    2031   ##    self.columntype = self.data["ColumnType"]  
    2032   ##    self.reportrow = self.data["ReportRow"]  
    2033 1619  
    2034 1620 ########## @@@@@@@@@@ Start Alex Row/Column Order @@@@@@@@@@ ##########  
    2035 1621  
    2036   # this is overriden by ReportAids.py  
    2037   def UpdateRowPointers(self):  
    2038       pass  
    2039    
    2040   ##    # self is either a list or a table behind a grid  
    2041   ##  
    2042   ##    reportid = self.report.get('ID')  
    2043   ##    rows, rowlevels = GetRowLevels(reportid)  
    2044   ##  
    2045   ##    if self.report.get('ShowHidden'):  
    2046   ##        self.rows = rows  
    2047   ##        self.rowlevels = rowlevels  
    2048   ##        return  
    2049   ##  
    2050   ##    self.rows = []  
    2051   ##    self.rowlevels = []  
    2052   ##    level = 0  # maximum level of next row  
    2053   ##  
    2054   ##    for rowid, lev in zip(rows, rowlevels):  
    2055   ##        if lev > level:  
    2056   ##            # parent is not shown  
    2057   ##            continue  
    2058   ##        level = lev  
    2059   ##  
    2060   ##        r = ReportRow.get(rowid) or {}  
    2061   ##        hidden = r.get('Hidden')  
    2062   ##        try:  
    2063   ##            t = r['TableName']  
    2064   ##            id = r['TableID']  
    2065   ##            deleted = (Database[t][id].get('zzStatus') == 'deleted')  
    2066   ##        except KeyError:  
    2067   ##            deleted = True  
    2068   ##  
    2069   ##        if not (hidden or deleted):  
    2070   ##            self.rows.append(rowid)  
    2071   ##            self.rowlevels.append(lev)  
    2072   ##            level += 1  
    2073    
    2074 1622 def GetColumnList(reportid):  
    2075 1623     """ Return list of column id's in the current order """  
     
    2154 1702     return ids  
    2155 1703