forms forms forms
This commit is contained in:
parent
3d09d355eb
commit
789b9a1dc0
13 changed files with 71 additions and 100 deletions
|
@ -13,15 +13,7 @@
|
|||
|
||||
<form class="review-form" name="review" action="/review/" method="post">
|
||||
<input type="hidden" name="book" value="{{ book.openlibrary_key }}"></input>
|
||||
<label for="name">Title:
|
||||
<input type="text" name="name"></input>
|
||||
</label>
|
||||
<label for="content">
|
||||
<textarea name="content"></textarea>
|
||||
</label>
|
||||
<label for="rating">Your rating (1-5)
|
||||
<input type="number" name="rating"></input>
|
||||
</label>
|
||||
{{ review_form.as_p }}
|
||||
<button type="submit">Post review</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -2,51 +2,13 @@
|
|||
{% block content %}
|
||||
<div id="content">
|
||||
<div class="user-profile">
|
||||
<h1>{% if user.localname %}{{ user.localname }}{% else %}{{ user.username }}{% endif %}</h1>
|
||||
<img class="user-pic" src="/static/images/profile.jpg">
|
||||
<form name="avatar" action="/upload-avatar/" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="avatar">
|
||||
<form name="avatar" action="/edit_profile/" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit">Upload</button>
|
||||
</form>
|
||||
<h1>{% if user.localname %}{{ user.localname }}{% else %}{{ user.username }}{% endif %}</h1>
|
||||
{% if is_self %}<a href="/user/{{ user.localname }}/edit">Edit profile</a>
|
||||
<p>Since {{ user.created_date }}</p>
|
||||
{% endif %}
|
||||
{% if not is_self %}
|
||||
{% if not following %}
|
||||
<form action="/follow/" method="post">
|
||||
<input type="hidden" name="user" value="{{ user.id }}"></input>
|
||||
<input type="submit" value="Follow"></input>
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="/unfollow/" method="post">
|
||||
<input type="hidden" name="user" value="{{ user.id }}"></input>
|
||||
<input type="submit" value="Unfollow"></input>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>Books</h2>
|
||||
{% for book in books.all %}
|
||||
<div class="book">
|
||||
{{ book.data.title }} by {{ book.authors.first.data.name }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>Followers</h2>
|
||||
{% for follower in user.followers.all %}
|
||||
<div>
|
||||
<a href="{{ follower.actor }}">{{ follower.username }}</a>
|
||||
<form action="/follow/" method="post">
|
||||
<input type="hidden" name="user" value="{{ follower.id }}"></input>
|
||||
<input type="submit" value="Follow"></input>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
{% for activity in activities %}
|
||||
<div class="update">
|
||||
<h2>
|
||||
<img class="user-pic" src="static/images/profile.jpg">
|
||||
<img class="user-pic" src="{% if activity.user.avatar %}/images/{{ activity.user.avatar }}{% else %}/static/images/default_avi.jpg{% endif %}">
|
||||
{# TODO: a helper function for displaying a username #}
|
||||
<a href="/user/{% if activity.user.localname %}{{ activity.user.localname }}{% else %}{{ activity.user.username }}{% endif %}" class="user">
|
||||
{% if activity.user.localname %}{{ activity.user.localname }}{% else %}{{ activity.user.username }}{% endif %}</a>
|
||||
|
|
|
@ -27,20 +27,21 @@
|
|||
<div id="account">
|
||||
{% if user.is_authenticated %}
|
||||
<form name="logout" action="/logout/" method="post">
|
||||
Welcome, {% if request.user.localname %}{{ request.user.localname }}{% else %}{{ request.user.username }}{% endif %}
|
||||
Welcome, <a href="{{ request.user.actor }}">{% if request.user.localname %}{{ request.user.localname }}{% else %}{{ request.user.username }}{% endif %}</a>
|
||||
<input type="submit" value="Log out"></input>
|
||||
</form>
|
||||
{% else %}
|
||||
<form name="login" action="/login/" method="post">
|
||||
<input type="text" name="username"></input>
|
||||
<input type="password" name="password"></input>
|
||||
{% for field in login_form %}
|
||||
{{ field }}
|
||||
{% endfor %}
|
||||
<input type="submit" value="Log in"></input>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="search">
|
||||
<form action="/search/">
|
||||
<input type="text" name="q"></input>
|
||||
<input type="text" name="q" placeholder="search"></input>
|
||||
<input type="submit" value="🔍"></input>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -3,13 +3,7 @@
|
|||
<div id="content">
|
||||
<div>
|
||||
<form name="login" method="post">
|
||||
<label for="username">Username:
|
||||
<input type="text" name="username"></input>
|
||||
</label>
|
||||
|
||||
<label for="password">Password:
|
||||
<input type="password" name="password"></input>
|
||||
</label>
|
||||
{{ login_form.as_p }}
|
||||
<button type="submit">Log in</button>
|
||||
</form>
|
||||
<a href="/register/">Create a new account</a>
|
||||
|
|
|
@ -3,17 +3,7 @@
|
|||
<div id="content">
|
||||
<div>
|
||||
<form name="register" method="post">
|
||||
<label for="username">Username:
|
||||
<input type="text" name="username"></input>
|
||||
</label>
|
||||
|
||||
<label for="email">Email address:
|
||||
<input type="text" name="email"></input>
|
||||
</label>
|
||||
|
||||
<label for="password">Password:
|
||||
<input type="password" name="password"></input>
|
||||
</label>
|
||||
{{ register_form.as_p }}
|
||||
<button type="submit">Create account</button>
|
||||
</form>
|
||||
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
{% block content %}
|
||||
<div id="content">
|
||||
<div class="user-profile">
|
||||
<img class="user-pic" src="/static/images/profile.jpg">
|
||||
<h1>{% if user.localname %}{{ user.localname }}{% else %}{{ user.username }}{% endif %}</h1>
|
||||
<img class="user-pic" src="{% if user.avatar %}/images/{{ user.avatar }}{% else %}/static/images/default_avi.jpg{% endif %}">
|
||||
<h1>{% if user.name %}{{ user.name }}<br>{% endif %}{% if user.localname %}{{ user.localname }}{% else %}{{ user.username }}{% endif %}</h1>
|
||||
{% if user.summary %}
|
||||
<blockquote>{{ user.summary }}</blockquote>
|
||||
{% endif %}
|
||||
{% if is_self %}<a href="/user/{{ user.localname }}/edit">Edit profile</a>
|
||||
<p>Since {{ user.created_date }}</p>
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue