update gitignore

master
Laurent Morvillier 6 years ago
commit cfb9aee497
  1. 7
      news/choices.py
  2. 12
      news/forms.py
  3. 35
      news/migrations/0006_auto_20191009_1004.py
  4. 22
      news/migrations/0007_auto_20191009_1009.py
  5. 23
      news/migrations/0008_auto_20191010_0909.py
  6. 18
      news/migrations/0009_auto_20191010_0910.py
  7. 18
      news/migrations/0010_auto_20191010_0945.py
  8. 48
      news/models.py
  9. BIN
      news/static/image/favicon.png
  10. BIN
      news/static/image/icon1024.png
  11. BIN
      news/static/image/icon1024_basic.png
  12. BIN
      news/static/image/icon1024_transparent.png
  13. BIN
      news/static/image/icon128.png
  14. BIN
      news/static/image/icon128_black.png
  15. BIN
      news/static/image/icon128_transparent.png
  16. BIN
      news/static/image/icon128_transparent_black.png
  17. BIN
      news/static/image/icon128_transparent_white.png
  18. BIN
      news/static/image/icon_square.png
  19. 93
      news/static/news/css/app.css
  20. 22
      news/templates/base.html
  21. 54
      news/templates/news/index.html
  22. 33
      news/templates/news/post.html
  23. 24
      news/templates/news/static/about.html
  24. 4
      news/templates/news/static/contact.html
  25. 2
      news/templates/news/submission.html
  26. 2
      news/templates/news/submitted.html
  27. 4
      news/templates/news/user/account.html
  28. 2
      news/templates/news/user/change-password.html
  29. 4
      news/templates/news/user/password_reset_complete.html
  30. 45
      news/templates/news/user/password_reset_confirm.html
  31. 2
      news/templates/news/user/password_reset_done.html
  32. 2
      news/templates/news/user/password_reset_form.html
  33. 3
      news/templates/news/user/password_reset_html_email.html
  34. 1
      news/templates/news/user/password_reset_subject.txt
  35. 2
      news/templates/news/user/register.html
  36. 2
      news/templates/news/user/signin.html
  37. 11
      news/urls.py
  38. 29
      news/views.py
  39. BIN
      pokercc/._settings.py
  40. 11
      pokercc/settings.py

@ -1,5 +1,6 @@
STYLE_CHOICES = ( STYLE_CHOICES = (
(0, "Standard"), (0, "Standard [Title + URL + Image]"),
(1, "Quote"), (1, "Quote [Title]"),
(2, "Image Only") (2, "Image Only [Image]"),
(3, "Youtube [Put video id in URL]")
) )

@ -10,18 +10,18 @@ from datetime import datetime, date, time, timedelta
class PostForm(forms.Form): class PostForm(forms.Form):
style = forms.ChoiceField(label='Style',choices=STYLE_CHOICES, required=True) style = forms.ChoiceField(label='Style',choices=STYLE_CHOICES, required=True)
title = forms.CharField(label='Title', max_length=200, required=False) title = forms.CharField(label='Title (required for slug/SEO)', max_length=200, required=True)
body = forms.CharField(label='Optional text', max_length=10000, required=False)
url = forms.CharField(label='URL', max_length=200, required=False) url = forms.CharField(label='URL', max_length=200, required=False)
# date = forms.DateTimeField('date published')
# state = forms.IntegerField(label='State', default=1) body = forms.CharField(label='Optional body', max_length=10000, required=False)
today = datetime.today() # + datetime.timedelta(days=1) today = datetime.today() # + datetime.timedelta(days=1)
today_formatted = today.strftime("%Y-%m-%d %H:%M:%S") today_formatted = today.strftime("%Y-%m-%d %H:%M:%S")
image = forms.FileField(required=False)
tags = forms.CharField(label='Tags (separated by a comma)', max_length=200, required=False)
pub_date = forms.DateTimeField(label='Optional publication date, example: ' + today_formatted, required=False) pub_date = forms.DateTimeField(label='Optional publication date, example: ' + today_formatted, required=False)
image = forms.FileField()
class SigninForm(forms.Form): class SigninForm(forms.Form):
username = forms.CharField(label='Enter Username', min_length=4, max_length=150) username = forms.CharField(label='Enter Username', min_length=4, max_length=150)

@ -0,0 +1,35 @@
# Generated by Django 2.2.6 on 2019-10-09 10:04
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('news', '0005_auto_20190918_0918'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='voters',
field=models.ManyToManyField(blank=True, related_name='voted_comments', to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='player',
name='post',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='news.Post'),
),
migrations.AlterField(
model_name='post',
name='author',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='tag',
name='post',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='news.Post'),
),
]

@ -0,0 +1,22 @@
# Generated by Django 2.2.6 on 2019-10-09 10:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('news', '0006_auto_20191009_1004'),
]
operations = [
migrations.RemoveField(
model_name='tag',
name='post',
),
migrations.AddField(
model_name='tag',
name='post',
field=models.ManyToManyField(blank=True, null=True, to='news.Post'),
),
]

@ -0,0 +1,23 @@
# Generated by Django 2.2.6 on 2019-10-10 09:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('news', '0007_auto_20191009_1009'),
]
operations = [
migrations.AddField(
model_name='post',
name='slug',
field=models.SlugField(default='', unique=True),
),
migrations.AlterField(
model_name='tag',
name='post',
field=models.ManyToManyField(blank=True, to='news.Post'),
),
]

@ -0,0 +1,18 @@
# Generated by Django 2.2.6 on 2019-10-10 09:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('news', '0008_auto_20191010_0909'),
]
operations = [
migrations.AlterField(
model_name='post',
name='slug',
field=models.SlugField(default=''),
),
]

@ -0,0 +1,18 @@
# Generated by Django 2.2.6 on 2019-10-10 09:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('news', '0009_auto_20191010_0910'),
]
operations = [
migrations.AlterField(
model_name='post',
name='slug',
field=models.SlugField(default='', max_length=200),
),
]

@ -1,6 +1,8 @@
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.conf import settings from django.conf import settings
from django.db.models import Q
from django.utils.text import slugify
from enum import Enum from enum import Enum
# Create your models here. # Create your models here.
@ -11,7 +13,7 @@ class PostState(Enum):
USER_SUBMITTED = 3 USER_SUBMITTED = 3
class Post(models.Model): class Post(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True)
title = models.CharField(max_length=200) title = models.CharField(max_length=200)
body = models.CharField(max_length=10000) body = models.CharField(max_length=10000)
url = models.CharField(max_length=200) url = models.CharField(max_length=200)
@ -19,25 +21,45 @@ class Post(models.Model):
state = models.IntegerField(default=0) state = models.IntegerField(default=0)
style = models.IntegerField(default=0) style = models.IntegerField(default=0)
image_url = models.CharField(max_length=100) image_url = models.CharField(max_length=100)
slug = models.SlugField(default='', max_length=200)
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
super(Post, self).save(*args, **kwargs)
def __str__(self): def __str__(self):
return self.title string = self.title
if self.style == 2:
string = "some image"
elif self.style == 3:
string = "Youtube: " + self.title
return string
def get_absolute_url(self):
kwargs = {
'pk': self.id,
'slug': self.slug
}
return reverse('post_detail', kwargs=kwargs)
def top_comments(self): def top_comments(self):
return self.comment_set.order_by('-voters').all()[:1] return self.comment_set.filter(Q(parent_comment=None)).order_by('-voters').all()[:1]
def flat_comments(self, user): def flat_comments(self, user):
flat = [] flat = []
for comment in self.comment_set.all(): for comment in self.comment_set.filter(Q(parent_comment=None)).all():
# flat.append(comment) children = comment.flat_children(0, user)
flat.extend(comment.flat_children(0, user)) flat.extend(children)
return flat return flat
def is_youtube_video(self): def formatted_tags(self):
return "youtube.com" in self.url tag_names = map(lambda t: t.name, self.tag_set.all())
return ", ".join(tag_names)
# return self.comment_set.annotate(ratings_num=count('voters')).order_by('-ratings_num')[:5]
# return self.comment_set.order_by('voters_num').all()[:5]
def html_title(self):
if self.title:
return self.title
return 'Poker Rumble - Amazing content'
class Comment(models.Model): class Comment(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True) author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True)
@ -68,7 +90,7 @@ class Comment(models.Model):
class Player(models.Model): class Player(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
post = models.ForeignKey(Post, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.SET_NULL, null=True)
image_url = models.CharField(max_length=100) image_url = models.CharField(max_length=100)
def __str__(self): def __str__(self):
@ -77,6 +99,6 @@ class Player(models.Model):
class Tag(models.Model): class Tag(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
post = models.ForeignKey(Post, on_delete=models.CASCADE) post = models.ManyToManyField(Post, blank=True)
def __str__(self): def __str__(self):
return self.name return self.name

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

@ -46,12 +46,11 @@ header {
} }
} }
/* header a {
text-decoration: none;
} */
.title { .title {
background-color: var(--header-bg-color); border-top: 2px solid var(--header-bg-color);
border-bottom: 2px solid var(--header-bg-color);
/* background-color: var(--header-bg-color); */
} }
header h1 { header h1 {
@ -59,8 +58,7 @@ header h1 {
margin-bottom: 0px; margin-bottom: 0px;
font-family: "HelveticaNeue-CondensedBlack", "HelveticaNeueBlackCondensed", "HelveticaNeue-Black-Condensed", "Helvetica Neue Black Condensed", "HelveticaNeueBlack", "HelveticaNeue-Black", "Helvetica Neue Black", "HelveticaNeue", "Helvetica Neue", 'TeXGyreHerosCnBold', "Helvetica", "Tahoma", "Geneva", "Arial Narrow", "Arial", sans-serif; font-family: "HelveticaNeue-CondensedBlack", "HelveticaNeueBlackCondensed", "HelveticaNeue-Black-Condensed", "Helvetica Neue Black Condensed", "HelveticaNeueBlack", "HelveticaNeue-Black", "Helvetica Neue Black", "HelveticaNeue", "Helvetica Neue", 'TeXGyreHerosCnBold', "Helvetica", "Tahoma", "Geneva", "Arial Narrow", "Arial", sans-serif;
font-weight:900; font-weight:900;
font-stretch:condensed; /* font-family: 'LibreBaskervilleBold'; */ font-stretch:condensed;
/* letter-spacing: -1px; */
text-transform: uppercase; text-transform: uppercase;
font-size: 32px; font-size: 32px;
} }
@ -75,6 +73,9 @@ header h1 a {
color: #fff; color: #fff;
} }
header h1 a:hover {
color: var(--header-bg-color);
}
header h2 { header h2 {
margin-top: -10px; margin-top: -10px;
padding: 0; padding: 0;
@ -83,9 +84,9 @@ header h2 {
nav { nav {
padding: 4px; padding: 4px;
/* margin-top: 4px; */ font-size: 13px;
font-size: 14px; text-transform: uppercase;
background-color: #333; /* background-color: #333; */
} }
footer { footer {
@ -152,18 +153,9 @@ a h1 {
} }
} }
.inside_image_top { .date {
position: absolute; margin-bottom: 4px;
top: 12px;
left: 12px;
}
.inside_image_bottom {
position: absolute;
bottom: 12px;
left: 12px;
} }
.details { .details {
font-size: 14px; font-size: 14px;
color: #999; color: #999;
@ -192,17 +184,39 @@ a h1 {
.imgcontainer { .imgcontainer {
position: relative; position: relative;
color: white; color: white;
border-bottom: 10px solid #111; /* border-bottom: 0px solid #111; */
border-top: 10px solid #111; /* border-top: 20px solid #111; */
} }
@media print, screen and (min-width: 40em) { @media print, screen and (min-width: 40em) {
.imgcontainer { .imgcontainer {
width: 500px; width: 600px;
border-bottom: 10px solid #111; /* border-bottom: 10px solid #111; */
border-top: 10px solid #111; /* border-top: 20px solid #111; */
} }
} }
.imgcontainer h1 {
padding: 0px 8px;
line-height: 120%;
}
.imgcontainer h1 span {
background-color: #000;
}
.inside_image_top {
position: absolute;
top: 0px;
left: 12px;
right: 12px;
}
.inside_image_bottom {
position: absolute;
bottom: 12px;
left: 12px;
}
.post { .post {
padding: 10px 0px; padding: 10px 0px;
margin-bottom: 10px; margin-bottom: 10px;
@ -293,7 +307,7 @@ input[type=email] {
input[type=file] { input[type=file] {
font-size: 14px; font-size: 14px;
padding:10px 15px; padding:10px 15px;
background:#e8e8e8; background:#555;
border:0 none; border:0 none;
cursor:pointer; cursor:pointer;
-webkit-border-radius: 8px; -webkit-border-radius: 8px;
@ -303,7 +317,7 @@ input[type=file] {
input[type=file]:hover { input[type=file]:hover {
font-size: 14px; font-size: 14px;
padding:10px 15px; padding:10px 15px;
background:#fcf; background:#777;
border:0 none; border:0 none;
cursor:pointer; cursor:pointer;
-webkit-border-radius: 8px; -webkit-border-radius: 8px;
@ -339,3 +353,26 @@ form .secondary_button {
.reply_form { .reply_form {
margin-top: 8px; margin-top: 8px;
} }
.youtube {
width: 95vw;
height: 60vw;
}
/* @media print, screen and (min-width: 40em) {
.youtube {
width: 90vw;
height: 60vw;
}
} */
@media print, screen and (min-width: 50em) {
.youtube {
width: 60vw;
height: 35vw;
}
}
@media print, screen and (min-width: 70em) {
.youtube {
width: 45vw;
height: 25vw;
}
}

@ -8,6 +8,22 @@
<link rel="stylesheet" type="text/css" href="{% static 'news/css/foundation.min.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'news/css/foundation.min.css' %}">
<link rel="shortcut icon" type="image/png" href="{% static 'image/favicon.png' %}"/> <link rel="shortcut icon" type="image/png" href="{% static 'image/favicon.png' %}"/>
<title>{% block title %}My amazing site{% endblock %}</title> <title>{% block title %}My amazing site{% endblock %}</title>
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//www.pokerrumble.net/matomo/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
</head> </head>
<body> <body>
@ -26,9 +42,9 @@
<!-- Header --> <!-- Header -->
<header> <header>
<img src="{% static 'image/icon128_transparent.png' %}" alt="Poker Rumble icon" width="96" height="96"/>
<div class="title"> <div class="title">
<h1> <h1>
<!-- <img src="{% static 'image/icon_square.png' %}" alt="Poker Rumble icon" width="64" height="56"/> -->
<a href="{% url 'news:index' %}">poker rumble</a> <a href="{% url 'news:index' %}">poker rumble</a>
</h1> </h1>
</div> </div>
@ -61,7 +77,9 @@
<footer> <footer>
<a href="{% url 'news:contact' %}">Contact</a> <a href="{% url 'news:contact' %}">Contact</a>
<p>Copyright © 2019 Stax River</p> <br/>
<a href="{% url 'news:about' %}">About</a>
<p>Copyright © 2019 Poker Rumble</p>
</footer> </footer>

@ -2,35 +2,27 @@
{% load static %} {% load static %}
{% block title %}My amazing blog{% endblock %} {% block title %}Poker Rumble - Your source of great poker content{% endblock %}
{% block content %} {% block content %}
{% if latest_post_list %} {% if latest_post_list %}
{% for post in latest_post_list %} {% for post in latest_post_list %}
<!-- <div class="{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}"> -->
<!-- A post -->
<article> <article>
<div class="details lat_padding"> <div class="date details lat_padding">
{{ post.date }} - {{ post.author.username }} {{ post.date }} - {{ post.author.username }}
</div> </div>
<!-- A post -->
{% if post.style == 0 %} {% if post.style == 0 %}
{% if post.is_youtube_video %}
<a href="{{ post.url }}">
<h1>{{ post.title }}</h1>
</a>
<iframe src="{{ post.url }}" width="600" height="400"></iframe>
{% else %}
<div class="imgcontainer"> <div class="imgcontainer">
<img src="{% static 'media/' %}{{ post.image_url }}"/> <img src="{% static 'media/' %}{{ post.image_url }}"/>
<div class="inside_image_top"> <div class="inside_image_top">
{% if post.url %}<a href="{{ post.url }}">{% endif %} {% if post.url %}<a href="{{ post.url }}">{% endif %}
<h1>{{ post.title }}</h1> <h1><span>{{ post.title }}</span></h1>
{% if post.url %}</a>{% endif %} {% if post.url %}</a>{% endif %}
{% if post.body %} {% if post.body %}
@ -40,10 +32,9 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
{% endif %}
<div class="details"> <div class="details">
<a href="{% url 'news:post' post.id %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comment{% if post.comment_set.count > 1 %}s{% endif %}{% else %}write comment{% endif %}</a> <a href="{% url 'news:post' post.id post.slug %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comment{% if post.comment_set.count > 1 %}s{% endif %}{% else %}write comment{% endif %}</a>
</div> </div>
<!-- Some comments --> <!-- Some comments -->
<div class="comments"> <div class="comments">
@ -63,7 +54,7 @@
<div class="post_padding"> <div class="post_padding">
<div class="details info"> <div class="details info">
<a href="{% url 'news:post' post.id %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comment{% if post.comment_set.count > 1 %}s{% endif %}{% else %}write comment{% endif %}</a> <a href="{% url 'news:post' post.id post.slug %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comment{% if post.comment_set.count > 1 %}s{% endif %}{% else %}write comment{% endif %}</a>
</div> </div>
<!-- Some comments --> <!-- Some comments -->
<div class="comments"> <div class="comments">
@ -77,17 +68,33 @@
<!-- Media no title no link --> <!-- Media no title no link -->
{% elif post.style == 2 %} {% elif post.style == 2 %}
{% if post.is_youtube_video %}
<iframe src="{{ post.url }}" width="600" height="400"></iframe>
{% else %}
<div class="imgcontainer"> <div class="imgcontainer">
<img class="crop" src="{% static 'media/' %}{{ post.image_url }}"/> <img class="crop" src="{% static 'media/' %}{{ post.image_url }}"/>
</div> </div>
{% endif %}
<div class="post_padding"> <div class="post_padding">
<div class="details info"> <div class="details info">
<a href="{% url 'news:post' post.id %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comment{% if post.comment_set.count > 1 %}s{% endif %}{% else %}write comment{% endif %}</a> <a href="{% url 'news:post' post.id post.slug %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comment{% if post.comment_set.count > 1 %}s{% endif %}{% else %}write comment{% endif %}</a>
</div>
<!-- Some comments -->
<div class="comments">
{% for comment in post.top_comments %}
<span>{{ comment.body }} - {{ comment.author.username }}</span><br/>
{% endfor %}
</div>
</div>
{% elif post.style == 3 %}
<a href="{{ post.url }}">
<h1>{{ post.title }}</h1>
</a>
<iframe class="youtube" src="https://www.youtube.com/embed/{{ post.url }}"></iframe>
<div class="post_padding">
<div class="details info">
<a href="{% url 'news:post' post.id post.slug %}">{% if post.comment_set.count > 0 %}{{ post.comment_set.count }} comment{% if post.comment_set.count > 1 %}s{% endif %}{% else %}write comment{% endif %}</a>
</div> </div>
<!-- Some comments --> <!-- Some comments -->
<div class="comments"> <div class="comments">
@ -98,6 +105,11 @@
</div> </div>
{% endif %} {% endif %}
<!-- {% if post.tag_set.count > 0 %}
<p>tags: {{ post.formatted_tags }}</p>
{% endif %} -->
</article> </article>
<!-- </div> --> <!-- </div> -->

@ -2,7 +2,7 @@
{% load static %} {% load static %}
{% block title %}My amazing blog{% endblock %} {% block title %}{{ post.html_title }}{% endblock %}
{% block content %} {% block content %}
@ -23,7 +23,9 @@
</div> </div>
</div> </div>
{% if post.style != 1 %} {% if post.style == 3 %}
<iframe class="youtube" src="https://www.youtube.com/embed/{{ post.url }}"></iframe>
{% elif post.style != 1 %}
<img src="{% static 'media/' %}{{ post.image_url }}"/> <img src="{% static 'media/' %}{{ post.image_url }}"/>
{% endif %} {% endif %}
@ -36,14 +38,20 @@
{% endif %} {% endif %}
<br/> <br/>
<form action="{% url 'news:comment' post.id %}" method="post"> {% if user.is_authenticated %}
{% csrf_token %} <form action="{% url 'news:comment' post.id %}" method="post">
<p>Add comment</p> {% csrf_token %}
<p>Add comment</p>
<p>
<textarea name="body" rows="3" cols="50"></textarea>
</p>
<button class="primary_button" type="submit">Submit</button>
</form>
{% else %}
<p> <p>
<textarea name="body" rows="3" cols="50"></textarea> Please <a href="{% url 'news:signin' %}">login</a> to comment the post
</p> </p>
<button class="primary_button" type="submit">Submit</button> {% endif %}
</form>
<script type="text/javascript"> <script type="text/javascript">
function myFunction(divID) { function myFunction(divID) {
@ -69,7 +77,7 @@
{{ comment.body }} {{ comment.body }}
<div> <div>
{% if comment.upvoted == False %} {% if comment.upvoted == False and user.is_authenticated %}
<form action="{% url 'news:upvote' comment.id %}" method="post" class="inline"> <form action="{% url 'news:upvote' comment.id %}" method="post" class="inline">
{% csrf_token %} {% csrf_token %}
<button class="primary_button" type="submit">+1</button> <button class="primary_button" type="submit">+1</button>
@ -86,11 +94,18 @@
<button class="secondary_button inline" onclick="myFunction('{{ comment.id }}')">reply</button> <button class="secondary_button inline" onclick="myFunction('{{ comment.id }}')">reply</button>
<div id="div_{{ comment.id }}" class="inline reply_form" style="display:none"> <div id="div_{{ comment.id }}" class="inline reply_form" style="display:none">
{% if user.is_authenticated %}
<form action="{% url 'news:comment_with_parent' post.id comment.id %}" method="post"> <form action="{% url 'news:comment_with_parent' post.id comment.id %}" method="post">
{% csrf_token %} {% csrf_token %}
<textarea id="text_{{ comment.id}}" name="body" rows="3" cols="50"></textarea> <textarea id="text_{{ comment.id}}" name="body" rows="3" cols="50"></textarea>
<button id="sub_{{ comment.id}}" class="primary_button" type="submit">Submit</button> <button id="sub_{{ comment.id}}" class="primary_button" type="submit">Submit</button>
</form> </form>
{% else %}
<p>
Please <a href="{% url 'news:signin' %}">login</a> to reply
</p>
{% endif %}
</div> </div>
</div> </div>

@ -0,0 +1,24 @@
{% extends "base.html" %}
{% block title %}About - Poker Rumble{% endblock %}
{% block content %}
<h1>About</h1>
<p>
This site is owned by Stax River.
</p>
<h2>Host</h2>
<p>
This website is hosted by ALWAYSDATA, 91 rue du Faubourg Saint-Honoré, 75008 Paris (phone: +33 1 84 16 23 40).
</p>
<h2>GDPR</h2>
<p>
When creating an account on Poker Rumble, you specify an email used to retrieve your password if it's lost. We store it in a database and that's it.
No selling personal data, no cookies, no crap.
</p>
{% endblock content %}

@ -1,13 +1,13 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Contact{% endblock %} {% block title %}Contact - Poker Rumble{% endblock %}
{% block content %} {% block content %}
<h1>Contact</h1> <h1>Contact</h1>
<p> <p>
Please contact us directly on social media! Please contact us directly on social media, @pokerrumble on <a href="https://twitter.com/pokerrumble">twitter</a> and <a href="https://www.instagram.com/pokerrumble">instagram</a>!
</p> </p>
{% endblock content %} {% endblock content %}

@ -2,7 +2,7 @@
{% load static %} {% load static %}
{% block title %}My amazing submission{% endblock %} {% block title %}Submit great stuff{% endblock %}
{% block content %} {% block content %}

@ -1,6 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}My amazing blog{% endblock %} {% block title %}Submission done{% endblock %}
{% block content %} {% block content %}

@ -1,8 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %} {% block title %}Account - Poker Rumble{% endblock %}
Account
{% endblock %}
{% block content %} {% block content %}

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %} {% block title %}
Change password Change password - Poker Rumble
{% endblock %} {% endblock %}
{% block content %} {% block content %}

@ -1,5 +1,9 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block title %}
Password changed - Poker Rumble
{% endblock %}
{% block content %} {% block content %}
<p> <p>
Your password has been set. You may go ahead and <a href="{% url 'news:signin' %}">sign in</a> now. Your password has been set. You may go ahead and <a href="{% url 'news:signin' %}">sign in</a> now.

@ -1,17 +1,34 @@
{% extends 'base.html' %}
{% extends "base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block content_title %}<h1>{{ title }}</h1>{% endblock %}
{% block content %} {% block content %}
{% if validlink %}
<h3>Change password</h3> {% if validlink %}
<form method="post">
{% csrf_token %} <p>Please enter your new password twice so we can verify you typed it in correctly.</p>
{{ form.as_p }}
<button class="primary_button" type="submit">Change password</button> <form method="post">{% csrf_token %}
</form> <fieldset class="module aligned">
{% else %} <div class="form-row field-password1">
<p> {{ form.new_password1.errors }}
The password reset link was invalid, possibly because it has already been used. <label for="id_new_password1">New password:</label>
Please request a new password reset. {{ form.new_password1 }}
</p> </div>
{% endif %} <div class="form-row field-password2">
{{ form.new_password2.errors }}
<label for="id_new_password2">Confirm password:</label>
{{ form.new_password2 }}
</div>
<input type="submit" value="Change my password">
</fieldset>
</form>
{% else %}
<p>The password reset link was invalid, possibly because it has already been used. Please request a new password reset.</p>
{% endif %}
{% endblock %} {% endblock %}

@ -1,7 +1,7 @@
<!-- templates/registration/password_reset_done.html --> <!-- templates/registration/password_reset_done.html -->
{% extends 'base.html' %} {% extends 'base.html' %}
{% block title %}Email Sent{% endblock %} {% block title %}Email Sent - Poker Rumble{% endblock %}
{% block content %} {% block content %}
<h1>Check your inbox.</h1> <h1>Check your inbox.</h1>

@ -1,7 +1,7 @@
<!-- templates/registration/password_reset_form.html --> <!-- templates/registration/password_reset_form.html -->
{% extends 'base.html' %} {% extends 'base.html' %}
{% block title %}Forgot Your Password?{% endblock %} {% block title %}Forgot Your Password? - Poker Rumble{% endblock %}
{% block content %} {% block content %}
<h1>Forgot your password?</h1> <h1>Forgot your password?</h1>

@ -1,2 +1,3 @@
Someone asked for password reset for email {{ email }}. Follow the link below: Someone asked for a password reset for email {{ email }}.
Please follow the link below:
{{ protocol}}://{{ domain }}{% url 'news:password_reset_confirm' uidb64=uid token=token %} {{ protocol}}://{{ domain }}{% url 'news:password_reset_confirm' uidb64=uid token=token %}

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %} {% block title %}
Create User Create User - Poker Rumble
{% endblock %} {% endblock %}
{% block content %} {% block content %}

@ -1,7 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %} {% block title %}
Sign-in Sign-in - Poker Rumble
{% endblock %} {% endblock %}
{% block content %} {% block content %}

@ -8,9 +8,11 @@ app_name = 'news'
urlpatterns = [ urlpatterns = [
# Static # Static
path('contact', TemplateView.as_view(template_name='news/static/contact.html'), name='contact'), path('contact', TemplateView.as_view(template_name='news/static/contact.html'), name='contact'),
path('about', TemplateView.as_view(template_name='news/static/about.html'), name='about'),
# Posts # Posts
path('', views.index, name='index'), path('', views.index, name='index'),
path('<int:post_id>', views.post, name='post'), path("<int:post_id>/<slug:post_slug>", views.post, name="post"),
# path('<int:post_id>', views.post, name='post'),
path('<int:post_id>/comment/<int:comment_id>', views.comment_with_parent, name='comment_with_parent'), path('<int:post_id>/comment/<int:comment_id>', views.comment_with_parent, name='comment_with_parent'),
path('<int:post_id>/comment', views.comment, name='comment'), path('<int:post_id>/comment', views.comment, name='comment'),
path('comment/<int:comment_id>/delete', views.delete_comment, name='delete_comment'), path('comment/<int:comment_id>/delete', views.delete_comment, name='delete_comment'),
@ -27,11 +29,12 @@ urlpatterns = [
template_name='news/user/password_reset_form.html', template_name='news/user/password_reset_form.html',
email_template_name='news/user/password_reset_email.html', email_template_name='news/user/password_reset_email.html',
html_email_template_name='news/user/password_reset_html_email.html', html_email_template_name='news/user/password_reset_html_email.html',
subject_template_name='news/user/password_reset_subject.txt',
success_url='../password-reset/done' success_url='../password-reset/done'
), name='password_reset'), ), name='password_reset'),
path('password-reset/done', auth_views.PasswordResetDoneView.as_view(template_name='news/user/password_reset_done.html'), name='password_reset_done'), path('password-reset/done', auth_views.PasswordResetDoneView.as_view(template_name='news/user/password_reset_done.html'), name='password_reset_done'),
path('reset/<uidb64>/<token>', auth_views.PasswordResetConfirmView.as_view( path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(
template_name='news/user/password_reset_confirm.html', template_name='news/user/password_reset_confirm.html',
success_url='../password-change/done'), name='password_reset_confirm'), success_url='password-change/done'), name='password_reset_confirm'),
path('password-change/done', auth_views.PasswordResetCompleteView.as_view(template_name='news/user/password_reset_complete.html'), name='password_change_done'), path('reset/Mg/set-password/password-change/done', auth_views.PasswordResetCompleteView.as_view(template_name='news/user/password_reset_complete.html'), name='password_change_done'),
] ]

@ -11,7 +11,8 @@ from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import PasswordChangeForm from django.contrib.auth.forms import PasswordChangeForm
from django.db.models import Q from django.db.models import Q
from django.utils.html import strip_tags from django.utils.html import strip_tags
from .models import Post, Comment, PostState from django.utils.text import slugify
from .models import Post, Comment, PostState, Tag
from .forms import PostForm, CustomUserCreationForm, SigninForm from .forms import PostForm, CustomUserCreationForm, SigninForm
from datetime import datetime from datetime import datetime
import logging import logging
@ -89,7 +90,7 @@ def index(request):
context = { 'latest_post_list' : posts } context = { 'latest_post_list' : posts }
return render(request, 'news/index.html', context) return render(request, 'news/index.html', context)
def post(request, post_id): def post(request, post_id, post_slug):
post = get_object_or_404(Post, pk=post_id) post = get_object_or_404(Post, pk=post_id)
return render(request, 'news/post.html', {'post': post, 'comments': post.flat_comments(request.user) }) return render(request, 'news/post.html', {'post': post, 'comments': post.flat_comments(request.user) })
@ -106,10 +107,17 @@ def submission(request):
post.url = form.cleaned_data['url'] post.url = form.cleaned_data['url']
post.style = form.cleaned_data['style'] post.style = form.cleaned_data['style']
filename = str(uuid.uuid4()) tags = parsed_tags(form.cleaned_data['tags'])
handle_uploaded_file(filename, request.FILES['image']) post.tag_set.add(*tags)
post.slug = slugify(post.title)
file = request.FILES.get('image', None)
if file is not None:
filename = str(uuid.uuid4())
handle_uploaded_file(filename, file)
post.image_url = filename
post.image_url = filename
if request.user.is_staff: if request.user.is_staff:
post.state = PostState.PUBLISHED.value post.state = PostState.PUBLISHED.value
pub_date = form.cleaned_data['pub_date'] pub_date = form.cleaned_data['pub_date']
@ -126,6 +134,15 @@ def submission(request):
return render(request, 'news/submission.html', {'form': form}) return render(request, 'news/submission.html', {'form': form})
def parsed_tags(tag_strings):
tags = []
separated_tags_strings = tag_strings.split(",")
for tag_string in separated_tags_strings:
tag, created = Tag.objects.get_or_create(name=tag_string.strip())
tag.save()
tags.append(tag)
return tags
def handle_uploaded_file(filename, f): def handle_uploaded_file(filename, f):
with open(settings.MEDIA_ROOT + filename, 'wb+') as destination: with open(settings.MEDIA_ROOT + filename, 'wb+') as destination:
for chunk in f.chunks(): for chunk in f.chunks():
@ -142,7 +159,7 @@ def comment_with_parent(request, post_id, comment_id):
comment.post = get_object_or_404(Post, pk=post_id) comment.post = get_object_or_404(Post, pk=post_id)
if comment_id is not None: if comment_id is not None:
comment.parent_comment = get_object_or_404(Comment, pk=comment_id) comment.parent_comment = get_object_or_404(Comment, pk=comment_id)
comment.body = strip_tags(request.POST['body']) comment.body = strip_tags(request.POST['body']) # removes HTML tags
comment.save() comment.save()
comment.voters.add(request.user) comment.voters.add(request.user)
comment.save() comment.save()

Binary file not shown.

@ -29,7 +29,14 @@ DEBUG = True
ALLOWED_HOSTS = ['ssh-stax.alwaysdata.net', 'www.pokerrumble.net'] ALLOWED_HOSTS = ['ssh-stax.alwaysdata.net', 'www.pokerrumble.net']
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' #EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_HOST = 'smtp-stax.alwaysdata.net'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'automatic@pokerrumble.net'
EMAIL_HOST_PASSWORD = 'StaxKikoo12'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'Poker Rumble <automatic@pokerrumble.net>'
# Application definition # Application definition
@ -83,7 +90,7 @@ DATABASES = {
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.postgresql', 'ENGINE': 'django.db.backends.postgresql',
'NAME': 'stax_rumble', 'NAME': 'stax_rumble_dev',
'USER': 'stax', 'USER': 'stax',
'PASSWORD': 'staxkikoo', 'PASSWORD': 'staxkikoo',
'HOST': 'postgresql-stax.alwaysdata.net', 'HOST': 'postgresql-stax.alwaysdata.net',

Loading…
Cancel
Save