# coding: utf-8 ''' ''' import json from ru.curs.celesta.showcase.utils import XMLJSONConverter from common.htmlhints.htmlHint import htmlHintElement from edu._edu_orm import educational_groupCursor, vw_edu_group_personsCursor # from common.htmlhints.htmlHint import htmlHintElement # from gridsettings.functions.gridSettings import toolbar_button_panel def datapanel(context, main=None, session=None): data = {'datapanel': {'tab': []}} tab1 = {'@id': 1, '@name': u'Группы тестирования', 'element': []} testGroupsGrid = { '@id': 'testGroupsGrid', '@type': 'grid', '@subtype': 'JS_TREE_GRID', '@plugin': 'treeDGrid', '@proc': 'edu.grid.educationalGroupsGrid.getTreeData.celesta', '@hideOnLoad': 'false', 'proc': [ {'@id': 'proc1', '@name': 'edu.grid.educationalGroupsGrid.getTreeSettings.celesta', '@type': 'METADATA'}, # {'@id': 'partialUpdate', # '@name': "edu.grid.educationalGroupsGrid.gridPartialUpdate.celesta", # '@type': 'PARTIALUPDATE'}, {'@id': 'proc2', '@name': 'edu.grid.educationalGroupsGrid.gridToolBar.celesta', '@type': 'TOOLBAR'}, {'@id': 'downloadStudentFile', '@name': 'edu.grid.educationalGroupsGrid.downloadStudentFile.celesta', '@type': 'DOWNLOAD'}, {'@id': 'downloadStudentAppealFile', '@name': 'edu.grid.educationalGroupsGrid.downloadStudentAppealFile.celesta', '@type': 'DOWNLOAD'} ]} importTestGroupsCard = {"@id": "importTestGroupsCard", "@type": "xforms", "@template": "importTestGroups.xml", "@proc": "edu.xform.importTestGroupsCard.cardData.cl", "@neverShowInPanel": "true", "proc": [ {"@id": 'uploadFile', "@name": "edu.xform.importTestGroupsCard.attachmentUpload.cl", "@type": "UPLOAD"}, {"@id": "0004", "@name": "edu.xform.importTestGroupsCard.cardDataSave.cl", "@type": "SAVE"}], "related": {"@id": 'testGroupsGrid'}} startTestCard = {"@id": "startTestCard", "@type": "xforms", "@template": "edu/startTestCard.xml", "@proc": "edu.xform.startTestCard.cardData.cl", "@neverShowInPanel": "true", "proc": [ {"@id": "startTestCardSave", "@name": "edu.xform.startTestCard.cardDataSave.cl", "@type": "SAVE"}], "related": {"@id": 'testGroupsGrid'}} endTestCard = {"@id": "endTestCard", "@type": "xforms", "@template": "delElementStandardCard.xml", "@proc": "edu.xform.endTestCard.cardData.cl", "@neverShowInPanel": "true", "proc": [ {"@id": "endTestCardSave", "@name": "edu.xform.endTestCard.cardDataSave.cl", "@type": "SAVE"}], "related": {"@id": 'testGroupsGrid'}} addTestGroupCard = {"@id": "addTestGroupCard", "@type": "xforms", "@template": "edu/addTestGroupCard.xml", "@proc": "edu.xform.addTestGroupCard.cardData.cl", "@neverShowInPanel": "true", "proc": [ {"@id": "addTestGroupCardSave", "@name": "edu.xform.addTestGroupCard.cardDataSave.cl", "@type": "SAVE"}], "related": {"@id": 'testGroupsGrid'}} addTestGroupPersonsCard = {"@id": "addTestGroupPersonsCard", "@type": "xforms", "@template": "edu/addTestGroupPersonsCard.xml", "@proc": "edu.xform.addTestGroupPersonsCard.cardData.cl", "@neverShowInPanel": "true", "proc": [ {"@id": "addTestGroupPersonsCardSave", "@name": "edu.xform.addTestGroupPersonsCard.cardDataSave.cl", "@type": "SAVE"}], "related": {"@id": 'testGroupsGrid'}} tab1['element'].append(htmlHintElement('testGruopsDescription')) tab1['element'].append(testGroupsGrid) tab1['element'].append(importTestGroupsCard) tab1['element'].append(startTestCard) tab1['element'].append(endTestCard) tab1['element'].append(addTestGroupCard) tab1['element'].append(addTestGroupPersonsCard) data['datapanel']['tab'].extend([tab1]) return XMLJSONConverter.jsonToXml(json.dumps(data)) def datapanelTesting(context, main=None, session=None): data = {'datapanel': {'tab': []}} group_name = u'Группа тестирования' educational_groupCur = educational_groupCursor(context) if educational_groupCur.tryGet(main): group_name = educational_groupCur.group_name educational_groupCur.close() tab1 = {'@id': 1, '@name': group_name, '@layout': "TABLE", '@style': "border-collapse: collapse; border-spacing: 0;", '@styleClass': "testInfo", 'tr': []} test_webtext = {'@id': "r01", '@styleClass': "testInfoRow", 'td' : { '@id': "d0101", '@styleClass': "testInfoRowCell", 'element':{ "@id": "testInfoCard", "@type": "xforms", "@template": "edu/testInfoCard.xml", "@proc": "edu.xform.testInfoCard.cardData.cl", "proc": [ {"@id": "testInfoCardSave", "@name": "edu.xform.testInfoCard.cardDataSave.cl", "@type": "SAVE"}]}}} tab1['tr'].append(test_webtext) edu_group_personsCur = vw_edu_group_personsCursor(context) edu_group_personsCur.setRange('group_id', main) edu_group_personsCur.orderBy('surname', 'name', 'patronymic') i = 2 for person in edu_group_personsCur.iterate(): person_webtext = {'@id': "r0{}".format(i), '@styleClass': "personInfoRow", 'td' : { '@id': "d0{}01".format(i), '@styleClass': "personInfoCell", 'element': { '@id': person.person_id, '@proc': 'edu.webtext.studentText.webtext.celesta', '@refreshByTimer': 'true', '@refreshInterval': '15', '@transform': 'studentText.xsl', '@type': 'webtext'}}} i += 1 tab1['tr'].append(person_webtext) edu_group_personsCur.close() data['datapanel']['tab'].append(tab1) return XMLJSONConverter.jsonToXml(json.dumps(data))