Disclaimer: Title may not be the best way to describe what I am about to ask. If you have a better title in mind, please put it instead of mine
I am working on a scope database which will allow me to know what user has access to what ressource. To put it simply:
admin
super-foo
manager-foo-1
user-1
user-2
manager-foo-2
user-3
user-4
super-bar
manager-bar-1
user-5
user-6
manager-bar-2
user-7
user-8
admin has access to all users underneath him.
super-foo has access to all users underneath him, but not the ones of super-bar
etc... until your reach for example user-1, which doesn't have access to anything except himself
(when I say underneath, I mean hierarchically)
(when I say acces, I mean access data, the users, whatever)
Each entry of my DB is like this (using manager-foo-1 for example):
id=manager-foo-1 (I have a function that I can call to get everything on the user as the uuid is the hash key of my user DB (because i'm using their usernames here, but the ids are uuids.))
parents_id=['super-foo']
children_id=['user-1', 'user2']
Here's my DB right now (I've replaced the uuid4 with names):
for user_scope in UserScope.scan():
print("User {} has parents {} and childs {}".format(user_scope.id, user_scope.parents_id, user_scope.children_id))
User manager-foo has parents [super-foo] and childs [user-1, user-2]
User admin has parents None and childs [super-foo]
User super-foo has parents [admin] and childs [manager-foo]
User user-1 has parents [manager-foo] and childs None
User user-1 has parents [manager-foo] and childs None
childs are set to None when you reach the bottom, but that shouldn't really matter
What I would like it to get a pretty display, or at least an understandable display or that DB, when given an id. So if given admin, display EVERYTHING. If given user-1, only display user-1 etc...
I've used a little bit of jinja templates but nothing advanced, the furthest I've got was this for loop to make a user list (using a macro)
{% for user in user_list %}
{% from "user_line.html" import user_line %}
{{user_line(user)}}
{% endfor %}
I'm having trouble to wrap my head around how to do this, what should the layout be, in what order should I display them and should I use macros? templates?
Thanks in advance
I ended up finding a way to solve this.
First of all, I generated a dictionnary containing everything I need scopewise:
def get_all_children_tree(uid):
scope = get_userscope_dict(user.client_id)
children = []
if scope['children_id'] is None:
ret = {
"user": scope['id'],
"children": None
}
return ret
for child_id in scope['children_id']:
children.append(get_all_children_tree(child_id))
ret = {
"user": scope['id'],
"children": children
}
return ret
This will give me something like this:
{
'user':'cbf7f365-db8a-419b-9f8c-c24b2ce01361',
'children':[
{
'user':'17bc0bdc-892b-4e47-b749-36c1687c0992',
'children':[
{
'user':'d51056b7-60fe-437f-abe0-4a30076df4cd',
'children':[
{
'user':'14f1963b-0f64-4431-a52f-819877d6096c',
'children':None
},
{
'user':'40765a8d-6001-4146-9d1f-ce3fd95646c7',
'children':None
}
]
},
{
'user':'8a617821-e189-4b17-ac67-597ca79b98e9',
'children':[
{
'user':'42af51b0-2810-4004-b063-a4789631bb2e',
'children':None
},
{
'user':'26d43e72-4e45-40c3-ab2b-98c637dde5aa',
'children':None
}
]
}
]
}
]
}
Then I wrote a jinja template like so :
{% extends "main.html" %}
{% block body %}
<!-- tree -->
<style type="text/css">
ul.tree {
overflow-x: auto;
white-space: nowrap;
}
ul.tree,
ul.tree ul {
width: auto;
margin: 0;
padding: 0;
list-style-type: none;
}
ul.tree li {
display: block;
width: auto;
float: left;
vertical-align: top;
padding: 0;
margin: 0;
}
ul.tree ul li {
background-image: url(data:image/gif;base64,R0lGODdhAQABAIABAAAAAP///ywAAAAAAQABAAACAkQBADs=);
background-repeat: repeat-x;
background-position: left top;
}
ul.tree li span {
display: block;
width: 5em;
/*
uncomment to fix levels
height: 1.5em;
*/
margin: 0 auto;
text-align: center;
white-space: normal;
letter-spacing: normal;
}
</style>
<!--[if IE gt 8]> IE 9+ and not IE -->
<style type="text/css">
ul.tree ul li:last-child {
background-repeat: no-repeat;
background-size:50% 1px;
background-position: left top;
}
ul.tree ul li:first-child {
background-repeat: no-repeat;
background-size: 50% 1px;
background-position: right top;
}
ul.tree ul li:first-child:last-child {
background: none;
}
ul.tree ul li span {
background: url(data:image/gif;base64,R0lGODdhAQABAIABAAAAAP///ywAAAAAAQABAAACAkQBADs=) no-repeat 50% top;
background-size: 1px 0.8em;
padding-top: 1.2em;
}
ul.tree ul {
background: url(data:image/gif;base64,R0lGODdhAQABAIABAAAAAP///ywAAAAAAQABAAACAkQBADs=) no-repeat 50% top;
background-size: 1px 0.8em;
margin-top: 0.2ex;
padding-top: 0.8em;
}
</style>
<!-- <[endif]-->
<!--[if lte IE 8]>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
/* Just to simplify HTML for the moment.
* This could easily be replaced by inline classes.
*/
$(function() {
$('li:first-child').addClass('first');
$('li:last-child').addClass('last');
$('li:first-child:last-child').addClass('lone');
});
</script>
<style type="text/css">
ul.tree ul li {
background-image: url(pixel.gif);
}
ul.tree ul li.first {
background-image: url(left.gif);
background-position: center top;
}
ul.tree ul li.last {
background-image: url(right.gif);
background-position: center top;
}
ul.tree ul li.lone {
background: none;
}
ul.tree ul li span {
background: url(child.gif) no-repeat 50% top;
padding-top: 14px;
}
ul.tree ul {
background: url(child.gif) no-repeat 50% top;
margin-top: 0.2ex;
padding-top: 11px;
}
</style>
<[endif]-->
<!-- page presentation -->
<style type="text/css">
body {
font-family:sans-serif;
color: #666;
text-align: center;
}
A, A:visited, A:active {
color: #c00;
text-decoration: none;
}
A:hover {
text-decoration: underline;
}
ul.tree,
#wrapper {
width: 960px;
margin: 0 auto;
}
ul.tree {
width: 650px;
}
p {
margin-top: 2em;
}
</style>
<div id="page-wrapper">
<p> {{ data }}</p>
<div id="wrapper">
<ul class="tree">
<li>
<span> {{ get_user(data['user']).username }}</span>
<ul>
{%- for child in data['children'] recursive %}
<li>
<span> {{ get_user(child['user']).username }} </span>
{%- if child['children'] -%}
<ul>
{{ loop(child['children']) }}
</ul>
{%- endif %}
</li>
{%- endfor %}
</ul>
</li>
</ul>
</div>
</div>
{% endblock %}
Here's the final result
Related
I am trying to create a webapp where, the data comes from a certain API and is saved into the database. Now, I want to create a pdf using the data. I had my html Code ready with custom css and bootstrap ( using display: flex; ). I already tried using the xhtml2pdf, reportlab libraries but am not able to get it right with CSS flex properties.
The source for the HTML, and some python file are attached below.
HTML File:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Invoice-ID</title>
<style type="text/css">
/* Bootstrap CSS */
.col-md-7 {
flex: 0 0 auto;
width: 58%;
}
.container {
width: 1320px;
}
.bg-light {
background-color: #f8f9fa !important;
}
.nav {
display: flex;
flex-wrap: wrap;
padding-left: 0;
margin-bottom: 0;
list-style: none;
}
.justify-content-center {
justify-content: center;
}
.navbar {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
padding-top: .5rem;
padding-bottom: .5rem;
}
.navbar>.container-fluid {
display: flex;
flex-wrap: inherit;
align-items: center;
justify-content: space-between;
}
.navbar-light .navbar-brand {
color: rgba(0, 0, 0, .9);
}
.navbar-brand {
padding-top: .3125rem;
padding-bottom: .3125rem;
margin-right: 1rem;
font-size: 1.25rem;
text-decoration: none;
white-space: nowrap;
}
.flex-column {
flex-direction: column !important;
}
.d-flex {
display: flex !important;
}
.w-50 {
width: 50% !important;
}
.ms-2 {
margin-left: .5rem !important;
}
.p-3 {
padding: 1rem !important;
}
/* Custom CSS */
body {
font-weight: 300;
font-size: 14px;
}
.wrapper {
border: 2px solid gray;
border-width: 2px;
}
#location {
/* border: 2px solid gray; */
border-right: 1px solid gray;
border-width: 1px;
margin-bottom: 2rem;
}
.header {
font-size: 20px;
font-weight: 100;
text-align: center;
color: #007cae;
}
.title {
font-size: 22px;
font-weight: 100;
padding: 10px 20px 0px 20px;
}
.title span {
color: #007cae;
}
.details {
padding: 10px 20px 0px 20px;
text-align: left !important;
}
/* . {
margin-left: 455px;
} */
.hritem {
border: 1px solid gray;
border-width: 2px;
}
</style>
</head>
<body>
<div class="mt-5 container" style="border: 2px solid gray;">
<!-- Header Start -->
<div class="d-flex justify-content-center align-items-center">
<!-- <img src="E:\Python\Django web\logiswift\Deployment\main\static\assets\logo.png" alt="Logo" width="350px"> -->
<h1>LOGO</h1>
<div class="ms-auto">
<span><b>Some Text</b></span>
</div>
</div>
<hr class="hritem"/>
<div class="d-flex justify-content-center align-items-center">
<h3>Title</h3>
<div class="ms-auto ">
<p>Date: 12-12-2021</p>
<p>Document ID: 9868</p>
</div>
</div>
<!-- Header End -->
<hr class="hritem"/>
<!-- General Trip Info Start -->
<div class="d-flex">
<div class="w-50" id="location">
<p>
<h6>Current Location</h6>
<span>Address Line 1,</span>
<span>Address Line 2,</span>
<span>City,</span>
<span>State - PIN</span>
</p>
<p>
<h6>Expected Location</h6>
<span>Address Line 1,</span>
<span>Address Line 2,</span>
<span>City,</span>
<span>State - PIN</span>
</p>
</div>
<div class="w-50 ms-2 mt-3" id="consumer">
<h6>consumer Details</h6>
<hr/>
<p>
<span style="font-size: medium; font-weight: 400;"><b>Name: </b></span>
<span>Your Name</span>
</p>
<p>
<span style="font-size: medium; font-weight: 400;"><b>Consumer ID: </b></span>
<span>Unique Consumer ID</span>
</p>
</div>
</div>
<!-- General Trip Info End -->
<hr class="hritem"/>
<!-- Bill Start -->
<!-- <div>
<p>Bill Will Come here</p>
</div> -->
<!-- Bill End -->
<!-- <hr class="hritem"/> -->
<!-- Footer Start -->
<!-- <div>
<p>Additional info like address of the company and seal comes here.</p>
</div> -->
<!-- Footer end -->
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>
utils.py
from io import BytesIO
from django.http import HttpResponse
from django.template.loader import get_template
from xhtml2pdf import pisa
def render_to_pdf(template_src, context_dict={}):
template = get_template(template_src)
html = template.render(context_dict)
result = BytesIO()
pdf = pisa.pisaDocument(BytesIO(html.encode("UTF-8")), result)
if not pdf.err:
return HttpResponse(result.getvalue(), content_type='application/pdf')
return None
view.py
def generatePDF(request):
template = get_template('main/invoices.html')
context = {
"date": datetime.date.today(),
}
html = template.render(context)
pdf = render_to_pdf('main/invoices.html', context)
return HttpResponse(pdf, content_type="application/pdf")
I don't understand why the above code isn't rendering the CSS flex attributes. I even tried to use the bootstrap classes inside the style tag, but the CSS flex won't come on rendering the PDF.
Please help me out.
Thanks in advance
I am building a website using flask-python, css, HTML.
I am not able to get transparent dropdown menu i changed the styling for css code and given proper code to HTML Layout.
The dropdown occurs in the center without any styling which i had speified in CSS styling
If i write the code in only in HTMl and CSS for dropdown menu.The drop down menu works perfectly fine.
Main python Script
from flask import Flask,render_template
import os
from flask import send_from_directory
app = Flask(__name__)
#app.route('/')
def home():
return render_template("home.html")
#app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico', mimetype='image/vnd.microsoft.icon')
#app.route('/projects/')
def projects():
return render_template("projects.html")
if __name__ == "__main__":
app.run(debug = True)
layout code layout.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<body>
<head>
<meta charset="utf-8">
<title>Developer | Krishan</title>
<link rel = "stylesheet" href ="{{ url_for('static' , filename = 'css/main.css') }}">
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
</head>
<header>
<div class="container">
<h1 class = "logo">Krishan K B's Webpage</h1>
<strong><nav>
<ul class = "menu">
<li>Home</li>
<li>Projects
<ul class = "menu">
<li><a>Disaster Managment</a></li>
<li><a>Data Analytics</a></li>
<li><a>Volcanoes & Population</a></li>
<li><a>Games</a></li>
<li><a>Book App</a></li>
</ul>
</li>
</ul>
</nav></strong>
</div>
</header>
<div class = "container">
{%block content%}
{%endblock%}
</div>
</body>
</html>
Style css code style.css
body{
margin: 0 auto;
text-align: center;
font-family: brandon-grotesque,HelveticaNeue-Light,"Helvetica Neue Light","Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;
}
ul {
margin: 0px;
padding: 0px;
list-style : none;
}
ul li {
float : left;
width : 200px;
height : 40px;
background-color: #020202;
opacity : .8;
line-height: 40px;
text-align: center;
font-size: 20px;
margin-right: 2px;
}
ul li a {
text-decoration: none;
color : white;
display: block;
}
ul li a:hover {
background-color: green;
}
ul li ul li {
display: none;
}
ul li:hover ul li {
display: block;
}
h1{
text-align: center;
font-family: 'Yellowtail', cursive;
color: #e46922;
margin: 50px auto 0 auto;
font-size:60px;
}
h2{
color:#66bfbf;
text-align: center;
font-family:'monntserrat',sans-serif;
padding-bottom: 10px;
}
h3{
color: #11999e;
font-family:'monntserrat',sans-serif;
}
p{
line-height: 2;
width: 40%;
margin: 40px auto 60px;
}
hr{
border: dotted #eaf6f6 6px;
border-bottom: none;
width: 6%;
margin: 100px auto;
}
a{
color: #80b838;
font-family:'monntserrat',sans-serif;
margin: 10px 20px;
text-decoration: none;
}
a:hover{
color: #eaf6f6;
}
.head{
color: #66bfbf;
font-size: 140%;
}
.top{
background-color: #E4F9F5;
position: relative;
padding-top: 100px;
}
.middle{
margin: 100px 0;
}
.bottom{
background-color: #66bfbf; ;
padding: 50px 0 10px;
}
.intro{
width: 30%;
margin: auto;
}
.top-cloud{
position: absolute;
right: 180px;
top: 30px;
}
.below-cloud{
position: absolute;
left: 150px;
bottom: 230px;
}
.img{
float: left;
margin-left: 320px;
}
.img-code{
float: right;
margin-right: 320px;
}
.skils{
width: 30%;
margin: auto;
}
.copyright{
color: #eaf6f6;
font-size: 0.75rem;
}
.contact-message{
width: 40%;
margin: 40px auto 60px;
}
.contact{
padding-bottom: 100px;
}
.btn {
margin: 100px;
background: #45b29a;
background-image: -webkit-linear-gradient(top, #45b29a, #45b29a);
background-image: -moz-linear-gradient(top, #45b29a, #45b29a);
background-image: -ms-linear-gradient(top, #45b29a, #45b29a);
background-image: -o-linear-gradient(top, #45b29a, #45b29a);
background-image: linear-gradient(to bottom, #45b29a, #45b29a);
-webkit-border-radius: 6;
-moz-border-radius: 6;
border-radius: 6px;
font-family: Arial;
color: #1b7f69;
font-size: 21px;
padding: 10px 20px 10px 20px;
text-decoration: none;
}
.btn:hover {
background: #45b29a;
background-image: -webkit-linear-gradient(top, #45b29a, #1b7f69);
background-image: -moz-linear-gradient(top, #45b29a, #1b7f69);
background-image: -ms-linear-gradient(top, #45b29a, #1b7f69);
background-image: -o-linear-gradient(top, #45b29a, #1b7f69);
background-image: linear-gradient(to bottom, #45b29a, #1b7f69);
text-decoration: none;
}
Output i received :
enter image description here
I think your css is not properly rendered by flask, you need to hard reload
After this go to developers tool > sources tab , then search for the css file and crosscheck whether it is properly rendered or not.
Thanx i did hard reload and it worked but now i am not able to see the dropdown or any menu in my home page but i can see it in my projects webpage when i type /projects/ with the web address local host on URL. All the css styling changes are working perfectly fine but now there is no options menu in in my HomePage.
This is my homepage with no dropdown or any menu options to go to projects webpage :
enter image description here
This is my projects webpage, in this there is a dropdown and a menu with all the styling.
enter image description here
Homepage Code:
{%extends "layout.html"%}
{%block content%}
<div class = "home">
<div class="top">
<img class="top-cloud" src="{{ url_for('static' , filename = 'images/clo.png') }}" alt="cloud-img" height="200px">
<h1> I'm Krishan.</h1>
<p class="head">A Back End Developer.</p>
<img class="below-cloud" src="{{ url_for('static' , filename = 'images/clo.png') }}" alt="cloud-img" height="200px">
<img src="{{ url_for('static' , filename = 'images/land.svg') }}" alt="mounntains-img" height="350px">
</div>
<div class="middle">
<img class="profile" src="{{ url_for('static' , filename = 'images/profile.png') }}" alt="profile" height="150px" >
<h2>Hi.</h2>
<P class="intro"> I'm a Programme developer,web developer and designer,UI Designer based in Bangalore,India.I have a passion for web app,data analytics,web design,data analytics and coding and love to create new apps,website for web and mobile devices.</P>
</div>
<hr>
<div>
<h2>What I can do.</h2>
<img class="img" src="{{ url_for('static' , filename = 'images/coding.png') }}" alt="" height="150px" >
<p>I like to keep it simple. My goals is to develop a new programme which would be beneficial for the people and be enviromen friendly.</p>
</div>
<hr>
<div class="skill">
<h2>Develop what you need.</h2>
<img class="img-code" src="{{ url_for('static' , filename = 'images/code-img.png') }}" alt="" height="150px" >
<p class="skills">I'm a developer, so I know how to create your website,application or any other programme to run across devices using the latest technologies available.</p>
</div>
<hr>
<div class="contact">
<h2>Get in touch.</h2>
<h3>I’m currently available for freelance work.</h3>
<p class="contact-message">if you have a project that you want to get started, think you need my help with something or just fancy saying hey, then get in touch.</p>
<a class="btn" href="mailto:krishankbhushan#gmail.com">message me</a>
</div>
</div>
<div class="bottom">
<a class="footer-link" href="https://www.linkedin.com/in/krishan-k-b-0a164b125/">Linkedin</a><i class="fab fa-twitter"></i>
<a class="fab fa-twitter" href=" https://twitter.com/krishankbhushan"><i class="fa fa-twitter"></i>Twitter</a>
<i class="fa fa-twitter" style="font-size:24px"></i>
<p class="copyright">©️ 2021 Krishan.All rights reserved.</p>
</div>
</div>
{%endblock%}
So I am at the last couple details of my portfolio website, and everything has gone relatively smoothly. I have not had an issue with images before, but this time I am using a {% for loop %} to iterate over the code for the card and I just have the variable template tags that create a new object every time I add something new in the django admin interface.
I feel like there is some small detail I am just completely missing, because I had it working at one point, but then decided to do the iteration instead of hard-coding it in, and it just won't show up. Another pair of eyes would be nice.
This is the section of my index.html:
{% block content %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Jordan Miracle</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/portfolio/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<body>
<div class="jumbotron text-center ui-datepicker-next-hover" style="margin-bottom:0">
<div class="align-center">
<img src="{% static 'portfolio/mylogo.png' %}" id="img-bastet" class="img-fluid"
alt="Jordan and Bastet">
</div>
<h1><p style="font-family: 'Ubuntu Mono', Monospaced, monospace; font-size: medium;">Developer and Aspirant Data
Scientist</p>
</div>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<a class="navbar-brand" href="{% url 'home' %}">Home</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="https://github.com/jordanmiracle">Github</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://twitter.com/jordanmiracle1">Twitter</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.linkedin.com/in/jordan-m-605b4b1a9/">LinkedIn</a>
</div>
<div class="topnav-right">
Blog
</nav>
<div class="container" style="margin-top:30px">
<div class="row">
<h2>About Me</h2>
<div class="row justify-content-center my-3">
<div class="col-5" style="border: #303030" aria-setsize="10px">
<img src="{% static 'portfolio/me-bastet-and-babys-turtle.jpg' %}" class="img-fluid"
alt="Jordan and Bastet">
</div>
</div>
<div class="intro-text">
<p style="font-family: 'Ubuntu Mono', Monospaced, monospace; font-size: small; ">
<p>I enjoy web development, and have a true love for analyzing data. Whether creating visualizations and
interpreting what I find,<br>
or creating a machine learning model to try and make predictions. <br>
Things that interest me the most are the climate and our ecosystem, consciousness, and the cosmos that we live
in.
</p>
</div>
<ul class="nav nav-pills flex-column">
<div class="button-row-main">
<button class="nav-button highlight-green">
<a href="mailto:jordanmiracle#protonmail.com" target="_blank">Contact
Me</a>
</button>
</div>
<div class="portfolio">
{% for project in projects %}
<div class="project">
<h2>{{ project.title }}</h2>
<p class="technologies">
</p>
<!-- Depending on availability, display either the image as a link,
only image, or a string explaining that the img is missing-->
{% if project.image %}
<a href="{{ project.url }}" target="_blank">
<div class="img-container" style="background-image: url('{{ project.image }}')"></div>
</a>
<p>{{ project.description }}
</p><br>
<div class="project-links">
Live Site
Code
</div>
{% endif %}
</div>
{% endfor %}
</body>
{% endblock %}
</html>
My style.css:
font-family: 'Oswald', sans-serif;
text-align: center;
background-color: #00FF00;
color: #303030;
}
/* ---------- HOME ---------- */
/* create color-hover-effect for M logo and buttons */
.highlight-orange:hover {
color: #417FD5;
border-color: #ffa000;
}
.highlight-green:hover {
color: darkred;
border-color: indianred;
}
button a {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
text-decoration: darkslateblue;
color: inherit;
/* increase the clickable area */
display: inline-block;
position: relative;
z-index: 1;
padding: 1.3em;
margin: -1.3em;
}
.nav-button {
font-size: 1.1em;
margin: 20px;
padding: 10px;
border: 2px solid #303030;
border-radius: 25px;
color: #303030;
background-color: #fdfdfd;
box-shadow: #417FD5;
}
.button-row-mobile,
.button-row-portfolio-mobile {
display: none;
}
/* ---------- PORTFOLIO ---------- */
.portfolio {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
.project {
margin: 20px;
padding: 20px;
border: 3px solid #303030;
border-radius: 20px;
color: transparent;
background-color: transparent;
max-width: 300px;
}
.project-links {
display: flex;
justify-content: space-around;
}
.project-links a {
color: #4DAAE3;
}
.project-links a:visited {
color: #ffffff;
}
.project-links a:hover {
color: #4DAAE3;
}
.button-row-portfolio {
position: fixed;
width: 100%;
justify-content: space-between;
bottom: 5px;
}
.button-row-portfolio .nav-button {
opacity: 0.8;
}
/*
restrict img to uniform size automatically,
while showing the center portion of the screenshot. adapted from:
https://stackoverflow.com/questions/15866223/how-to-make-images-get-cut-off
*/
.img-container {
height: 200px;
width: 250px;
color: transparent;
background-position: center;
border: 1px solid #303030;
border-radius: 20px;
background-repeat: no-repeat;
}
/* ---------- FOOTER ---------- */
.separator {
display: none;
}
#footer {
position : absolute;
bottom : 0;
height : 40px;
margin-top : 40px;
}
footer {
font-size: 16px;
color: #303030;
}
.site-footer {
padding-left: 40px;
padding-right: 40px;
padding-top: 15px;
padding-bottom: 5px;
background-color: #aa2222;
color: white;
font-style: italic;
text-align: center;
}
.icon {
height: 36px;
width: auto;
padding: 8px;
}
.overflow {
color: #fdfdfd;
font-size: 2.5em;
}
/* ---------- RESPONSIVE ELEMENTS ---------- */
/* TODO: remove blue highlighting when buttons are clicked */
#media only screen and (max-width: 768px) {
.logo {
font-size: 14em;
}
.button-row-main,
.button-row-portfolio {
display: none;
}
.button-row-mobile {
margin-top: 50px;
margin-bottom: 50px;
display: flex;
justify-content: space-around;
}
.button-row-portfolio-mobile {
display: flex;
position: fixed;
width: 100%;
justify-content: space-around;
bottom: 5px;
}
.button-row-portfolio-mobile .nav-mobile {
opacity: 0.8;
}
.nav-mobile {
font-family: 'Oswald', sans-serif;
font-size: 1em;
border: none;
border-radius: 100px;
background-color: #fdfdfd;
}
.highlight-orange {
color: #4DAAE3;
border-color: #4DAAE3;
fill: #4DAAE3;
}
.highlight-green {
color: lightgreen;
border-color: lightgreen;
fill: lightgreen;
}
.highlight-blue {
color: lightblue;
border-color: lightblue;
fill: lightblue;
}
.separator {
display: block;
}
footer {
margin-top: 24px;
}
.icon {
height: 45px;
width: auto;
padding: 20px;
}
}
* {
box-sizing: border-box;
}
body {
background-color: #f1f1f1;
padding: 20px;
font-family: "Ubuntu Mono", serif;
}
/* Center website */
.main {
max-width: 1000px;
margin: auto;
}
h1 {
font-size: 50px;
word-break: break-all;
}
.row {
margin: 8px -16px;
}
/* Add padding BETWEEN each column (if you want) */
.row,
.row > .column {
padding: 8px;
}
/* Create four equal columns that floats next to each other */
.column {
float: left;
width: 25%;
}
/* Clear floats after rows */
.row:after {
content: "";
display: table;
clear: both;
}
/* Content */
.content {
background-color: white;
padding: 10px;
}
/* Responsive layout - makes a two column-layout instead of four columns */
#media screen and (max-width: 900px) {
.column {
width: 75%;
}
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width: 100%;
}
}
My models.py:
class Project(models.Model):
title = models.CharField(max_length=100)
description = models.CharField(max_length=120)
image = models.FilePathField(path='portfolio/images')
url = models.URLField(blank=True)
code_url = models.URLField(blank=True)
def __str__(self):
return self.title
Here is my file structure.
If anybody needs more information, or if I need to provide more details, just let me know. This is the last thing really standing in my way of deploying and it's been a pain.
Before changing it to img class
After changing it from a div class to img class
The images needed to be registered properly in the Django admin shell.
Once in the shell, I had to import the models.
from portfolio.models import Project
Then, p2 = Project.objects.get(id=2)
p2.image = <path_to_file>
And so on. Once they were registered in the DB, they popped up right away.
Looks like you might need to set a background image size on .img-container. If that doesn't work, also try setting display: block;
.img-container {
height: 200px;
width: 250px;
color: transparent;
background-position: center;
border: 1px solid #303030;
border-radius: 20px;
background-repeat: no-repeat;
background-size: cover;
display: block;
}
This question already has answers here:
CSS selector for reCAPTCHA checkbok using Selenium and VBA Excel
(1 answer)
Find the reCAPTCHA element and click on it -- Python + Selenium
(2 answers)
How to click on the reCAPTCHA using Selenium and Java
(5 answers)
Closed 3 years ago.
I am trying to switch to iframe in captcha, but I get this error
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: The result of the xpath expression "//iframe" is: [object HTMLIFrameElement]. It should be an element.
I tryed with switcing to Iiframe, but it doesnt work, I find iframe with inspecting element, but I can not find element when I run the script, also I added explicit wait, time sleep, but it still doesn't work
here is html code
<html lang="en"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Access to this page has been denied.</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300" rel="stylesheet">
<style>
html, body {
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
color: #000;
}
a {
color: #c5c5c5;
text-decoration: none;
}
.container {
align-items: center;
display: flex;
flex: 1;
justify-content: space-between;
flex-direction: column;
height: 100%;
}
.container > div {
width: 100%;
display: flex;
justify-content: center;
}
.container > div > div {
display: flex;
width: 80%;
}
.customer-logo-wrapper {
padding-top: 2rem;
flex-grow: 0;
background-color: #fff;
visibility: hidden;
}
.customer-logo {
border-bottom: 1px solid #000;
}
.customer-logo > img {
padding-bottom: 1rem;
max-height: 50px;
max-width: 100%;
}
.page-title-wrapper {
flex-grow: 2;
}
.page-title {
flex-direction: column-reverse;
}
.content-wrapper {
flex-grow: 5;
}
.content {
flex-direction: column;
}
.page-footer-wrapper {
align-items: center;
flex-grow: 0.2;
background-color: #000;
color: #c5c5c5;
font-size: 70%;
}
#media (min-width: 768px) {
html, body {
height: 100%;
}
}
</style>
<script src="/rw7M6iAV/captcha/PXrw7M6iAV/captcha.js?a=c&m=0&u=266c5db0-19e6-11ea-8150-878a39a29362&v="></script><style type="text/css">.px-loader-wrapper { display: flex;}#keyframes loadingEffect { 0% { background-position: 0; } 100% { background-position: 60vw; }}.px-inner-loading-area { width: 310px; height: 30px; animation-name: loadingEffect; animation-duration: 1.2s; animation-iteration-count: infinite; animation-timing-function: ease; animation-fill-mode: forwards; background: linear-gradient(to right, #F6F6F6 8%, #F0F0F0 18%, #F6F6F6 33%);}.px-loading-area { width: 310px; height: 30px; margin: 0; ;}</style><script src="/rw7M6iAV/init.js"></script><a tabindex="-1" aria-hidden="true" href="/organization/waldeck-associates?_pxhc=1575828688573" rel="nofollow" target="_blank" style="width: 0px; height: 0px; font-size: 0px; line-height: 0;"></a></head>
<body>
<section class="container">
<div class="customer-logo-wrapper">
<div class="customer-logo">
<img src="" alt="Logo">
</div>
</div>
<div class="page-title-wrapper">
<div class="page-title">
<h1>Please verify you are a human</h1>
</div>
</div>
<div class="content-wrapper">
<div class="content">
<div id="px-captcha" role="main"><style>#media screen and (max-width: 350px) {
#px-captcha {
position: relative;
right: 32px;
}
}</style><iframe style="display: block; width: 310px; height: 100px; border: 0; padding:0; margin: 0; -moz-user-select: none;-khtml-user-select: none;-webkit-user-select: none;-ms-user-select: none;user-select: none;" token="efbbf8834a03575dcd9c41ce37a32800bac150d7be5c1b3bf3a953f0879cfc3caa53da776440a3d731e03394daec916c92fe9416ba7947d3cea7370b970a551d"></iframe></div>
<p>
Access to this page has been denied because we believe you are using automation tools to browse the
website.
</p>
<p>
This may happen as a result of the following:
</p>
<ul>
<li>
Javascript is disabled or blocked by an extension (ad blockers for example)
</li>
<li>
Your browser does not support cookies
</li>
</ul>
<p>
Please make sure that Javascript and cookies are enabled on your browser and that you are not blocking
them from loading.
</p>
<p>
Reference ID: #266c5db0-19e6-11ea-8150-878a39a29362
</p>
<div id="px-block-form-wrapper"><div><style>#px-block-form-wrapper{width:400px;position:absolute;bottom:0;left:calc(50% - 200px)}#px-block-toggle-button{height:20px;background:#fff;color:#000;border-radius:3px;padding:10px;cursor:pointer;font-size:13px;text-align:center;width:270px;border:1px solid #000;font-weight:900;margin-left:75px;text-decoration:underline}#px-block-form{background:#fff;border:1px solid;border-color:#404040;color:#000;border-radius:3px;height:265px;font-size:12px}button#px-form-close{float:right;background:0 0;border:none;color:#fff;font-size:18px;cursor:pointer}button#px-form-submit{position:absolute;bottom:10px;background:#404040;border:none;width:100px;border-radius:3px;height:25px;color:#fff;right:20px;cursor:pointer}button#px-form-submit:disabled{background:#ddd;cursor:not-allowed;color:#000}div#px-form{color:#000;padding:15px}div#px-form-head{padding:10px;font-size:14px;background:#404040;color:#fff}div#px-form textarea{margin:-5px 0 0 4px;width:300px;height:36px}div#px-form div{margin-bottom:6px}#px-form-thank-you{background:#fff;color:#000;border:1px solid;border-color:#404040;border-radius:3px;height:54px;padding:5px 10px;text-align:center;width:330px;margin-left:35px}#px-form-thank-you div{font-size:15px;margin-top:14px}#px-form-thank-you span.checkmark{margin-right:8px;color:green;font-size:20px}div#px-form form h4{margin:8px 4px}#media only screen and (orientation:portrait){#px-block-form-wrapper{width:97%;position:relative;left:3%;z-index:10}#px-block-toggle-button{height:20px;background:#fff;color:#000;padding:3px;cursor:pointer;font-size:13px;text-align:center;width:94%;border:none;font-weight:900;text-decoration:underline;margin-left:0;position:fixed;bottom:5px;right:10px;width:initial}#px-block-form{background:#fff;border:1px solid;border-color:#404040;color:#000;border-radius:3px;height:250px;font-size:12px}button#px-form-close{float:right;background:0 0;border:none;color:#fff;font-size:18px;cursor:pointer;position:absolute;right:15px;padding:0;bottom:6px}button#px-form-submit{position:absolute;bottom:10px;background:#404040;border:none;width:100px;border-radius:3px;height:25px;color:#fff;right:20px;cursor:pointer;font-size:13px}button#px-form-submit:disabled{background:#ddd;cursor:not-allowed;color:#000}div#px-form{color:#000;padding:15px}div#px-form-head{padding:10px;font-size:14px;background:#404040;color:#fff;position:relative}div#px-form textarea{margin:-5px 0 0 4px;width:90%;height:36px}div#px-form div{margin-bottom:6px}#px-form-thank-you{background:#fff;color:#000;border:1px solid;border-color:#404040;border-radius:3px;height:54px;padding:5px 10px;text-align:center;width:94%;margin-left:0}#px-form-thank-you div{font-size:15px;margin-top:14px}#px-form-thank-you span.checkmark{margin-right:8px;color:green;font-size:20px}div#px-form form h4{margin:8px 4px}.container{display:block;position:relative}.container .content-wrapper{padding-bottom:40px}.container .page-footer-wrapper{position:fixed;bottom:0}.container .content-wrapper .content{margin:0 auto}}</style><div id="px-block-toggle-button" onclick="_pxToggleOpenForm()" hidden="">Report an issue</div><div id="px-block-form"><div id="px-form-head"><span>Experiencing issues? Let us know:</span> <button onclick="_pxToggleOpenForm(!0)" id="px-form-close">X</button></div><div id="px-form"><form><div style="display:none"><input onchange="_pxItemSelected()" type="radio" id="opt0" name="px-report-reason" value="-1"> <label for="opt0">I’m a bot</label></div><div><input onchange="_pxItemSelected()" type="radio" id="opt1" name="px-report-reason" value="1"> <label for="opt1">I don’t see any challenge</label></div><div><input onchange="_pxItemSelected()" type="radio" id="opt2" name="px-report-reason" value="2"> <label for="opt2">I keep solving the challenge</label></div><div><input onchange="_pxItemSelected()" type="radio" id="opt3" name="px-report-reason" value="3"> <label for="opt3">Other (please elaborate)</label></div><h4>Additional Information:</h4><textarea id="px-form-free-text" placeholder="Experiencing other issues?"></textarea></form><button disabled="disabled" id="px-form-submit" onclick="_pxSubmitForm()">Send</button></div></div><div hidden="" id="px-form-thank-you"><div><span class="checkmark">✓</span><span>Thank you for the feedback</span></div></div></div></div></div>
</div>
<div class="page-footer-wrapper">
<div class="page-footer">
<p>
Powered by
PerimeterX
, Inc.
</p>
</div>
</div>
</section>
<script>
window._pxAppId = 'PXrw7M6iAV';
window._pxJsClientSrc = '/rw7M6iAV/init.js';
window._pxFirstPartyEnabled = true;
window._pxVid = '';
window._pxUuid = '266c5db0-19e6-11ea-8150-878a39a29362';
window._pxHostUrl = '/rw7M6iAV/xhr';
</script>
<script>
var s = document.createElement('script');
s.src = '/rw7M6iAV/captcha/PXrw7M6iAV/captcha.js?a=c&m=0&u=266c5db0-19e6-11ea-8150-878a39a29362&v=';
var p = document.getElementsByTagName('head')[0];
p.insertBefore(s, null);
if (true) {
s.onerror = function () {
s = document.createElement('script');
var suffixIndex = '/rw7M6iAV/captcha/PXrw7M6iAV/captcha.js?a=c&m=0&u=266c5db0-19e6-11ea-8150-878a39a29362&v='.indexOf('captcha.js');
var temperedBlockScript = '/rw7M6iAV/captcha/PXrw7M6iAV/captcha.js?a=c&m=0&u=266c5db0-19e6-11ea-8150-878a39a29362&v='.substring(suffixIndex);
s.src = '//captcha.px-cdn.net/PXrw7M6iAV/' + temperedBlockScript;
p.parentNode.insertBefore(s, p);
};
}
</script>
</body></html>
The exception itself says that the selector is incorrect. Try to use absolute xpath while selecting the iFrame. Absolute xpath for captcha iframe always works for me.
Also it woulbe be great if you can share your automation code
I am making a blog with django but when I try to align them next to each other,
they appear under each other.
the posts appear under each other.
how can i make them horizontally aligned.
here is my html:
{% extends "blog/base.html" %}
{% load blog_tags %}
{% block content %}
<div class="mdl-layout mdl-js-layout ">
{% for post in posts %}
<main class="mdl-layout__content">
<div class="mdl-grid ">
<div class="mdl-card mdl-cell mdl-cell--6-col mdl-cell--4-col mdl-shadow--2dp">
<figure class="mdl-card__media">
<img src="{{ post.photo }}" alt="" />
</figure>
<div class="mdl-card__title">
<h1 class="mdl-card__title-text">{{ post.title }}</h1>
</div>
<div class="mdl-card__supporting-text">
<p>{{ post.body|truncatewords:11 }}</p>
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect kal" href="{{ post.get_absolute_url }}">Read More</a>
<div class="mdl-layout-spacer"></div>
<button class="mdl-button mdl-button--icon mdl-button--colored kal"><i class="material-icons">favorite</i></button>
<button class="mdl-button mdl-button--icon mdl-button--colored kal"><i class="material-icons">share</i></button>
</div>
</div>
{% endfor %}
</div>
</div>
</main>
</div>
{% endblock %}
css file:
I think the problem is with this css file but i had trouble finding it
css file:
I think the problem is with this css file but i had trouble finding itcss file:
I think the problem is with this css file but i had trouble finding itcss file:
I think the problem is with this css file but i had trouble finding itcss file:
I think the problem is with this css file but i had trouble finding itcss file:
I think the problem is with this css file but i had trouble finding it
body{
background: white;
}
.mdl-grid {
max-width: 600px;
}
.mdl-card__media {
margin: 0;
}
.mdl-card__media > img {
max-width: 100%;
}
.mdl-card__actions {
display: flex;
box-sizing:border-box;
align-items: center;
}
.mdl-card__actions > .mdl-button--icon {
margin-right: 3px;
margin-left: 3px;
}
.kal:hover{
text-decoration: none;
}
.main{
font-family: 'Bungee', cursive;
font-size: 600%;
color: white;
border: None;
position: absolute;
bottom: 9%;
left: 6%;
}
.skills{
position: absolute;
bottom: 5%;
left: 6%;
color: white;
}
.iff{
position: absolute;
bottom: 9%;
right: 9%;
}
.ten{
color: black;
background: white;
font-size: 300%;
border-radius: 300px;
margin: 10px;
padding: 30px;
}
.navbar{
border-radius: 0px !important;
background: transparent;
width: 100% !important;
border: None !important;
font-family: 'Josefin Sans', sans-serif;
position: fixed !important;
width: 100%;
z-index: 1 !important;
}
.nad{
font-size: 120% !important;
}
li:hover{
font-weight: bold;
background: white;
}
.navbar-brand{
font-family: 'Josefin Sans', sans-serif;
font-weight: bold;
font-size-adjust: auto;
font-size: 200% !important;
color: black !important;
}
header{
background: url("https://wp-themes.com/wp-content/themes/twentyseventeen/assets/images/header.jpg");
background-attachment: fixed;
height: 100vh;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
.tn{
background: white;
border-radius: 250px;
color: black;
}
.main1{
font-family: 'Sedgwick Ave Display', cursive;
}
.tab{
font-family: 'Abril Fatface', cursive;
}
.tab12{
font-family: 'Abril Fatface', cursive;
}