示例#1
0
class ISchool(model.Schema):
    """ Marker interface and Dexterity Python Schema for School
    """

    seed = schema.Bool(title=_(u'Seed School'), default=False, required=False)

    zip = schema.TextLine(
        title=_(u'ZIP Code'),
        required=False,
    )

    fieldset(_('School Cotact'),
             fields=['name', 'telephone', 'phone', 'email'])
    name = schema.TextLine(title=_(u'Contact Name'), required=False)

    telephone = schema.TextLine(title=_(u'Telephone'), required=False)

    phone = schema.TextLine(title=_(u'Phone'), required=False)

    email = schema.TextLine(title=_(u'Email'), required=False)

    fieldset(_(u'School ID PW'), fields=['school_id', 'school_pw'])
    school_id = schema.TextLine(
        title=_(u'School Login Id'),
        required=False,
    )

    school_pw = schema.TextLine(
        title=_(u'School Password'),
        required=False,
    )
示例#2
0
class ICourse(model.Schema):
    """
    title = schema.TextLine(
        title=_(u'Title'),
        required=True,
    )"""

    local_language = schema.TextLine(
        title=_(u'Local Language'),
        required=False,
    )

    teacher = RelationChoice(
        title=_(u'Teacher'),
        source=CatalogSource(portal_type='Teacher'),
        required=False,
    )

    school = RelationList(
        title=_(u'Alliance Schools'),
        value_type=RelationChoice(
            title=u"School",
            source=CatalogSource(portal_type=['School', 'Folder'])),
        required=False,
    )

    hire_school = RelationChoice(
        title=_(u'Hire School'),
        source=CatalogSource(portal_type=['School', 'Folder']),
        required=False,
    )

    studentList = schema.Text(
        title=_(u'Student List'),
        description=_(u'format: city,school_name,student_name'),
        required=False,
    )

    place = schema.TextLine(
        title=_(u'Place of Study'),
        required=False,
    )

    course_date = schema.TextLine(
        title=_(u'Course Date'),
        required=False,
    )

    course_time = schema.TextLine(
        title=_(u'Course Time'),
        required=False,
    )

    course_outline = RichText(
        title=_(u'Course Outline'),
        required=False,
    )
示例#3
0
 def getTeacherField(self, item):
     fields = ['localLang'     , 'certification', 'study'     , 'qualified_teacher', \
               'ethnic_teacher', 'education'    , 'experience', 'teaching_years'   , 'remarks']
     fieldsName = {
         'localLang': _(u'Local Language'),
         'certification': _(u'Ethnic language certification'),
         'study': _(u'Revitalization study'),
         'qualified_teacher': _(u'Teaching class (Qualified teacher)'),
         'ethnic_teacher': _(u'Teaching class (Ethnic teacher)'),
         'education': _(u'Education'),
         'experience': _(u'work experience'),
         'teaching_years': _(u'Teaching years'),
         'remarks': _(u'Remarks')
     }
     fieldsDict = OrderedDict()
     for field in fields:
         field_value = getattr(item, field, '')
         if field_value:
             fieldsDict.update({fieldsName[field]: field_value})
     if fieldsDict.has_key(fieldsName['localLang']):
         localLangValue = '\r\n'.join([
             lang.split(',')[1]
             for lang in fieldsDict[fieldsName['localLang']].split('/')
         ])
         fieldsDict[fieldsName['localLang']] = localLangValue
     return fieldsDict
示例#4
0
 def updateEmail(self):
     email = self.request.get('email', '')
     if email:
         alsoProvides(self.request, IDisableCSRFProtection)
         self.school.email = email
         self.context.plone_utils.addPortalMessage(
             _(u'Email already update'), 'info')
示例#5
0
    def __call__(self):
        request = self.request
        hashSHA256 = request.form.get('id', '')
        school = api.content.find(hashSHA256=hashSHA256)

        if len(school) == 1:
            self.school = school[0]

        if request.form.get('widget-form-btn', '') == 'widget-form-btn':
            portal_catalog = getToolByName(self.context, 'portal_catalog')
            index_id = portal_catalog.Indexes['school_id']

            school_id = request.form.get('school_id', '')
            school_pw = request.form.get('school_pw', '')
            if request.form.get('widget-registered-btn',
                                '') == 'widget-registered-btn':
                if school_id == self.school.school_id or school_id not in index_id.uniqueValues(
                ):
                    self.initSchool(school_id, school_pw, hashSHA256)
                else:
                    self.context.plone_utils.addPortalMessage(
                        _(u'This School ID is already be used'), 'error')
            else:
                self.checkLogin(school_id, school_pw)

        if len(school) != 1:
            return self.template_login()
        return self.template()
示例#6
0
    def __call__(self):
        request = self.request
        hashSHA256 = request.form.get('id', '')
        teacher = api.content.find(hashSHA256=hashSHA256)

        if len(teacher) == 1:
            self.teacher = teacher[0]

        if request.form.get('widget-form-btn', '') == 'widget-form-btn':
            portal_catalog = getToolByName(self.context, 'portal_catalog')
            index_id = portal_catalog.Indexes['teacher_id']
            teacher_id = request.form.get('teacher_id', '')
            teacher_pw = request.form.get('teacher_pw', '')
            if request.form.get('widget-registered-btn',
                                '') == 'widget-registered-btn':
                if teacher_id == self.teacher.teacher_id or teacher_id not in index_id.uniqueValues(
                ):
                    self.initTeacher(teacher_id, teacher_pw, hashSHA256)
                else:
                    self.context.plone_utils.addPortalMessage(
                        _(u'This Teacher ID is already be used'), 'error')
            else:
                self.checkLogin(teacher_id, teacher_pw)

        if len(teacher) != 1:
            return self.template_login()
        return self.template()
示例#7
0
class IOptional(model.Schema):
    """
    """

    localLang = schema.TextLine(
        title=_(u'Local Language'),
        description=
        _(u'Format example: D20,Language Name,1,1,1/A01,Language Name,0,1,3/..., 0,0,0 or 0,1,3 mapping to primary-intermediate-advanced'
          ),
        required=False,
    )

    classTime = schema.List(title=_(u'Class Time'),
                            value_type=schema.Choice(
                                title=_(u"Class Time"),
                                vocabulary='apc.content.ClassTime',
                                required=False,
                            ),
                            required=False)
示例#8
0
    def test_vocab_language(self):
        vocab_name = 'apc.content.Language'
        factory = getUtility(IVocabularyFactory, vocab_name)
        self.assertTrue(IVocabularyFactory.providedBy(factory))

        vocabulary = factory(self.portal)
        self.assertTrue(IVocabularyTokenized.providedBy(vocabulary))
        self.assertEqual(
            vocabulary.getTerm('sony-a7r-iii').title,
            _(u'Sony Aplha 7R III'),
        )
示例#9
0
class ILiveClass(model.Schema):
    """ Marker interface and Dexterity Python Schema for LiveClass
    """

    localLang = schema.TextLine(
        title=_(u'Local Language'),
        required=False,
    )

    teachSchool = RelationChoice(title=_(u"Teach School"),
                                 required=False,
                                 source=CatalogSource(Type='School'))

    coSchool = RelationList(
        title=_(u"Training Center"),
        default=[],
        value_type=RelationChoice(title=_(u"Related"),
                                  source=CatalogSource(Type='School')),
        required=False,
    )

    teacher = RelationChoice(title=_(u"Teacher"),
                             required=False,
                             source=CatalogSource(Type='Teacher'))

    embeded = schema.Text(
        title=_(u'Embeded Code'),
        required=False,
    )
示例#10
0
    def sendTeacherInitMail(self, teacher):
        teacher_title = teacher.Title
        hashSHA256 = teacher.hashSHA256
        link = self.context.portal_url(
        ) + '/teacher-area/teacher-login/@@teacher_init?id=' + hashSHA256

        current_time = datetime.datetime.now().date()
        effective_date = current_time + datetime.timedelta(days=3)

        body_str = """ 您好 %s 老師: \
                  <br>  \
                  <br> 點擊以下連結可以設定您的帳號密碼↓ \
                  <br> 此連結有效時間為 %s 請在時間內設定完成\
                  <br> <a href="%s">%s</a> \
                  <br>  \
                  <br> 原住民族委員會 \
                   """ % (teacher_title, effective_date, link, link)
        mime_text = MIMEText(body_str, 'html', 'utf-8')
        teacher_email = teacher.getObject().email
        if teacher_email:
            api.portal.send_email(
                recipient=teacher_email,
                sender="*****@*****.**",
                subject="備課教材",
                body=mime_text.as_string(),
            )
            alsoProvides(self.request, IDisableCSRFProtection)
            teacher.getObject().link_date = effective_date

            self.context.plone_utils.addPortalMessage(
                _(u'It is success mail to ') + teacher.Title.decode('utf8'),
                'info')
        else:
            self.context.plone_utils.addPortalMessage(
                _(u'This teacher has not email: ') +
                teacher.Title.decode('utf8'), 'info')
示例#11
0
    def __call__(self):
        request = self.request
        teacher_uid = self.request.cookies.get("teacher_login", "")
        teacher = api.content.find(UID=teacher_uid,
                                   sort_on='getObjPositionInParent')
        if len(teacher) != 1:
            return self.request.response.redirect(
                '{}/teacher-area/teacher-login'.format(
                    self.context.portal_url()))
        self.teacher = teacher[0]

        if request.form.get('widget-form-btn', '') == 'widget-form-btn':
            teacherFields = [
                'certification', 'study', 'qualified_teacher',
                'ethnic_teacher', 'education', 'experience', 'teaching_years',
                'remarks', 'email'
            ]
            data = {}
            url = self.teacher.getURL()
            headers = {
                'Accept': "application/json",
                'Content-Type': "application/json",
                'Authorization': "Basic YWRtaW46MTIzNDU2",
            }
            for field in teacherFields:
                value = request.form.get(field, '')
                if value:
                    data.update({field: value})
            image = request.form.get('image', '')
            if image:
                data.update({
                    "image": {
                        "content-type": image.headers['content-type'],
                        "filename": image.filename,
                        "encoding": "base64",
                        "data": image.read().encode('base64')
                    }
                })

            response = requests.request("PATCH",
                                        url,
                                        headers=headers,
                                        json=data)
            self.context.plone_utils.addPortalMessage(
                _(u'The Teacher info is success update'), 'info')
        return self.template()
示例#12
0
    def checkLogin(self, school_id, school_pw):
        school = api.content.find(portal_type='School',
                                  school_id=school_id,
                                  sort_on='getObjPositionInParent')
        if len(school) == 1:
            if school[0].getObject().school_pw == school_pw:

                cookie_path = api.portal.get().absolute_url_path()
                self.request.response.setCookie("school_login",
                                                school[0].UID,
                                                path=cookie_path)

                return self.request.response.redirect(
                    '{}/school-area/school-area'.format(
                        self.context.portal_url()))

        self.context.plone_utils.addPortalMessage(
            _(u'Your Username or Password is not vaild'), 'error')
示例#13
0
    def checkLogin(self, teacher_id, teacher_pw):
        teacher = api.content.find(portal_type='Teacher',
                                   teacher_id=teacher_id,
                                   sort_on='getObjPositionInParent')
        if len(teacher) == 1:
            if teacher[0].getObject().teacher_pw == teacher_pw:

                cookie_path = api.portal.get().absolute_url_path()
                self.request.response.setCookie("teacher_login",
                                                teacher[0].UID,
                                                path=cookie_path)

                return self.request.response.redirect(
                    '{}/teacher-area/teacher-area'.format(
                        self.context.portal_url()))

        self.context.plone_utils.addPortalMessage(
            _(u'Your Username or Password is not vaild'), 'error')
示例#14
0
 def updateNamelist(self):
     school_title = self.school.title
     school_city = self.school.getParentNode().title
     nameHeader = '{},{},'.format(school_city.encode('utf8'),
                                  school_title.encode('utf8'))
     nameList = self.request.get('nameList', '')
     otherList = self.request.get('otherList', '')
     uid = self.request.get('uid', '')
     course = api.content.get(UID=uid)
     studentList = otherList.split('\r\n')
     if course and nameList:
         alsoProvides(self.request, IDisableCSRFProtection)
         for name in nameList.split('\r\n'):
             if name:
                 studentList.append(nameHeader + name)
         course.studentList = '\r\n'.join(studentList)
         self.context.plone_utils.addPortalMessage(
             course.title + _(u' student list already update'), 'info')
示例#15
0
class IStudent(model.Schema):

    studentId = schema.TextLine(title=_(u"Student Id"), required=False)

    birthday = schema.Date(title=_(u"Birthday"), required=False)

    address = schema.TextLine(title=_(u"Address"), required=False)

    course = RelationChoice(
        title=_(u'Learning Course'),
        source=CatalogSource(po2rtal_type=['Course', 'Folder']),
        required=False,
    )

    fieldset(_(u'Student ID PW'), fields=['student_id', 'student_pw'])
    student_id = schema.TextLine(
        title=_(u'Student Username'),
        required=False,
    )

    student_pw = schema.TextLine(
        title=_(u'Student Password'),
        required=False,
    )
示例#16
0
class IPrepare(model.Schema):

    title = schema.TextLine(
        title=_(u'Title'),
        required=True,
    )

    description = schema.Text(
        title=_(u'Agenda'),
        required=False,
    )

#    file = namedfile.NamedFile(
    file = namedfile.NamedBlobFile(
        title=_(u'Teaching material'),
        required=False,
    )

    """ 
    video = RichText(
        title=_(u'Course Video'),
        required=False,
    ) """

    embeded = schema.Text(
        title=_(u'Embeded Code'),
        required=False,
    )

    onCall = schema.Text(
        title=_(u'Roll Call, On Call'),
        required=False,
    )

    notOnCall = schema.Text(
        title=_(u'Roll Call, Not On Call'),
        required=False,
    )
示例#17
0
class ICourse(model.Schema):
    """
    id = schema.TextLine(
        title=_(u'CoStudy Course Id'),
        required=True,
    )
    """

    title = schema.TextLine(
        title=_(u'CoStudy Course Id'),
        required=True,
    )

    form.mode(description='hidden')
    description = schema.Text(
        title=_(u'CoStudy Course Description'),
        required=False,
    )

    timeSection = schema.TextLine(
        title=_(u'Class Time Section'),
        required=False,
    )

    vMeetingRoom = schema.TextLine(
        title=_(u'Virtual Meeting Room'),
        required=False,
    )

    local_language = schema.TextLine(
        title=_(u'Local Language'),
        required=False,
    )

    teacher = RelationChoice(
        title=_(u'Teacher'),
        source=CatalogSource(portal_type='Teacher'),
        required=False,
    )

    school = RelationList(
        title=_(u'Alliance Schools'),
        value_type=RelationChoice(
            title=u"School",
            source=CatalogSource(portal_type=['School', 'Folder'])),
        required=False,
    )

    hire_school = RelationChoice(
        title=_(u'Hire School'),
        source=CatalogSource(portal_type=['School', 'Folder']),
        required=False,
    )

    studentList = schema.Text(
        title=_(u'Student List'),
        description=_(u'format: city,school_name,student_name'),
        required=False,
    )

    #    form.mode(place='hidden')
    place = schema.TextLine(
        title=_(u'Place of Study'),
        required=False,
    )

    form.mode(course_date='hidden')
    course_date = schema.TextLine(
        title=_(u'Course Date'),
        required=False,
    )

    form.mode(course_time='hidden')
    course_time = schema.TextLine(
        title=_(u'Course Time'),
        required=False,
    )

    course_outline = RichText(
        title=_(u'Course Outline'),
        required=False,
    )

    fieldset(_(u'coReading'),
             fields=[
                 'coReadingName', 'coReadingId', 'coReadingBank',
                 'coReadingAccount'
             ])
    coReadingName = schema.TextLine(
        title=_(u'Co Reading Name'),
        required=False,
    )

    coReadingId = schema.TextLine(
        title=_(u'Co Reading Id'),
        required=False,
    )

    coReadingBank = schema.TextLine(
        title=_(u'Co Reading Bank'),
        description=_(u'Bank Name and Branch Name'),
        required=False,
    )

    coReadingAccount = schema.TextLine(
        title=_(u'Co Reading Bank Account'),
        required=False,
    )
示例#18
0
class IPrepare(model.Schema):

    title = schema.TextLine(
        title=_(u'Title'),
        required=True,
    )

    topic = schema.TextLine(
        title=_(u'Prepare Theme'),
        required=False,
    )

    description = schema.Text(
        title=_(u'Prepare Description'),
        required=False,
    )

    file = namedfile.NamedBlobFile(
        title=_(u'Teaching material'),
        required=False,
    )

    file2 = namedfile.NamedBlobFile(
        title=_(u'Teaching material'),
        required=False,
    )

    file3 = namedfile.NamedBlobFile(
        title=_(u'Teaching material'),
        required=False,
    )

    vacation = schema.Bool(title=_(u'vacation'), default=False, required=True)
    """ 
    video = RichText(
        title=_(u'Course Video'),
        required=False,
    ) """

    cover_url = schema.TextLine(
        title=_(u'cover url'),
        required=False,
    )

    download_url = schema.TextLine(
        title=_(u'Download URL'),
        required=False,
    )

    youtube_embeded = schema.Text(
        title=_(u'Youtube Embeded Code'),
        required=False,
    )

    embeded = schema.Text(
        title=_(u'Embeded Code'),
        required=False,
    )

    onCall = schema.Text(
        title=_(u'Roll Call, On Call'),
        required=False,
    )

    notOnCall = schema.Text(
        title=_(u'Roll Call, Not On Call'),
        required=False,
    )

    fieldset(_(u'Leave a Lesson'), fields=['leave', 'makeUp', 'makeUpDay'])
    leave = schema.Text(
        title=_(u'Leave a Lesson'),
        required=False,
    )

    makeUp = schema.Bool(
        title=_(u'Make up a missed lesson'),
        required=False,
    )

    makeUpDay = schema.TextLine(
        title=_(u'Make Up Day'),
        required=False,
    )

    fieldset(_(u'Place of Study'), fields=['place'])
    place = schema.TextLine(
        title=_(u'Place of Study'),
        required=False,
    )
示例#19
0
class ITeacher(model.Schema):

    gender = SimpleVocabulary(
               [SimpleTerm(value=u'man', title=_(u'man')),
                SimpleTerm(value=u'woman', title=_(u'woman'))]
             )

    fieldset(_('Teacher Info'), fields=['image', 'gender', 'nameSpell', 'aboriginalsLang', 'certification', 'study', 'qualified_teacher', 'ethnic_teacher', 'education', 'experience', 'teaching_years', 'remarks'])

    image = namedfile.NamedBlobImage(
        title=_(u'Teacher Image'),
        required=False,
    )

    gender = schema.Choice(
        title=_(u'Gender'),
        vocabulary=gender,
        default='man',
        required=True,
    )

    nameSpell = schema.TextLine(
        title=_(u'Name Spell'),
        required=False,
    )

    aboriginalsLang = schema.TextLine(
        title=_(u'Aboriginals Language'),
        required=False,
    )

    certification = schema.TextLine(
        title=_(u"Ethnic language certification"),
        required=False
    )

    study = schema.TextLine(
        title=_(u"Revitalization study"),
        required=False
    )

    qualified_teacher = schema.TextLine(
        title=_(u"Teaching class (Qualified teacher)"),
        required=False
    )

    ethnic_teacher = schema.TextLine(
        title=_(u"Teaching class (Ethnic teacher)"),
        required=False
    )

    education = schema.Text(
        title=_(u"Education"),
        required=False
    )

    experience = schema.Text(
        title=_(u"work experience"),
        required=False
    )

    teaching_years = schema.TextLine(
        title=_(u"Teaching years"),
        required=False
    )

    remarks = schema.Text(
        title=_(u"Remarks"),
        required=False
    )

    email = schema.TextLine(
        title=_(u"Email"),
        required=False
    )

    fieldset(_(u'Link Effective Date'), fields=['link_date'])
    link_date = schema.Date(
        title=_(u'Prepare Lessons Link Effective Date'),
        required=False,
    )

    fieldset(_(u'Teacher ID PW'), fields=['teacher_id', 'teacher_pw'])
    teacher_id = schema.TextLine(
        title=_(u'Teacher Username'),
        required=False,
    )

    teacher_pw = schema.TextLine(
        title=_(u'Teacher Password'),
        required=False,
    )
示例#20
0
class ITeacher(model.Schema):

    fieldset(_('Teacher Info'),
             fields=[
                 'image', 'certification', 'study', 'qualified_teacher',
                 'ethnic_teacher', 'education', 'experience', 'teaching_years',
                 'remarks'
             ])

    image = namedfile.NamedBlobImage(
        title=_(u'Teacher Image'),
        required=False,
    )

    certification = schema.Text(title=_(u"Ethnic language certification"),
                                required=False)

    study = schema.Text(title=_(u"Revitalization study"), required=False)

    qualified_teacher = schema.Text(
        title=_(u"Teaching class (Qualified teacher)"), required=False)

    ethnic_teacher = schema.Text(title=_(u"Teaching class (Ethnic teacher)"),
                                 required=False)

    education = schema.Text(title=_(u"Education"), required=False)

    experience = schema.Text(title=_(u"work experience"), required=False)

    teaching_years = schema.Text(title=_(u"Teaching years"), required=False)

    remarks = schema.Text(title=_(u"Remarks"), required=False)

    email = schema.TextLine(title=_(u"Email"), required=False)

    fieldset(_(u'Link Effective Date'), fields=['link_date'])
    link_date = schema.Date(
        title=_(u'Prepare Lessons Link Effective Date'),
        required=False,
    )

    fieldset(_(u'Teacher ID PW'), fields=['teacher_id', 'teacher_pw'])
    teacher_id = schema.TextLine(
        title=_(u'Teacher Username'),
        required=False,
    )

    teacher_pw = schema.TextLine(
        title=_(u'Teacher Password'),
        required=False,
    )