Table not working randomly. H2 repeating in the loop. Function upgrades.
This commit is contained in:
Binary file not shown.
@ -49,7 +49,7 @@ def get_courses():
|
|||||||
|
|
||||||
for course in dt:
|
for course in dt:
|
||||||
df = df.append(course["attributes"], ignore_index=True)
|
df = df.append(course["attributes"], ignore_index=True)
|
||||||
df = df.drop("list_image_url", axis=1)
|
# df = df.drop("list_image_url", axis=1)
|
||||||
|
|
||||||
if "next" not in next:
|
if "next" not in next:
|
||||||
break
|
break
|
||||||
@ -107,9 +107,41 @@ def get_people():
|
|||||||
return "what what"
|
return "what what"
|
||||||
|
|
||||||
|
|
||||||
@app.route("/add_options")
|
@app.route("/add_options", methods=["POST"])
|
||||||
def add_options():
|
def add_options():
|
||||||
return render_template("bulk_add.html", title="Bulk Add Learners")
|
array = []
|
||||||
|
df = pd.DataFrame()
|
||||||
|
x = 0
|
||||||
|
if request.method == "POST":
|
||||||
|
while True:
|
||||||
|
x += 1
|
||||||
|
url = f"https://api.northpass.com/v2/groups?page={x}"
|
||||||
|
headers = {"accept": "application/json", "X-Api-Key": session["key"]}
|
||||||
|
response = requests.get(url, headers=headers)
|
||||||
|
data = response.text
|
||||||
|
df = pd.json_normalize(data)
|
||||||
|
print(df)
|
||||||
|
|
||||||
|
# print(type(response))
|
||||||
|
# print(response)
|
||||||
|
# jsonresponse = response.json()
|
||||||
|
# dt = jsonresponse["data"]
|
||||||
|
# next = jsonresponse["links"]
|
||||||
|
|
||||||
|
for group in dt:
|
||||||
|
df = df.from_dict(group["attributes"], orient="index")
|
||||||
|
# df = df.append(group["id"], ignore_index=True)
|
||||||
|
# df = df.append(group["attributes"], ignore_index=True)
|
||||||
|
|
||||||
|
if "next" not in next:
|
||||||
|
break
|
||||||
|
|
||||||
|
print(df)
|
||||||
|
session["dfcsv"] = df.to_csv()
|
||||||
|
dfgroups = df.to_html(col_space=5)
|
||||||
|
return render_template(
|
||||||
|
"bulk_add.html", tables=dfgroups, titles="Bulk Add Learners"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/bulk_add", methods=["GET", "POST"])
|
@app.route("/bulk_add", methods=["GET", "POST"])
|
||||||
|
|||||||
@ -51,14 +51,14 @@ html {
|
|||||||
|
|
||||||
input,
|
input,
|
||||||
select {
|
select {
|
||||||
width: 200px;
|
width: 200px;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
--moz-box-sizing: border-box;
|
--moz-box-sizing: border-box;
|
||||||
--webkit-box-sizing: border-box;
|
--webkit-box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
.dataframe {
|
.dataframe {
|
||||||
font-size: 11pt;
|
font-size: 11pt;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
@ -78,7 +78,7 @@ select {
|
|||||||
.dataframe tr:hover {
|
.dataframe tr:hover {
|
||||||
background: #096F8E;
|
background: #096F8E;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 4rem;
|
font-size: 4rem;
|
||||||
|
|||||||
@ -3,22 +3,27 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<h4>Hello! Please enter the emails below.</h4>
|
<h4>Hello! Please enter the emails below.</h4>
|
||||||
{% if error %}
|
{% if error %}
|
||||||
<p class=error><strong> </strong>{{ error }}
|
<p class=error><strong> </strong>{{ error }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<p><label for="Bulk Add"> Please select the appropriate options below.</label></p>
|
<p><label for="Bulk Add"> Please select the appropriate options below.</label></p>
|
||||||
<form action="{{ url_for("bulk_add")}}" method="post">
|
<form action="{{ url_for("bulk_add")}}" method="post">
|
||||||
<p>Please Copy and Paste Emails of learners you'd like to add</p>
|
<p>Please Copy and Paste Emails of learners you'd like to add</p>
|
||||||
<textarea id="emails" name="emails" rows="4" cols="50"></textarea>
|
<textarea id="emails" name="emails" rows="4" cols="50"></textarea>
|
||||||
<p>Please select which Groups these learners should be added to. </p>
|
<p>Please paste in the Group UUIDs which these learners should be added to.</p>
|
||||||
<select name="groups" id="groups" multiple>
|
<textarea id="groups" name="groups" rows="4" cols="50"></textarea>
|
||||||
<option></option>
|
<option></option>
|
||||||
<input type="submit" value="Submit"></select>
|
<input type="submit" value="Submit"></select>
|
||||||
</form>
|
</form>
|
||||||
|
<h4>Here is a list of your client's Groups.</h4>
|
||||||
|
<a id="download" href="/downloadcsv">Click here to download as CSV.</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="panda-table">
|
||||||
|
<!-- Display Converted Table -->
|
||||||
|
<h2> {{ titles }} </h2>
|
||||||
|
{{ table }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script src="{{ url_for('static', filename='getallgroups.js')}}"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap"
|
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap"
|
||||||
rel="stylesheet">
|
rel="stylesheet">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename="css/styles.css") }}" />
|
<link rel="stylesheet" href="{{ url_for('static', filename="css/styles.css") }}" />
|
||||||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@ -27,14 +27,17 @@
|
|||||||
</a>
|
</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="card" >
|
<form class="card"
|
||||||
<a class="a-card" href="{{ url_for('add_options')}}"
|
id="add_options"
|
||||||
style="cursor:pointer; color: inherit; text-decoration: none">
|
action="{{ url_for('add_options')}}"
|
||||||
<i class="ri-building-line card__icon"></i>
|
method="post">
|
||||||
<p class="card__name">Bulk Add</p>
|
<a class="a-card"
|
||||||
|
onclick="document.forms['add_options'].submit()"
|
||||||
|
style="cursor:pointer;">
|
||||||
|
<i class="ri-send-plane-line card__icon"></i>
|
||||||
|
<p class="card__name">Bulk Add People</p>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -14,4 +14,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user