def test(self):

        report_id = "R000001"
        auther_user_id = "U0001"
        file_name = "file_name001"
        google_file_id = "g0001"
        target_year = "2019"
        comment = "comment001"
        login_user_id = "U0000"

        ReportRepository().insert(report_id, auther_user_id, file_name,
                                  google_file_id, target_year, comment,
                                  login_user_id)

        report = ReportQuery().get_one(report_id)

        self.assertEqual(report.auther_user_id, "U0001")
        self.assertEqual(report.file_name, "file_name001")
        self.assertEqual(report.google_file_id, "g0001")
        self.assertEqual(report.target_year, "2019")
        self.assertEqual(report.comment, "comment001")
        self.assertEqual(report.create_user_id, "U0000")
        self.assertEqual(report.update_user_id, "U0000")

        ReportRepository().delete(report)

        report = ReportQuery().get_one(report_id)
        self.assertEqual(report, None)
def change(request):

    form = TargetYearForm(data=request.POST)

    if form.is_valid():
        target_year = form.cleaned_data['target_year']

        result_list = ReportQuery().custom_query(str(target_year), '', '', 0,
                                                 100, 'auther-user-sort',
                                                 'True')

        context = {
            'result_list': result_list,
            'result_list_count': len(result_list),
            'target_years': function.get_target_years(),
            'target_year': int(target_year),
            'password': REPORT_SUMMARY_PASSWORD
        }

        return render(request,
                      'student/reportsummary/summarypartial.html',
                      context=context)
    else:
        # プルダウン選択でvalidではない場合は、不正操作として何も返さない。
        return None
    def test_custom_query_case11(self):

        result_list = ReportQuery().custom_query("", "", "_name", 0, 5,
                                                 "download-count-sort",
                                                 "False")

        self.assertEqual(len(result_list), 4)

        self.assertEqual(result_list[0].report_id, "R000004")
        self.assertEqual(result_list[0].target_year, "2018")
        self.assertEqual(result_list[0].file_name, "file_name004")
        self.assertEqual(result_list[0].full_name, "first_name2 last_name2")
        self.assertEqual(result_list[0].download_count, 0)
        self.assertEqual(result_list[0].comment, "comment004")

        self.assertEqual(result_list[1].report_id, "R000003")
        self.assertEqual(result_list[1].target_year, "2018")
        self.assertEqual(result_list[1].file_name, "file_name003")
        self.assertEqual(result_list[1].full_name, "first_name1 last_name1")
        self.assertEqual(result_list[1].download_count, 0)
        self.assertEqual(result_list[1].comment, "comment003")

        self.assertEqual(result_list[2].report_id, "R000002")
        self.assertEqual(result_list[2].target_year, "2019")
        self.assertEqual(result_list[2].file_name, "file_name002")
        self.assertEqual(result_list[2].full_name, "first_name2 last_name2")
        self.assertEqual(result_list[2].download_count, 2)
        self.assertEqual(result_list[2].comment, "comment002")

        self.assertEqual(result_list[3].report_id, "R000001")
        self.assertEqual(result_list[3].target_year, "2019")
        self.assertEqual(result_list[3].file_name, "file_name001")
        self.assertEqual(result_list[3].full_name, "first_name1 last_name1")
        self.assertEqual(result_list[3].download_count, 2)
        self.assertEqual(result_list[3].comment, "comment001")
    def test_custom_query_case3(self):

        result_list = ReportQuery().custom_query("", "_name2", "", 0, 5,
                                                 "target-year-sort", "True")

        self.assertEqual(len(result_list), 3)

        self.assertEqual(result_list[0].report_id, "R000002")
        self.assertEqual(result_list[0].target_year, "2019")
        self.assertEqual(result_list[0].file_name, "file_name002")
        self.assertEqual(result_list[0].full_name, "first_name2 last_name2")
        self.assertEqual(result_list[0].download_count, 2)
        self.assertEqual(result_list[0].comment, "comment002")

        self.assertEqual(result_list[1].report_id, "R000004")
        self.assertEqual(result_list[1].target_year, "2018")
        self.assertEqual(result_list[1].file_name, "file_name004")
        self.assertEqual(result_list[1].full_name, "first_name2 last_name2")
        self.assertEqual(result_list[1].download_count, 0)
        self.assertEqual(result_list[1].comment, "comment004")

        self.assertEqual(result_list[2].report_id, "R000005")
        self.assertEqual(result_list[2].target_year, "2017")
        self.assertEqual(result_list[2].file_name, "file_xxxx005")
        self.assertEqual(result_list[2].full_name, "first_name2 last_name2")
        self.assertEqual(result_list[2].download_count, 0)
        self.assertEqual(result_list[2].comment, "comment005")
def __search(
        request,
        target_year,
        full_name,
        file_name,
        target_sort_item,
        target_descending_order):

    offset = 0

    result_list_count = ReportQuery().custom_count(target_year, full_name, file_name)
    result_list = ReportQuery().custom_query(
        target_year,
        full_name,
        file_name,
        offset,
        __limit,
        target_sort_item,
        target_descending_order)

    request.session['target_year'] = target_year
    request.session['full_name'] = full_name
    request.session['file_name'] = file_name
    request.session['current_sort_item'] = target_sort_item
    request.session['current_descending_order'] = target_descending_order

    context = {
        'result_list': result_list,
        'result_list_count': result_list_count,
        'current_sort_item': target_sort_item,
        'current_descending_order': target_descending_order,
        'current_page': offset + 1,
        'limit': __limit,
        'authority_name': request.session['authority']
    }

    html = render_to_string(
        'student/report/search_result.html',
        context,
        request=request)
    return HttpResponse(html)
Example #6
0
    def test_get_one_case1(self):

        result = ReportQuery().get_one('R000002')

        self.assertEqual(result.report_id, "R000002")
        self.assertEqual(result.auther_user_id, "U0002")
        self.assertEqual(result.target_year, "2019")
        self.assertEqual(result.file_name, "file_name002")
        self.assertEqual(result.google_file_id, "google_file_id_002")
        self.assertEqual(result.comment, "comment002")
        self.assertEqual(result.create_user_id, "U0001")
        self.assertEqual(result.update_user_id, "U0001")
    def test_custom_query_case6(self):

        result_list = ReportQuery().custom_query("", "", "", 4, 4,
                                                 "target-year-sort", "False")

        self.assertEqual(len(result_list), 1)

        self.assertEqual(result_list[0].report_id, "R000001")
        self.assertEqual(result_list[0].target_year, "2019")
        self.assertEqual(result_list[0].file_name, "file_name001")
        self.assertEqual(result_list[0].full_name, "first_name1 last_name1")
        self.assertEqual(result_list[0].download_count, 2)
        self.assertEqual(result_list[0].comment, "comment001")
Example #8
0
 def __new__(cls, *args, **kwargs):
     cls.__new_lock.acquire()
     if cls.__singleton is None:
         cls.__singleton = super(ReportService, cls).__new__(cls)
         cls.__applicationuserrquery = ApplicationUserQuery()
         cls.__numberingmasterquery = NumberingMasterQuery()
         cls.__googleapiservice = GoogleApiService()
         cls.__reportrepository = ReportRepository()
         cls.__reportquery = ReportQuery()
         cls.__downloadinformationrepository = DownloadInformationRepository()
         cls.__downloadinformationquery = DownloadInformationQuery()
     cls.__new_lock.release()
     return cls.__singleton
def __paging(request, current_page, previous, next, target_page):

    offset, target_page = function.get_offset(
        previous, next, target_page, current_page, __limit)

    target_year = request.session['target_year']
    full_name = request.session['full_name']
    file_name = request.session['file_name']
    current_sort_item = request.session['current_sort_item']
    current_descending_order = request.session['current_descending_order']

    result_list_count = ReportQuery().custom_count(target_year, full_name, file_name)
    result_list = ReportQuery().custom_query(
        target_year,
        full_name,
        file_name,
        offset,
        __limit,
        current_sort_item,
        current_descending_order)

    context = {
        'result_list': result_list,
        'result_list_count': result_list_count,
        'current_page': target_page,
        'limit': __limit,
        'current_sort_item': current_sort_item,
        'current_descending_order': current_descending_order,
        'authority_name': request.session['authority']
    }

    html = render_to_string(
        'student/report/search_result.html',
        context,
        request=request)
    return HttpResponse(html)
def search_sp(request):

    form = ReportSearchSpForm(data=request.POST)

    if form.is_valid():
        search_value = form.cleaned_data['search_value']

        result_list = ReportQuery().custom_query_sp(search_value)

        context = {
            'result_list': result_list
        }

        html = render_to_string(
            'student/report/search_result_sp.html',
            context,
            request=request)
        return HttpResponse(html)
    else:
        return None
Example #11
0
    def test_select_all_case1(self):

        result_list = ReportQuery().select_all()
        self.assertEqual(len(result_list), 4)

        self.assertEqual(result_list[0].report_id, "R000002")
        self.assertEqual(result_list[0].auther_user_id, "U0002")
        self.assertEqual(result_list[0].target_year, "2019")
        self.assertEqual(result_list[0].file_name, "file_name002")
        self.assertEqual(result_list[0].google_file_id, "google_file_id_002")
        self.assertEqual(result_list[0].comment, "comment002")
        self.assertEqual(result_list[0].create_user_id, "U0001")
        self.assertEqual(result_list[0].update_user_id, "U0001")

        self.assertEqual(result_list[1].report_id, "R000001")
        self.assertEqual(result_list[1].auther_user_id, "U0001")
        self.assertEqual(result_list[1].target_year, "2019")
        self.assertEqual(result_list[1].file_name, "file_name001")
        self.assertEqual(result_list[1].google_file_id, "google_file_id_001")
        self.assertEqual(result_list[1].comment, "comment001")
        self.assertEqual(result_list[1].create_user_id, "U0001")
        self.assertEqual(result_list[1].update_user_id, "U0001")

        self.assertEqual(result_list[2].report_id, "R000004")
        self.assertEqual(result_list[2].auther_user_id, "U0002")
        self.assertEqual(result_list[2].target_year, "2018")
        self.assertEqual(result_list[2].file_name, "file_name004")
        self.assertEqual(result_list[2].google_file_id, "google_file_id_004")
        self.assertEqual(result_list[2].comment, "comment004")
        self.assertEqual(result_list[2].create_user_id, "U0001")
        self.assertEqual(result_list[2].update_user_id, "U0001")

        self.assertEqual(result_list[3].report_id, "R000003")
        self.assertEqual(result_list[3].auther_user_id, "U0001")
        self.assertEqual(result_list[3].target_year, "2018")
        self.assertEqual(result_list[3].file_name, "file_name003")
        self.assertEqual(result_list[3].google_file_id, "google_file_id_003")
        self.assertEqual(result_list[3].comment, "comment003")
        self.assertEqual(result_list[3].create_user_id, "U0001")
        self.assertEqual(result_list[3].update_user_id, "U0001")
    def test_custom_count_case4(self):

        result = ReportQuery().custom_count("2019", "_name1", "_name")

        self.assertEqual(result, 1)
    def test_custom_count_case3(self):

        result = ReportQuery().custom_count("", "", "_name")

        self.assertEqual(result, 4)
    def test_custom_count_case1(self):

        result = ReportQuery().custom_count("2019", "", "")

        self.assertEqual(result, 2)
Example #15
0
    def test_exist_same_file_name_case2(self):

        result = ReportQuery().exist_same_file_name("abc")

        self.assertEqual(result, False)
Example #16
0
    def test_exist_same_file_name_case1(self):

        result = ReportQuery().exist_same_file_name("file_name002")

        self.assertEqual(result, True)