def prepare_program(program, data): """ This function adds custom stuff to save_instance to facilitate making programs happen. """ # Permissions format: perms = [] modules = [] perms += [('Student/All', None, data['student_reg_start'], data['student_reg_end'])] #it is recursive perms += [('Student/Catalog', None, data['student_reg_start'], None)] perms += [('Student/Profile', None, data['student_reg_start'], None)] perms += [('Teacher/All', None, data['teacher_reg_start'], data['teacher_reg_end'])] perms += [('Teacher/Classes/View', None, data['teacher_reg_start'], None)] perms += [('Teacher/MainPage', None, data['teacher_reg_start'], None)] perms += [('Teacher/Profile', None, data['teacher_reg_start'], None)] # Grant onsite bit (for all times) if an onsite user is available. if ESPUser.onsite_user(): perms += [('Onsite', ESPUser.onsite_user(), None, None)] modules += [(str(ProgramModule.objects.get(id=i)), i) for i in data['program_modules']] return perms, modules
def prepare_program(program, data): """ This function adds custom stuff to save_instance to facilitate making programs happen. """ # Datatrees format: each item is a tuple of (node URI, friendly name) datatrees = [] # Userbits format: each item is a tuple of (QSC URI, user ID, startdate, enddate) userbits = [] modules = [] # Fetch/create the program node program_node_name = program.anchor.get_uri() + '/' + data['term'] # Create the DataTree branches for sub_node in ProgramTemplate: datatrees += [(program_node_name + sub_node, '')] userbits += [('V/Flags/Public', None, data['publish_start'], data['publish_end'])] userbits += [('V/Deadline/Registration/Student', None, data['student_reg_start'], data['student_reg_end'])] #userbits += [('V/Deadline/Registration/Student/Applications', None, data['student_reg_start'], data['student_reg_end'])] userbits += [('V/Deadline/Registration/Student/Catalog', None, data['student_reg_start'], None)] #userbits += [('V/Deadline/Registration/Student/Classes', None, data['student_reg_start'], data['student_reg_end'])] #userbits += [('V/Deadline/Registration/Student/Classes/OneClass', None, data['student_reg_start'], data['student_reg_end'])] #userbits += [('V/Deadline/Registration/Student/Confirm', None, data['student_reg_start'], data['publish_end'])] #userbits += [('V/Deadline/Registration/Student/ExtraCosts', None, data['student_reg_start'], data['student_reg_end'])] #userbits += [('V/Deadline/Registration/Student/MainPage', None, data['student_reg_start'], data['publish_end'])] #userbits += [('V/Deadline/Registration/Student/Payment', None, data['student_reg_start'], data['publish_end'])] userbits += [('V/Deadline/Registration/Teacher', None, data['teacher_reg_start'], data['teacher_reg_end'])] #userbits += [('V/Deadline/Registration/Teacher/Catalog', None, data['teacher_reg_start'], None)] #userbits += [('V/Deadline/Registration/Teacher/Classes', None, data['teacher_reg_start'], data['teacher_reg_end'])] userbits += [('V/Deadline/Registration/Teacher/Classes/View', None, data['teacher_reg_start'], None)] userbits += [('V/Deadline/Registration/Teacher/MainPage', None, data['teacher_reg_start'], None)] userbits += [('V/Deadline/Registration/Teacher/Profile', None, data['teacher_reg_start'], None)] # Grant onsite bit (for all times) if an onsite user is available. if ESPUser.onsite_user(): userbits += [('V/Registration/OnSite', ESPUser.onsite_user(), None, None)] for director in data['admins']: userbits += [('V/Administer', ESPUser.objects.get(id=int(director)), None, None)] json_module = ProgramModule.objects.get(handler=u'JSONDataModule') # get the JSON Data Module # If the JSON Data Module isn't already in the list of selected # program modules, add it. The JSON Data Module is a dependency for # many commonly-used modules, so it is important that it be enbabled # by default for all new programs. if json_module.id not in data['program_modules']: data['program_modules'].append(json_module.id) modules += [(str(ProgramModule.objects.get(id=i)), i) for i in data['program_modules']] return datatrees, userbits, modules
def prepare_program(program, data): """ This function adds custom stuff to save_instance to facilitate making programs happen. """ # Datatrees format: each item is a tuple of (node URI, friendly name) datatrees = [] # Userbits format: each item is a tuple of (QSC URI, user ID, startdate, enddate) userbits = [] modules = [] # Fetch/create the program node program_node_name = program.anchor.get_uri() + '/' + data['term'] # Create the DataTree branches for sub_node in ProgramTemplate: datatrees += [(program_node_name + sub_node, '')] userbits += [('V/Flags/Public', None, data['publish_start'], data['publish_end'])] userbits += [('V/Deadline/Registration/Student', None, data['student_reg_start'], data['student_reg_end'])] #userbits += [('V/Deadline/Registration/Student/Applications', None, data['student_reg_start'], data['student_reg_end'])] userbits += [('V/Deadline/Registration/Student/Catalog', None, data['student_reg_start'], None)] #userbits += [('V/Deadline/Registration/Student/Classes', None, data['student_reg_start'], data['student_reg_end'])] #userbits += [('V/Deadline/Registration/Student/Classes/OneClass', None, data['student_reg_start'], data['student_reg_end'])] #userbits += [('V/Deadline/Registration/Student/Confirm', None, data['student_reg_start'], data['publish_end'])] #userbits += [('V/Deadline/Registration/Student/ExtraCosts', None, data['student_reg_start'], data['student_reg_end'])] #userbits += [('V/Deadline/Registration/Student/MainPage', None, data['student_reg_start'], data['publish_end'])] #userbits += [('V/Deadline/Registration/Student/Payment', None, data['student_reg_start'], data['publish_end'])] userbits += [('V/Deadline/Registration/Teacher', None, data['teacher_reg_start'], data['teacher_reg_end'])] #userbits += [('V/Deadline/Registration/Teacher/Catalog', None, data['teacher_reg_start'], None)] #userbits += [('V/Deadline/Registration/Teacher/Classes', None, data['teacher_reg_start'], data['teacher_reg_end'])] userbits += [('V/Deadline/Registration/Teacher/Classes/View', None, data['teacher_reg_start'], None)] userbits += [('V/Deadline/Registration/Teacher/MainPage', None, data['teacher_reg_start'], None)] userbits += [('V/Deadline/Registration/Teacher/Profile', None, data['teacher_reg_start'], None)] # Grant onsite bit (for all times) if an onsite user is available. if ESPUser.onsite_user(): userbits += [('V/Registration/Onsite', ESPUser.onsite_user(), None, None)] for director in data['admins']: userbits += [('V/Administer', ESPUser.objects.get(id=int(director)), None, None)] modules += [(str(ProgramModule.objects.get(id=i)), i) for i in data['program_modules']] return datatrees, userbits, modules
def prepare_program(program, data): """ This function adds custom stuff to save_instance to facilitate making programs happen. """ # Permissions format: perms = [] modules = [] perms += [('Student/All', None, data['student_reg_start'], data['student_reg_end'])] #it is recursive perms += [('Student/Catalog', None, data['student_reg_start'], None)] perms += [('Student/Profile', None, data['student_reg_start'], None)] perms += [('Teacher/All', None, data['teacher_reg_start'], data['teacher_reg_end'])] perms += [('Teacher/Classes/View', None, data['teacher_reg_start'], None)] perms += [('Teacher/MainPage', None, data['teacher_reg_start'], None)] perms += [('Teacher/Profile', None, data['teacher_reg_start'], None)] # Grant onsite bit (for all times) if an onsite user is available. if ESPUser.onsite_user(): perms += [('Onsite', ESPUser.onsite_user(), None, None)] for director in data['admins']: perms += [('Administer', ESPUser.objects.get(id=int(director)), None, None)] json_module = ProgramModule.objects.get( handler=u'JSONDataModule') # get the JSON Data Module # If the JSON Data Module isn't already in the list of selected # program modules, add it. The JSON Data Module is a dependency for # many commonly-used modules, so it is important that it be enbabled # by default for all new programs. if json_module.id not in data['program_modules']: data['program_modules'].append(json_module.id) modules += [(str(ProgramModule.objects.get(id=i)), i) for i in data['program_modules']] return perms, modules