Exemplo n.º 1
0
 def get(self):
     sections = self.parseIndex()
     for file in sections:
         if Section.gql("where file = :1", file).count() == 0:
             section = Section(file=file, name=sections[file])
             section.put()
             memcache.set(key=file, value=sections[file], time=192*3600)
         taskqueue.add(queue_name="download", url="/download/%s" % file, method='GET')
Exemplo n.º 2
0
 def parse_section(self, chapter):
     for file_name in os.listdir(chapter.folder_url):
         abs_file_path = os.path.join(chapter.folder_url, file_name)
         if not os.path.isdir(abs_file_path):
             if file_name.startswith("."):
                 continue
             section = Section(abs_file_path)
             section.url = chapter.url + "/" + section.filename
             chapter.add_section(section)
Exemplo n.º 3
0
def _create_structure():
    category = Category('test category', 'category test', 'test_category')
    category.meta = {'id': 1, 'webtranslateit_ids': {'content': 1}}
    section = Section(category, 'test section', 'section test', 'test_section')
    section.meta = {'id': 2, 'webtranslateit_ids': {'content': 2}}
    category.sections.append(section)
    article = Article(section, 'test article', 'article body', 'test_article')
    article.meta = {'id': 3, 'webtranslateit_ids': {'content': 3, 'body': 4}}
    section.articles.append(article)
    return category, section, article
Exemplo n.º 4
0
def lesson(lesson_id, section_id):
    user_db = auth.current_user_db()
    if user_db.progress < lesson_id:
        return redirect(url_for('lesson', lesson_id=user_db.progress, section_id=1))
    if lesson_id > 0 and not user_db.registered:
        flash(u'Please register with your email below to access additional Lessons.')
        return redirect(url_for('welcome'))
    if request.method == 'POST':
        if answers.check(request.form, lesson_id):
            user_db.progress = lesson_id + 1
            try:
                user_db.put()
                flash(u'Congratulations! Welcome to Lesson %s.' % user_db.progress, 'success')
                return redirect(url_for('lesson', lesson_id=user_db.progress, section_id=1))
            except:
                flash(u'Something went wrong.', 'info')
                return redirect(url_for('lesson', lesson_id=lesson_id,section_id=section_id))
    lesson_db = Lesson.query(Lesson.number == lesson_id).get()
    section_dbs = Section.query(Section.lesson == lesson_id).order(Section.number)
    piece_dbs = Piece.query(Piece.lesson == lesson_id, Piece.section == section_id).order(Piece.number)
    graph_string = 'graphs/graph_' + str(lesson_id) + '_' + str(section_id)
    return render_template(
        'lesson.html',
        html_class='lesson',
        lesson=lesson_db,
        sections=section_dbs,
        pieces=piece_dbs,
        graph=graph_string + '.html',
        graph_head=graph_string + '_head.html',
        lesson_id=lesson_id,
        section_id=section_id,
        progress=user_db.progress
    )
Exemplo n.º 5
0
def fix_sections_legislation(docpath, sourcename):
    source = session.query(Source).filter(Source.name == sourcename).first()
    if source is None:
        source = Source(name=sourcename, type='legislation')
        session.add(source)
        session.commit()

    # conjoin the subitems of clauses to their parent
    # create sections from the parents
    to_fix = session.query(Section).filter(Section.docpath.like(docpath))
    nc = None
    ns = None
    for s in to_fix:
        if s.name != 'blp':
            for c in s.clauses:
                if '-' not in c.name: # new section
                    if ns is not None:
                        ns.clauses.append(nc)
                        session.add(ns)
                        nc = None

                    ns = Section(name=c.content_html, docpath=s.docpath, source_id=source.id)
                elif c.name.count('-') == 1: # new clause
                    if nc is not None:
                        ns.clauses.append(nc)

                    text = c.content_html
                    nc = RawClause(header=c.header, content_html=text, cleaned=text)
                else:
                    # continuation clause
                    text = '\n#{}#'.format(c.header) + c.content_html
                    nc.content_html += text
                    nc.cleaned += text
    session.commit()
Exemplo n.º 6
0
def create_section_in_program(program_name):
    """ Make request to section endpoint """
    program = Program.query.filter_by(program_name=program_name).first()
    # print(f'\n\n\n\t\t{program} \n\n\n')

    if program is not None:
        request_data = request.get_json()
        section_name = request_data['section_name']
        description = request_data['description']
        overview_Image_url = request_data['overview_Image_url']
        new_section = Section(program_id=program.program_id,
                              section_name=section_name,
                              description=description,
                              overview_Image_url=overview_Image_url)

        db.session.add(new_section)
        db.session.commit()
        return jsonify(serialize_section(new_section))
    else:
        return 'Cannot find the program', 404
Exemplo n.º 7
0
status_module = "blinky_adapter"
status_class = "BlinkyAdapter"

led_count = 60
request_interval = 60

startup_time = time(hour=07, minute=30)
shutdown_time = time(hour=18, minute=30)

jenkins_url = "https://jenkins.example.com"
jenkins_username = "******"
jenkins_password = "******"

sections = [
    Section("development", 0, 9,
            [Job("dev", True), Job("dev-test")]),
    Section("sonar", 10, 19, [Job("sonar")]),
    Section("regression-tests", 20, 29, [Job("regression-test")])
]

blue = [0, 0, 255]
red = [255, 0, 0]
orange = [255, 92, 0]
green = [0, 255, 0]
pink = [255, 0, 255]

color_mapping = {
    None: Led(blue),
    'ABORTED': Led(pink),
    'SUCCESS': Led(green),
    'UNSTABLE': Led(orange),
Exemplo n.º 8
0
def example_data():
    """ Create some sample data. """

    #Programs
    first_program = Program(
        name="Leadership Development Program",
        description="Leadership Development Program Description")

    second_program = Program(
        name="Cognitive Behavioral Therapy",
        description="Cognitive Behavioral Therapy Description")

    third_program = Program(name="New Parenting",
                            description="New Parenting Description")

    fourth_program = Program(name="Mindful Communication",
                             description="Mindful Communication Description")

    #First program's sections
    section_1 = Section(program_id=1,
                        name="Section 1 Program 1'",
                        description="Section 1 Program 1 Description",
                        order_index=1,
                        image_link="",
                        is_last=False)

    section_2 = Section(program_id=1,
                        name="Section 2 Program 1'",
                        description="Section 2 Program 1 Description",
                        order_index=2,
                        image_link="",
                        is_last=False)

    section_3 = Section(program_id=1,
                        name="Section 3 Program 1'",
                        description="Section 3 Program 1 Description",
                        order_index=3,
                        image_link="",
                        is_last=False)

    section_4 = Section(program_id=1,
                        name="Section 4 Program 1'",
                        description="Section 4 Program 1 Description",
                        order_index=4,
                        image_link="",
                        is_last=False)

    section_5 = Section(program_id=1,
                        name="Section 5 Program 1'",
                        description="Section 5 Program 1 Description",
                        order_index=5,
                        image_link="",
                        is_last=False)

    section_6 = Section(program_id=1,
                        name="Section 6 Program 1'",
                        description="Section 6 Program 1 Description",
                        order_index=6,
                        image_link="",
                        is_last=False)

    section_7 = Section(program_id=1,
                        name="Section 7 Program 1'",
                        description="Section 7 Program 1 Description",
                        order_index=7,
                        image_link="",
                        is_last=False)

    section_8 = Section(program_id=1,
                        name="Section 8 Program 1'",
                        description="Section 8 Program 1 Description",
                        order_index=8,
                        image_link="",
                        is_last=False)

    section_9 = Section(program_id=1,
                        name="Section 9 Program 1'",
                        description="Section 9 Program 1 Description",
                        order_index=9,
                        image_link="",
                        is_last=False)

    section_10 = Section(program_id=1,
                         name="Section 10 Program 1'",
                         description="Section 10 Program 1 Description",
                         order_index=10,
                         image_link="",
                         is_last=False)

    activity_1 = Activity(section_id=1,
                          html_content="",
                          question="Question Activity 1")

    activity_2 = Activity(section_id=2,
                          html_content="<html></html>",
                          question="")

    answer_1 = Answer(activity_id=1, answer_text="Activity 1 Answer Text")

    db.session.add_all([
        first_program, second_program, third_program, fourth_program,
        section_1, section_2, section_3, section_4, section_5, section_6,
        section_7, section_8, section_9, section_10, activity_1, activity_2,
        answer_1
    ])
    db.session.commit()
Exemplo n.º 9
0
def create_section(name, start, end=None, g_id=None):
    section = Section(name=name, start_date=start, end_date=end, g_id=g_id)
    db.session.add(section)
    db.session.commit()
    return section