Exemple #1
0
def render_characterNavigation():
    """
    FIXME: replace query by ?browse=<key>&start=<int>&end=<int>
    """
    args = to_dict(request.args)
    info = {}
    info['bread'] = [ ('Characters',url_for(".render_characterNavigation")),
    ('Dirichlet', url_for(".render_Dirichletwebpage")) ]

    info['learnmore'] = learn()

    if 'modbrowse' in args:
        arg = args['modbrowse']
        arg = arg.split('-')
        modulus_start = int(arg[0])
        modulus_end = int(arg[1])
        info['title'] = 'Dirichlet Characters of Moduli ' + str(modulus_start) + '-' + str(modulus_end)
        info['credit'] = 'Sage'
        h, c, rows, cols = ListCharacters.get_character_modulus(modulus_start, modulus_end)
        info['contents'] = c
        info['headers'] = h
        info['rows'] = rows
        info['cols'] = cols
        return render_template("ModulusList.html", **info)

    elif 'condbrowse' in args:
        arg = args['condbrowse']
        arg = arg.split('-')
        conductor_start = int(arg[0])
        conductor_end = int(arg[1])
        info['conductor_start'] = conductor_start
        info['conductor_end'] = conductor_end
        info['title'] = 'Dirichlet Characters of Conductors ' + str(conductor_start) + \
            '-' + str(conductor_end)
        info['credit'] = "Sage"
        info['contents'] = ListCharacters.get_character_conductor(conductor_start, conductor_end + 1)
        # info['contents'] = c
        # info['header'] = h
        # info['rows'] = rows
        # info['cols'] = cols
        return render_template("ConductorList.html", **info)

    elif 'ordbrowse' in args:
        arg = args['ordbrowse']
        arg = arg.split('-')
        order_start = int(arg[0])
        order_end = int(arg[1])
        info['order_start'] = order_start
        info['order_end'] = order_end
        info['title'] = 'Dirichlet Characters of Orders ' + str(order_start) + '-' + str(order_end)
        info['credit'] = 'Sage'
        info['contents'] = ListCharacters.get_character_order(order_start, order_end + 1)
        return render_template("OrderList.html", **info)

    elif args != {}:
        return character_search(**args)

    else:
       info['title'] = 'Dirichlet Characters'
       return render_template('CharacterNavigate.html', **info)
Exemple #2
0
def render_characterNavigation():
    """
    FIXME: replace query by ?browse=<key>&start=<int>&end=<int>
    """
    args = to_dict(request.args)
    info = {}
    info['bread'] = [ ('Characters',url_for(".render_characterNavigation")),
    ('Dirichlet', url_for(".render_Dirichletwebpage")) ]

    if 'modbrowse' in args:
        arg = args['modbrowse']
        arg = arg.split('-')
        modulus_start = int(arg[0])
        modulus_end = int(arg[1])
        info['title'] = 'Dirichlet Characters of Moduli ' + str(modulus_start) + '-' + str(modulus_end)
        info['credit'] = 'Sage'
        h, c, rows, cols = ListCharacters.get_character_modulus(modulus_start, modulus_end)
        info['contents'] = c
        info['headers'] = h
        info['rows'] = rows
        info['cols'] = cols
        return render_template("ModulusList.html", **info)

    elif 'condbrowse' in args:
        arg = args['condbrowse']
        arg = arg.split('-')
        conductor_start = int(arg[0])
        conductor_end = int(arg[1])
        info['conductor_start'] = conductor_start
        info['conductor_end'] = conductor_end
        info['title'] = 'Dirichlet Characters of Conductors ' + str(conductor_start) + \
            '-' + str(conductor_end)
        info['credit'] = "Sage"
        info['contents'] = ListCharacters.get_character_conductor(conductor_start, conductor_end + 1)
        # info['contents'] = c
        # info['header'] = h
        # info['rows'] = rows
        # info['cols'] = cols
        return render_template("ConductorList.html", **info)

    elif 'ordbrowse' in args:
        arg = args['ordbrowse']
        arg = arg.split('-')
        order_start = int(arg[0])
        order_end = int(arg[1])
        info['order_start'] = order_start
        info['order_end'] = order_end
        info['title'] = 'Dirichlet Characters of Orders ' + str(order_start) + '-' + str(order_end)
        info['credit'] = 'Sage'
        info['contents'] = ListCharacters.get_character_order(order_start, order_end + 1)
        return render_template("OrderList.html", **info)

    elif args != {}:
        return character_search(**args)

    else:
       info['title'] = 'Dirichlet Characters'
       return render_template('CharacterNavigate.html', **info)
Exemple #3
0
def render_characterNavigation():
    """
    FIXME: replace query by ?browse=<key>&start=<int>&end=<int>
    """
    args = to_dict(request.args)
    info = {}
    info["bread"] = [("Characters", "/Character")]

    if "modbrowse" in args:
        arg = args["modbrowse"]
        arg = arg.split("-")
        modulus_start = int(arg[0])
        modulus_end = int(arg[1])
        info["title"] = "Dirichlet Characters of Moduli " + str(modulus_start) + "-" + str(modulus_end)
        info["credit"] = "Sage"
        h, c, rows, cols = ListCharacters.get_character_modulus(modulus_start, modulus_end)
        info["contents"] = c
        info["headers"] = h
        info["rows"] = rows
        info["cols"] = cols
        return render_template("ModulusList.html", **info)

    elif "condbrowse" in args:
        arg = args["condbrowse"]
        arg = arg.split("-")
        conductor_start = int(arg[0])
        conductor_end = int(arg[1])
        info["conductor_start"] = conductor_start
        info["conductor_end"] = conductor_end
        info["title"] = "Dirichlet Characters of Conductors " + str(conductor_start) + "-" + str(conductor_end)
        info["credit"] = "Sage"
        info["contents"] = ListCharacters.get_character_conductor(conductor_start, conductor_end + 1)
        # info['contents'] = c
        # info['header'] = h
        # info['rows'] = rows
        # info['cols'] = cols
        return render_template("ConductorList.html", **info)

    elif "ordbrowse" in args:
        arg = args["ordbrowse"]
        arg = arg.split("-")
        order_start = int(arg[0])
        order_end = int(arg[1])
        info["order_start"] = order_start
        info["order_end"] = order_end
        info["title"] = "Dirichlet Characters of Orders " + str(order_start) + "-" + str(order_end)
        info["credit"] = "Sage"
        info["contents"] = ListCharacters.get_character_order(order_start, order_end + 1)
        return render_template("OrderList.html", **info)

    elif args != {}:
        return character_search(**args)

    else:
        return render_template("CharacterNavigate.html", **info)
Exemple #4
0
def render_DirichletNavigation():
    args = to_dict(request.args)

    info = {'args':args}
    info['bread'] = [ ('Characters',url_for(".render_characterNavigation")),
                      ('Dirichlet', url_for(".render_Dirichletwebpage")) ]

    info['learnmore'] = learn()

    if 'modbrowse' in args:
        arg = args['modbrowse']
        arg = arg.split('-')
        modulus_start = int(arg[0])
        modulus_end = int(arg[1])
        info['title'] = 'Dirichlet Characters of Modulus ' + str(modulus_start) + '-' + str(modulus_end)
        info['credit'] = 'Sage'
        h, c, rows, cols = ListCharacters.get_character_modulus(modulus_start, modulus_end)
        info['contents'] = c
        info['headers'] = h
        info['rows'] = rows
        info['cols'] = cols
        return render_template("ModulusList.html", **info)

    elif 'condbrowse' in args:
        arg = args['condbrowse']
        arg = arg.split('-')
        conductor_start = int(arg[0])
        conductor_end = int(arg[1])
        info['conductor_start'] = conductor_start
        info['conductor_end'] = conductor_end
        info['title'] = 'Dirichlet Characters of Conductor ' + str(conductor_start) + '-' + str(conductor_end)
        info['credit'] = "Sage"
        info['contents'] = ListCharacters.get_character_conductor(conductor_start, conductor_end + 1)
        return render_template("ConductorList.html", **info)

    elif 'ordbrowse' in args:
        arg = args['ordbrowse']
        arg = arg.split('-')
        order_start = int(arg[0])
        order_end = int(arg[1])
        info['order_start'] = order_start
        info['order_end'] = order_end
        info['title'] = 'Dirichlet Characters of Orders ' + str(order_start) + '-' + str(order_end)
        info['credit'] = 'SageMath'
        info['contents'] = ListCharacters.get_character_order(order_start, order_end + 1)
        return render_template("OrderList.html", **info)

    elif 'label' in args:
        label = args['label'].replace(' ','')
        if re.match(r'^[1-9][0-9]*\.[1-9][0-9]*$', label):
            slabel = label.split('.')
            m,n = int(slabel[0]), int(slabel[1])
            if m==n==1 or n < m and gcd(m,n) == 1:
                return redirect(url_for(".render_Dirichletwebpage", modulus=slabel[0], number=slabel[1]))
        if re.match(r'^[1-9][0-9]*$', label):
            return redirect(url_for(".render_Dirichletwebpage", modulus=label), 301)

        flash_error("%s is not a valid label for a Dirichlet character.  It should be of the form <span style='color:black'>q.n</span>, where q and n are coprime positive integers with n < q, or q=n=1.", label)
        return render_template('CharacterNavigate.html', **info)
        #FIXME, delete line below?
        #return redirect(url_for(".render_Dirichletwebpage"), 301)

    if args:
        # if user clicked refine search, reset start to 0
        if args.get('refine'):
            args['start'] = '0'
        try:
            search = ListCharacters.CharacterSearch(args)
        except ValueError as err:
            info['err'] = str(err)
            return render_template("CharacterNavigate.html" if "search" in args else "character_search_results.html" , **info)
        info['info'] = search.results()
        info['title'] = 'Dirichlet Character Search Results'
        info['bread'] = [('Characters', url_for(".render_characterNavigation")),
                         ('Dirichlet', url_for(".render_Dirichletwebpage")),
                         ('Search Results', '') ]
        info['credit'] = 'SageMath'
        return render_template("character_search_results.html", **info)
    else:
       info['title'] = 'Dirichlet Characters'
       return render_template('CharacterNavigate.html', **info)
def render_webpage(request, arg1, arg2):
    args = request.args
    temp_args = to_dict(args)
    if len(args) == 0:  # no arguments set yet
        if arg1 is None:  # this means we're at the start page
            info = set_info_for_start_page()  # sets info for character navigate
            info['credit'] = 'Sage'
            return render_template("dirichlet_characters/CharacterNavigate.html", **info)

        elif arg1.startswith("modbrowse"):
            modulus_start = int(arg1.partition('-')[0][10:])
            modulus_end = int(arg1.partition('-')[2])
            info = {}
            info["bread"] = [('Dirichlet Characters', url_for("render_Character")), ('Moduli ' + str(modulus_start) + '-' + str(modulus_end), '/Character/Dirichlet/modbrowse=' + str(modulus_start) + '-' + str(modulus_end))]
            info['title'] = 'Dirichlet Characters of Moduli ' + str(modulus_start) + '-' + str(modulus_end)
            info['credit'] = 'Sage'
            h, c, rows, cols = ListCharacters.get_character_modulus(modulus_start, modulus_end)
            info['contents'] = c
            info['headers'] = h
            info['rows'] = rows
            info['cols'] = cols
            return render_template("dirichlet_characters/ModulusList.html", **info)

        elif arg1.startswith("condbrowse"):
            conductor_start = int(arg1.partition('-')[0][11:])
            conductor_end = int(arg1.partition('-')[2])
            info = {}
            info['conductor_start'] = conductor_start
            info['conductor_end'] = conductor_end
            info["bread"] = [('Dirichlet Characters', url_for("render_Character")), ('Conductor ' + str(conductor_start) + '-' + str(conductor_end), '/Character/Dirichlet/condsearch=' + str(conductor_start) + '-' + str(conductor_end))]
            info['title'] = 'Dirichlet Characters of Conductors ' + str(conductor_start) + \
                '-' + str(conductor_end)
            info['credit'] = "Sage"
            info['contents'] = ListCharacters.get_character_conductor(conductor_start, conductor_end + 1)
            # info['contents'] = c
            # info['header'] = h
            # info['rows'] = rows
            # info['cols'] = cols
            return render_template("dirichlet_characters/ConductorList.html", **info)

        elif arg1.startswith("ordbrowse"):
            order_start = int(arg1.partition('-')[0][10:])
            order_end = int(arg1.partition('-')[2])
            info = {}
            info['order_start'] = order_start
            info['order_end'] = order_end
            info["bread"] = [('Dirichlet Characters', url_for("render_Character")), ('Order ' + str(order_start) + '-' + str(order_end), '/Character/Dirichlet/ordbrowse=' + str(order_start) + '-' + str(order_end))]
            info['title'] = 'Dirichlet Characters of Orders ' + str(order_start) + '-' + str(order_end)
            info['credit'] = 'Sage'
            info['contents'] = ListCharacters.get_character_order(order_start, order_end + 1)
            return render_template("dirichlet_characters/OrderList.html", **info)

        elif arg1 == 'custom':
            return "not yet implemented"

        temp_args['type'] = 'dirichlet'  # set type and input
        temp_args['modulus'] = arg1
        temp_args['number'] = arg2
            # elif arg1 == 'Hecke':
            #    temp_args['type'] = 'hecke'

        mod, num = Integer(str(arg1)), Integer(str(arg2))
        if mod <= 0 or num < 0 or mod < num or gcd(mod, num) != 1:
            info = {}
            info['message'] = """ modulus=%s,number=%s does not correspond to
            a valid Dirichlet character name.
            """ % (arg1, arg2)
            # See our <a href="%s">naming conventions</a>.
            return render_template("404.html", **info), 404
            # return 'invalid Dirichlet character name'

        web_chi = WebCharacter(temp_args)

        # try:
        #    print temp_args
        # except:
        #    1

        info = initCharacterInfo(web_chi, temp_args, request)  # sets the various properties of chi to be displayed in DirichletCharacter.htiml

        return render_template('dirichlet_characters/DirichletCharacter.html', **info)
    else:

        return character_search(**args)
def render_webpage(request, arg1, arg2):
    args = request.args
    temp_args = to_dict(args)
    if len(args) == 0:  # no arguments set yet
        if arg1 == None:  # this means we're at the start page
            info = set_info_for_start_page()  # sets info for character navigate
            info["credit"] = "Sage"
            return render_template("dirichlet_characters/CharacterNavigate.html", **info)

        elif arg1.startswith("modbrowse"):
            print "Check2"
            modulus_start = int(arg1.partition("-")[0][10:])
            modulus_end = int(arg1.partition("-")[2])
            info = {}
            info["bread"] = [
                ("Dirichlet Characters", url_for("render_Character")),
                (
                    "Moduli " + str(modulus_start) + "-" + str(modulus_end),
                    "/Character/Dirichlet/modbrowse=" + str(modulus_start) + "-" + str(modulus_end),
                ),
            ]
            info["title"] = "Moduli " + str(modulus_start) + "-" + str(modulus_end)
            info["credit"] = "Sage"
            info["contents"] = ListCharacters.get_character_modulus(modulus_start, modulus_end)
            return render_template("dirichlet_characters/ModulusList.html", **info)

        elif arg1.startswith("condbrowse"):
            conductor_start = int(arg1.partition("-")[0][11:])
            conductor_end = int(arg1.partition("-")[2])
            info = {}
            info["conductor_start"] = conductor_start
            info["conductor_end"] = conductor_end
            info["bread"] = [
                ("Dirichlet Characters", url_for("render_Character")),
                (
                    "Conductor " + str(conductor_start) + "-" + str(conductor_end),
                    "/Character/Dirichlet/condsearch=" + str(conductor_start) + "-" + str(conductor_end),
                ),
            ]
            info["title"] = "Conductors " + str(conductor_start) + "-" + str(conductor_end)
            info["credit"] = "Sage"
            info["contents"] = ListCharacters.get_character_conductor(conductor_start, conductor_end + 1)
            return render_template("dirichlet_characters/ConductorList.html", **info)

        elif arg1.startswith("ordbrowse"):
            order_start = int(arg1.partition("-")[0][10:])
            order_end = int(arg1.partition("-")[2])
            info = {}
            info["order_start"] = order_start
            info["order_end"] = order_end
            info["bread"] = [
                ("Dirichlet Characters", url_for("render_Character")),
                (
                    "Order " + str(order_start) + "-" + str(order_end),
                    "/Character/Dirichlet/ordbrowse=" + str(order_start) + "-" + str(order_end),
                ),
            ]
            info["title"] = "Order " + str(order_start) + "-" + str(order_end)
            info["credit"] = "Sage"
            info["contents"] = ListCharacters.get_character_order(order_start, order_end + 1)
            return render_template("dirichlet_characters/OrderList.html", **info)

        elif arg1 == "custom":
            return "not yet implemented"

        temp_args["type"] = "dirichlet"  # set type and input
        temp_args["modulus"] = arg1
        temp_args["number"] = arg2
        # elif arg1 == 'Hecke':
        #    temp_args['type'] = 'hecke'

        chi = WebCharacter(temp_args)

        print chi

        try:
            print temp_args
        except:
            1

        info = initCharacterInfo(
            chi, temp_args, request
        )  # sets the various properties of chi to be displayed in DirichletCharacter.html

        return render_template("dirichlet_characters/DirichletCharacter.html", **info)
    else:
        return character_search(**args)
def render_webpage(request, arg1, arg2):
    args = request.args
    temp_args = to_dict(args)
    if len(args) == 0:  # no arguments set yet
        if arg1 == None:  # this means we're at the start page
            info = set_info_for_start_page(
            )  # sets info for character navigate
            info['credit'] = 'Sage'
            return render_template(
                "dirichlet_characters/CharacterNavigate.html", **info)

        elif arg1.startswith("modbrowse"):
            print "Check2"
            modulus_start = int(arg1.partition('-')[0][10:])
            modulus_end = int(arg1.partition('-')[2])
            info = {}
            info["bread"] = [
                ('Dirichlet Characters', url_for("render_Character")),
                ('Moduli ' + str(modulus_start) + '-' + str(modulus_end),
                 '/Character/Dirichlet/modbrowse=' + str(modulus_start) + '-' +
                 str(modulus_end))
            ]
            info['title'] = 'Moduli ' + str(modulus_start) + '-' + str(
                modulus_end)
            info['credit'] = 'Sage'
            info['contents'] = ListCharacters.get_character_modulus(
                modulus_start, modulus_end)
            return render_template("dirichlet_characters/ModulusList.html",
                                   **info)

        elif arg1.startswith("condbrowse"):
            conductor_start = int(arg1.partition('-')[0][11:])
            conductor_end = int(arg1.partition('-')[2])
            info = {}
            info['conductor_start'] = conductor_start
            info['conductor_end'] = conductor_end
            info["bread"] = [
                ('Dirichlet Characters', url_for("render_Character")),
                ('Conductor ' + str(conductor_start) + '-' +
                 str(conductor_end), '/Character/Dirichlet/condsearch=' +
                 str(conductor_start) + '-' + str(conductor_end))
            ]
            info['title'] = 'Conductors ' + str(conductor_start) + '-' + str(
                conductor_end)
            info['credit'] = 'Sage'
            info['contents'] = ListCharacters.get_character_conductor(
                conductor_start, conductor_end + 1)
            return render_template("dirichlet_characters/ConductorList.html",
                                   **info)

        elif arg1.startswith("ordbrowse"):
            order_start = int(arg1.partition('-')[0][10:])
            order_end = int(arg1.partition('-')[2])
            info = {}
            info['order_start'] = order_start
            info['order_end'] = order_end
            info["bread"] = [
                ('Dirichlet Characters', url_for("render_Character")),
                ('Order ' + str(order_start) + '-' + str(order_end),
                 '/Character/Dirichlet/ordbrowse=' + str(order_start) + '-' +
                 str(order_end))
            ]
            info['title'] = 'Order ' + str(order_start) + '-' + str(order_end)
            info['credit'] = 'Sage'
            info['contents'] = ListCharacters.get_character_order(
                order_start, order_end + 1)
            return render_template("dirichlet_characters/OrderList.html",
                                   **info)

        elif arg1 == 'custom':
            return "not yet implemented"

        temp_args['type'] = 'dirichlet'  # set type and input
        temp_args['modulus'] = arg1
        temp_args['number'] = arg2
        #elif arg1 == 'Hecke':
        #    temp_args['type'] = 'hecke'

        chi = WebCharacter(temp_args)

        print chi

        try:
            print temp_args
        except:
            1

        info = initCharacterInfo(
            chi, temp_args, request
        )  # sets the various properties of chi to be displayed in DirichletCharacter.html

        return render_template('dirichlet_characters/DirichletCharacter.html',
                               **info)
    else:
        return character_search(**args)
def render_webpage(request, arg1, arg2):
    args = request.args
    temp_args = to_dict(args)
    if len(args) == 0:  # no arguments set yet
        if arg1 is None:  # this means we're at the start page
            info = set_info_for_start_page(
            )  # sets info for character navigate
            info['credit'] = 'Sage'
            return render_template(
                "dirichlet_characters/CharacterNavigate.html", **info)

        elif arg1.startswith("modbrowse"):
            modulus_start = int(arg1.partition('-')[0][10:])
            modulus_end = int(arg1.partition('-')[2])
            info = {}
            info["bread"] = [
                ('Dirichlet Characters', url_for("render_Character")),
                ('Moduli ' + str(modulus_start) + '-' + str(modulus_end),
                 '/Character/Dirichlet/modbrowse=' + str(modulus_start) + '-' +
                 str(modulus_end))
            ]
            info['title'] = 'Dirichlet Characters of Moduli ' + str(
                modulus_start) + '-' + str(modulus_end)
            info['credit'] = 'Sage'
            h, c, rows, cols = ListCharacters.get_character_modulus(
                modulus_start, modulus_end)
            info['contents'] = c
            info['headers'] = h
            info['rows'] = rows
            info['cols'] = cols
            return render_template("dirichlet_characters/ModulusList.html",
                                   **info)

        elif arg1.startswith("condbrowse"):
            conductor_start = int(arg1.partition('-')[0][11:])
            conductor_end = int(arg1.partition('-')[2])
            info = {}
            info['conductor_start'] = conductor_start
            info['conductor_end'] = conductor_end
            info["bread"] = [
                ('Dirichlet Characters', url_for("render_Character")),
                ('Conductor ' + str(conductor_start) + '-' +
                 str(conductor_end), '/Character/Dirichlet/condsearch=' +
                 str(conductor_start) + '-' + str(conductor_end))
            ]
            info['title'] = 'Dirichlet Characters of Conductors ' + str(conductor_start) + \
                '-' + str(conductor_end)
            info['credit'] = "Sage"
            info['contents'] = ListCharacters.get_character_conductor(
                conductor_start, conductor_end + 1)
            # info['contents'] = c
            # info['header'] = h
            # info['rows'] = rows
            # info['cols'] = cols
            return render_template("dirichlet_characters/ConductorList.html",
                                   **info)

        elif arg1.startswith("ordbrowse"):
            order_start = int(arg1.partition('-')[0][10:])
            order_end = int(arg1.partition('-')[2])
            info = {}
            info['order_start'] = order_start
            info['order_end'] = order_end
            info["bread"] = [
                ('Dirichlet Characters', url_for("render_Character")),
                ('Order ' + str(order_start) + '-' + str(order_end),
                 '/Character/Dirichlet/ordbrowse=' + str(order_start) + '-' +
                 str(order_end))
            ]
            info['title'] = 'Dirichlet Characters of Orders ' + str(
                order_start) + '-' + str(order_end)
            info['credit'] = 'Sage'
            info['contents'] = ListCharacters.get_character_order(
                order_start, order_end + 1)
            return render_template("dirichlet_characters/OrderList.html",
                                   **info)

        elif arg1 == 'custom':
            return "not yet implemented"

        temp_args['type'] = 'dirichlet'  # set type and input
        temp_args['modulus'] = arg1
        temp_args['number'] = arg2
        # elif arg1 == 'Hecke':
        #    temp_args['type'] = 'hecke'

        mod, num = Integer(str(arg1)), Integer(str(arg2))
        if mod <= 0 or num < 0 or mod < num or gcd(mod, num) != 1:
            info = {}
            info['message'] = """ modulus=%s,number=%s does not correspond to
            a valid Dirichlet character name.
            """ % (arg1, arg2)
            # See our <a href="%s">naming conventions</a>.
            return render_template("404.html", **info), 404
            # return 'invalid Dirichlet character name'

        web_chi = WebCharacter(temp_args)

        # try:
        #    print temp_args
        # except:
        #    1

        info = initCharacterInfo(
            web_chi, temp_args, request
        )  # sets the various properties of chi to be displayed in DirichletCharacter.htiml

        return render_template('dirichlet_characters/DirichletCharacter.html',
                               **info)
    else:

        return character_search(**args)