Skip to content

Commit

Permalink
THE END!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
mariklolik committed Apr 26, 2020
1 parent 8d9c339 commit 5a525ff
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 70 deletions.
Binary file modified __pycache__/acman_api.cpython-37.pyc
Binary file not shown.
Binary file modified __pycache__/stories_api.cpython-37.pyc
Binary file not shown.
48 changes: 29 additions & 19 deletions acman_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ def cabinet():
author = session.query(User).filter(User.id == disf.author.data)
user.followed.remove(author)
session.commit()
user = session.query(User).filter(User.id == current_user.id)
user = session.query(User).filter(User.id == current_user.id).first()
follows = user.followed
return flask.render_template("account.html", follows=follows)
name = user.nickname
return flask.render_template("account.html", follows=follows, name=name)


@blueprint.route("/dashboard", methods=["GET", "POST"]) # панель управления постами и авторской статистикой
Expand All @@ -64,21 +65,30 @@ def dashboard():
@blueprint.route("/author/<int:aid>", methods=["GET", "POST"]) # "визитная карточка" автора
def card(aid):
session = create_session()
author = session.query(User).filter(User.id == aid)
if current_user.is_authenticated:
sub = FollowForm()
if sub.validate_on_submit():
user = session.query(User).filter(User.id == current_user.id)
if author in user.followed:
user.followed.remove(author)
session.commit()
author.followers -= 1
session.commit()
else:
user.followed.append(author)
session.commit()
author.followers += 1
session.commit()
author = session.query(User).filter(User.id == aid).first()
user = session.query(User).filter(User.id == current_user.id).first()
if flask.request.method == 'GET':
if not current_user.is_authenticated:
return flask.redirect("/")
subscribed = author in user.followed
return flask.render_template("card.html", name=author.nickname, fc=author.followers, sub=subscribed)
else:
return flask.redirect("/")
return flask.render_template("card.html", name=author.nickname, fc=author.followers)
req = flask.request.form
if req.get('subscribe-button'):
subscribed = author in user.followed
req = flask.request.form
if req.get('subscribe-button'):

if author in user.followed:
user.followed.remove(author)
session.commit()
author.followers -= 1
session.commit()
else:
user.followed.append(author)
session.commit()
author.followers += 1
session.commit()
return flask.redirect('/feed')

return flask.render_template("card.html", name=author.nickname, fc=author.followers, sub=subscribed)
Binary file modified db/data.sqlite
Binary file not shown.
Binary file modified dbremote/__pycache__/storys.cpython-37.pyc
Binary file not shown.
Binary file modified dbremote/__pycache__/user.cpython-37.pyc
Binary file not shown.
103 changes: 65 additions & 38 deletions static/css/main2.css
Original file line number Diff line number Diff line change
Expand Up @@ -568,68 +568,77 @@ form input {
z-index: 2;
}

a i:hover{
a i:hover {
transition: 0.8s;
color: red;
}


.form__group {
position: relative;
padding: 15px 0 0;
margin-top: 10px;
width: 50%;
position: relative;
padding: 15px 0 0;
margin-top: 10px;
width: 50%;
}

.form__field {
font-family: inherit;
width: 100%;
border: 0;
border-bottom: 2px solid #9b9b9b;
outline: 0;
font-size: 1.3rem;
color: #fff;
padding: 7px 0;
background: transparent;
transition: border-color 0.2s;
font-family: inherit;
width: 100%;
border: 0;
border-bottom: 2px solid #9b9b9b;
outline: 0;
font-size: 1.3rem;
color: #fff;
padding: 7px 0;
background: transparent;
transition: border-color 0.2s;
}

.form__field::placeholder {
color: transparent;
color: transparent;
}

.form__field:placeholder-shown ~ .form__label {
font-size: 1.3rem;
cursor: text;
top: 20px;
font-size: 1.3rem;
cursor: text;
top: 20px;
}

.form__label {
position: absolute;
top: 0;
display: block;
transition: 0.2s;
font-size: 1rem;
color: #9b9b9b;
position: absolute;
top: 0;
display: block;
transition: 0.2s;
font-size: 1rem;
color: #9b9b9b;
}

.form__field:focus {
padding-bottom: 6px;
font-weight: 700;
border-width: 3px;
border-image: linear-gradient(to right, #11998e, #38ef7d);
border-image-slice: 1;
padding-bottom: 6px;
font-weight: 700;
border-width: 3px;
border-image: linear-gradient(to right, #11998e, #38ef7d);
border-image-slice: 1;
}

.form__field:focus ~ .form__label {
position: absolute;
top: 0;
display: block;
transition: 0.2s;
font-size: 1rem;
color: #11998e;
font-weight: 700;
position: absolute;
top: 0;
display: block;
transition: 0.2s;
font-size: 1rem;
color: #11998e;
font-weight: 700;
}

#search-top {
margin-left: 40%;
margin-top:5%;
}


#search-bottom {
margin-left: 40%;
}



Expand Down Expand Up @@ -663,6 +672,15 @@ a i:hover{
margin-bottom: 5%;
font-size: 20px;
}

#search-top {
margin-left: 5%
}

#search-bottom {
margin-left: 5%;
}

}

/* Smartphones (вертикальная) ----------- */
Expand All @@ -681,4 +699,13 @@ a i:hover{
font-size: 20px;

}

#search-top {
margin-left: 5%
}

#search-bottom {
margin-left: 5%;
}

}
26 changes: 18 additions & 8 deletions stories_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ def feed():
stories_for_watching = []
session = create_session()
user = session.query(User).filter(User.id == current_user.id).one()
if flask.request.method == "POST" and flask.request.form.get('accept'): # поисковой движок
results = session.query(Story).filter(Story.head.like(f'%{flask.request.get("search")}%'))
return flask.render_template("search_result.html", res=results)
for i in user.followed:
stories_for_watching += i
if flask.request.method == "POST" and flask.request.form.get('accept'):
search_key = flask.request.form.get("search-input")# поисковой движок
results = session.query(Story).filter(Story.head.like(f'%{search_key}%'))
if results:
return flask.render_template("search_results.html", res=results)
else:
results = session.query(Story).filter(Story.headlike(f"%{search_key[0].upper() + search_key[1:]}%"))
return flask.render_template("search_results.html", res=results)

for i in user.followed.all():
stories_for_watching += i.stories
if not stories_for_watching:
stories_for_watching = session.query(Story).all()
return flask.render_template("feed.html",
Expand All @@ -54,9 +60,11 @@ def story(sid):
header = story.head
name = session.query(User).filter(User.id == story.author_id).first()
can_delete = (current_user.id == story.author_id)
author_link = story.author_id

return flask.render_template("post_template.html", content=content, comments=comments, header=header,
name=name.nickname, likes=story.likes_count, can_delete=can_delete)
name=name.nickname, likes=story.likes_count, can_delete=can_delete,
author_href=author_link)
else:
if not current_user.utype:
content = story.content
Expand All @@ -74,14 +82,16 @@ def story(sid):
if req.get('post-like'):
story.likes_count += 1
session.commit()
return flask.render_template('post_template.html', content=content, comments=comments, header=header,
name=name.nickname, likes=story.likes_count)
else:
req = flask.request.form
if req.get('post-delete'):
session.delete(story)
session.commit()
return flask.redirect('/dashboard')
return flask.render_template('post_template.html', content=content, comments=comments, header=header,
name=name.nickname, likes=story.likes_count)
return flask.redirect(f'/story/{sid}')


@blueprint.route("/post", methods=['GET', 'POST']) # создание истории
def post():
Expand Down
24 changes: 24 additions & 0 deletions templates/account.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "base.html" %}

{% block content %}
<div class="container">
<div class="row">
<div class="col">
<h3 class="post-category">Control your subscribes {{ current_user.nickname }} </h3>

</div>
</div>

{% for follow in follows %}
<div class="row">
<div class="col">
<a href="/author/{{ follow.id }}" class="story-link" style="font-family: 'Lexend Giga', sans-serif; font-size: 20px;">
<h2> {{ follow.nickname }} <i class="fas fa-heart"></i></h2>
</a>
</div>
</div>
{% endfor %}


</div>
{% endblock %}
21 changes: 21 additions & 0 deletions templates/card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends "base.html" %}

{% block content %}

<h3 class="username" style="text-align: center;">{{ name }}</h3>
<h3 class="username" style="text-align: center;">{{ fc }} subscribers</h3>
<form method='post'>
<div class="row">
<div class="col-6" style="justify-content: center; margin: 0 auto;">
{% if not sub %}
<input type="submit" class="btn btn-block btn-primary" name='subscribe-button' value="Subscribe" style="margin:5% 0 5% 0; background-color:orangered;">
{% else %}
<input type="submit" class="btn btn-block btn-primary" name='subscribe-button' value="Unsubscribe" style="margin:5% 0 5% 0;background-color:darkgray;">
{% endif %}
</div>
</div>

</form>


{% endblock %}
13 changes: 13 additions & 0 deletions templates/feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

<!--Carousel Wrapper-->
<form method='post' style="justify-content: center; text-align: center; margin: 0 auto;align-items: center; flex-direction: column;">
<div class="row" id='search-top'>
<div class="col-4 my-auto" style="margin-top: 5%;">
<input type="text" name='search-input' style="border: 3px solid black; margin:0 auto;border-radius: 20px;padding:10px" placeholder="Search posts" required></div>
</div>
<div class="row" id='search-bottom'>
<div class="col-4 my-auto" >
<input type="submit" class="btn btn-block btn-primary" name='accept' value="Search" style="margin:5% 5% 5% 0; border-radius: 20px;">
</div>
</div>

</form>

<div id="carousel-example-1z" class="carousel slide carousel-fade" data-ride="carousel">
<!--Indicators-->
Expand All @@ -29,6 +41,7 @@ <h2>Hello! Let's have a look!</h2>
<!--/First slide-->



{% for story in stories %}
<div class="carousel-item">
<img class="d-block w-100" src="{{ story.cover }}" alt="Second slide">
Expand Down
14 changes: 9 additions & 5 deletions templates/post_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ <h3 class="post-category">{{ header }}</h3>
<div class="author-info">

<!-- <img src="static/img/mariklolik.jpg" alt="LOL" class='author-img'> -->
{% if current_user.utype %}
<span id='name'>Post by : {{ name }}</span>
{% else %}
<a href='/author/{{ author_href }}'id='name'>Post by : {{ name }}</a>
{% endif %}
</div>
</div>
</div>
Expand All @@ -37,15 +41,15 @@ <h3 class="post-category">{{ header }}</h3>
<h3 class="post-category">Your thoughts</h3>

<form method="post">
{% if can_delete %}
<input type="submit" class="btn btn-block btn-primary" name='post-delete' value="Delete post" style="margin:5% 0 5% 0">
{% endif %}
{% if can_delete %}
<input type="submit" class="btn btn-block btn-primary" name='post-delete' value="Delete post" style="margin:5% 0 5% 0">
{% endif %}
<div class="row">
<div class="col-1">
<!-- Post stats -->
<div class="like">
<div class="checkbox-wrapper">
<input type="checkbox" name="post-like"/>
<input type="checkbox" name="post-like" />
<div class="checkbox"><i class="fa fa-check" name='Like'></i></div>
</div>
</div>
Expand All @@ -57,7 +61,7 @@ <h3 class="post-category">Your thoughts</h3>
<div class="row">
<div class="col" style="margin-top: 5%;">
<textarea name="editordata" id="summernote" style='min-height: 30%;'></textarea>
<input type="submit" class="btn btn-block btn-primary" value="I think so!" style="margin-top:4%;">
<input type="submit" class="btn btn-block btn-primary" value="I think so!" style="margin-top:4%;">
</div>
</div>

Expand Down
Loading

0 comments on commit 5a525ff

Please sign in to comment.