Skip to content

Commit

Permalink
always show usage guide
Browse files Browse the repository at this point in the history
  • Loading branch information
vanyakosmos committed Aug 3, 2019
1 parent 942e1f4 commit f39b71d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
8 changes: 5 additions & 3 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
User = get_user_model()


def render_index(request):
def render_index(request, **extra_context):
with open('README.md', 'r') as f:
readme = markdown(f.read(), extensions=['fenced_code'])
readme = mark_safe(readme)
return render(request, 'index.html', context={'readme': readme})
return render(request, 'index.html', context={'readme': readme, **extra_context})


def index_view(request: HttpRequest):
if request.user.is_authenticated:
return redirect('core:user', user_id=request.user.username)
return render_index(request)


Expand Down Expand Up @@ -74,7 +76,7 @@ def user_hook_view(request: HttpRequest, user_id: str):

def logout_view(request):
u = request.user
if isinstance(u, User):
if u.is_authenticated:
u.is_active = False
u.save()
logout(request)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Django==2.2.4
future==0.17.1
gunicorn==19.9.0
idna==2.8
Markdown==3.1.1
psycopg2-binary==2.8.3
pycparser==2.19
python-telegram-bot==12.0.0b1
Expand Down
23 changes: 13 additions & 10 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,6 @@
<form action="{% url 'core:logout' %}">
<button class="logout-btn">Logout</button>
</form>
<div class="info">
Use this url as webhook in .travis.yml notifications section:
<div class="tooltip">
<span class="tooltiptext" id="tooltip" style="display: none;"></span>
<pre id="copypasta" onclick="copyText()">notifications:
webhooks: {{ request.build_absolute_uri }}</pre>
</div>
</div>
{% else %}
<script
async
Expand All @@ -114,10 +106,21 @@
data-auth-url="/login_success"
data-request-access="write"
></script>
<div>
{{ readme }}
{% endif %}
{% if user.is_authenticated and request.resolver_match.url_name == "user" %}
<div class="info">
Use url below as webhook in .travis.yml notifications section (click to copy).
Logout to stop receiving notifications (or just remove webhook from travis config, or block bot).
<div class="tooltip">
<span class="tooltiptext" id="tooltip" style="display: none;"></span>
<pre id="copypasta" onclick="copyText()">notifications:
webhooks: {{ request.build_absolute_uri }}</pre>
</div>
</div>
{% endif %}
<div class="info">
{{ readme }}
</div>
</div>

<script>
Expand Down

0 comments on commit f39b71d

Please sign in to comment.