コード例 #1
0
ファイル: views.py プロジェクト: sevas/csxj_viewer_app
def show_source_day_summary(request, source_name, year, month, day):
    """
    Renders the summary for one day of crawling.
    Shows a list of all articles downloaded that day, grouped by 'batch'
    """
    y, m, d = [int(i) for i in (year, month, day)]


    available_sources = jsondb.get_source_list(STATIC_DATA_PATH)
    if source_name in available_sources:
        date_string = '{0}-{1}-{2}'.format(year, month, day)
        available_days = jsondb.get_all_days(STATIC_DATA_PATH, source_name)
        if date_string in available_days:
            values = base_template.load_all_common_values(STATIC_DATA_PATH)

            prev_day, next_day = find_next_and_prev_days(date_string, available_days)
            articles_per_batch = jsondb.get_articles_per_batch(STATIC_DATA_PATH, source_name, date_string)

            values.update({'current_date':datetime(y, m, d),
                           'prev_day':prev_day,
                           'next_day':next_day,
                           'articles_per_batch':articles_per_batch,
                           'source_name':source_name
                          })

            c = Context(values)
            t = loader.get_template('source_day.html')
            return HttpResponse(t.render(c))
        else:
            return render_not_found('There is no data to show you for that date : ' + datetime(y,m,d).strftime('%B %d, %Y'))
    else:
        return render_not_found('There is no content provider with that id : {0}'.format(source_name))
コード例 #2
0
ファイル: views.py プロジェクト: sevas/csxj_viewer_app
def render_not_found(reason):
    values = base_template.load_all_common_values(STATIC_DATA_PATH)

    t = loader.get_template('source_day_not_found.html')
    values.update(dict(reason=reason))
    c = Context(values)
    return HttpResponse(t.render(c))
コード例 #3
0
ファイル: views.py プロジェクト: sevas/csxj_viewer_app
def render_not_found(reason):
    values = base_template.load_all_common_values(STATIC_DATA_PATH)
    
    t = loader.get_template('source_day_not_found.html')
    values.update(dict(reason=reason))
    c = Context(values)
    return HttpResponse(t.render(c))
コード例 #4
0
ファイル: views.py プロジェクト: sevas/csxj_viewer_app
def show_source_day_batch_summary(request, source_name, year, month, day, hours, minutes, seconds):
    y, m, d = [int(i) for i in (year, month, day)]
    h, mm, s = [int(i) for i in (hours, minutes, seconds)]

    available_sources = jsondb.get_source_list(STATIC_DATA_PATH)
    if source_name in available_sources:
        date_string = '{0}-{1}-{2}'.format(year, month, day)
        available_days = jsondb.get_all_days(STATIC_DATA_PATH, source_name)
        if date_string in available_days:
            available_batches = jsondb.get_all_batches(STATIC_DATA_PATH, source_name, date_string)
            batch_string = '{0}.{1}.{2}'.format(hours, minutes, seconds)
            
            if batch_string in available_batches:
                values = base_template.load_all_common_values(STATIC_DATA_PATH)
                articles = jsondb.get_articles_from_batch(STATIC_DATA_PATH, source_name, date_string, batch_string)
                values.update({'articles':articles, 'source_name':source_name})
                t = loader.get_template('source_batch.html')
                c = Context(values)
                return HttpResponse(t.render(c))

            else:
                return render_not_found('This source has no data to show you for that date and time : ' + asked_datetime.strftime('%B %d, %Y at %H:%M:%S'))
        else:
            return render_not_found('There is no data to show you for that date : ' + datetime(y,m,d).strftime('%B %d, %Y'))
    else:
        return render_not_found('There is no content provider with that id : {0}'.format(source_name))
コード例 #5
0
ファイル: views.py プロジェクト: sevas/csxj_viewer_app
def show_source_graphs(request, source_name):
    available_sources = jsondb.get_source_list(STATIC_DATA_PATH)
    if source_name in available_sources:
        values = base_template.load_all_common_values(STATIC_DATA_PATH)
        values.update({'source_name':source_name})

        t = loader.get_template('source_graphs.html')
        c = Context(values)
        return HttpResponse(t.render(c))
    else:
        return render_not_found('There is no content provider with that id : {0}'.format(source_name))
コード例 #6
0
ファイル: views.py プロジェクト: sevas/csxj_viewer_app
def show_source_graphs(request, source_name):
    available_sources = jsondb.get_source_list(STATIC_DATA_PATH)
    if source_name in available_sources:
        values = base_template.load_all_common_values(STATIC_DATA_PATH)
        values.update({'source_name': source_name})

        t = loader.get_template('source_graphs.html')
        c = Context(values)
        return HttpResponse(t.render(c))
    else:
        return render_not_found(
            'There is no content provider with that id : {0}'.format(
                source_name))
コード例 #7
0
ファイル: views.py プロジェクト: sevas/csxj_viewer_app
def show_source_day_batch_summary(request, source_name, year, month, day,
                                  hours, minutes, seconds):
    y, m, d = [int(i) for i in (year, month, day)]
    h, mm, s = [int(i) for i in (hours, minutes, seconds)]

    available_sources = jsondb.get_source_list(STATIC_DATA_PATH)
    if source_name in available_sources:
        date_string = '{0}-{1}-{2}'.format(year, month, day)
        available_days = jsondb.get_all_days(STATIC_DATA_PATH, source_name)
        if date_string in available_days:
            available_batches = jsondb.get_all_batches(STATIC_DATA_PATH,
                                                       source_name,
                                                       date_string)
            batch_string = '{0}.{1}.{2}'.format(hours, minutes, seconds)

            if batch_string in available_batches:
                values = base_template.load_all_common_values(STATIC_DATA_PATH)
                articles = jsondb.get_articles_from_batch(
                    STATIC_DATA_PATH, source_name, date_string, batch_string)
                values.update({
                    'articles': articles,
                    'source_name': source_name
                })
                t = loader.get_template('source_batch.html')
                c = Context(values)
                return HttpResponse(t.render(c))

            else:
                return render_not_found(
                    'This source has no data to show you for that date and time : '
                    + asked_datetime.strftime('%B %d, %Y at %H:%M:%S'))
        else:
            return render_not_found(
                'There is no data to show you for that date : ' +
                datetime(y, m, d).strftime('%B %d, %Y'))
    else:
        return render_not_found(
            'There is no content provider with that id : {0}'.format(
                source_name))
コード例 #8
0
ファイル: views.py プロジェクト: sevas/csxj_viewer_app
def show_source_day_summary(request, source_name, year, month, day):
    """
    Renders the summary for one day of crawling.
    Shows a list of all articles downloaded that day, grouped by 'batch'
    """
    y, m, d = [int(i) for i in (year, month, day)]

    available_sources = jsondb.get_source_list(STATIC_DATA_PATH)
    if source_name in available_sources:
        date_string = '{0}-{1}-{2}'.format(year, month, day)
        available_days = jsondb.get_all_days(STATIC_DATA_PATH, source_name)
        if date_string in available_days:
            values = base_template.load_all_common_values(STATIC_DATA_PATH)

            prev_day, next_day = find_next_and_prev_days(
                date_string, available_days)
            articles_per_batch = jsondb.get_articles_per_batch(
                STATIC_DATA_PATH, source_name, date_string)

            values.update({
                'current_date': datetime(y, m, d),
                'prev_day': prev_day,
                'next_day': next_day,
                'articles_per_batch': articles_per_batch,
                'source_name': source_name
            })

            c = Context(values)
            t = loader.get_template('source_day.html')
            return HttpResponse(t.render(c))
        else:
            return render_not_found(
                'There is no data to show you for that date : ' +
                datetime(y, m, d).strftime('%B %d, %Y'))
    else:
        return render_not_found(
            'There is no content provider with that id : {0}'.format(
                source_name))