Merge branch 'master' of gitlab.com:stax-river/pokercc

master
Laurent 6 years ago
commit d3a6f29666
  1. 5
      .gitignore
  2. 7
      news/choices.py
  3. 12
      news/forms.py
  4. 35
      news/migrations/0006_auto_20191009_1004.py
  5. 22
      news/migrations/0007_auto_20191009_1009.py
  6. 23
      news/migrations/0008_auto_20191010_0909.py
  7. 18
      news/migrations/0009_auto_20191010_0910.py
  8. 18
      news/migrations/0010_auto_20191010_0945.py
  9. BIN
      news/migrations/__pycache__/0001_initial.cpython-37.pyc
  10. BIN
      news/migrations/__pycache__/0002_auto_20190917_1255.cpython-37.pyc
  11. BIN
      news/migrations/__pycache__/0003_auto_20190917_1258.cpython-37.pyc
  12. BIN
      news/migrations/__pycache__/0004_auto_20190917_1301.cpython-37.pyc
  13. BIN
      news/migrations/__pycache__/0005_auto_20190918_0918.cpython-37.pyc
  14. BIN
      news/migrations/__pycache__/__init__.cpython-37.pyc
  15. 48
      news/models.py
  16. 82
      news/static/news/css/app.css
  17. 20
      news/templates/base.html
  18. 50
      news/templates/news/index.html
  19. 21
      news/templates/news/post.html
  20. 24
      news/templates/news/static/about.html
  21. 4
      news/templates/news/static/contact.html
  22. 2
      news/templates/news/submission.html
  23. 2
      news/templates/news/submitted.html
  24. 4
      news/templates/news/user/account.html
  25. 2
      news/templates/news/user/change-password.html
  26. 4
      news/templates/news/user/password_reset_complete.html
  27. 37
      news/templates/news/user/password_reset_confirm.html
  28. 2
      news/templates/news/user/password_reset_done.html
  29. 2
      news/templates/news/user/password_reset_form.html
  30. 3
      news/templates/news/user/password_reset_html_email.html
  31. 1
      news/templates/news/user/password_reset_subject.txt
  32. 2
      news/templates/news/user/register.html
  33. 2
      news/templates/news/user/signin.html
  34. 11
      news/urls.py
  35. 27
      news/views.py
  36. BIN
      pokercc/._settings.py
  37. 13
      pokercc/settings.py
  38. 2
      pokercc/urls.py

5
.gitignore vendored

@ -2,6 +2,7 @@
db.sqlite3
news/__pycache__
pokercc/__pycache__
news/migrations/__pycache__/
**/.DS_Store
rumble/

@ -1,5 +1,6 @@
STYLE_CHOICES = (
(0, "Standard"),
(1, "Quote"),
(2, "Image Only")
(0, "Standard [Title + URL + Image]"),
(1, "Quote [Title]"),
(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):
style = forms.ChoiceField(label='Style',choices=STYLE_CHOICES, required=True)
title = forms.CharField(label='Title', max_length=200, required=False)
body = forms.CharField(label='Optional text', max_length=10000, required=False)
title = forms.CharField(label='Title (required for slug/SEO)', max_length=200, required=True)
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_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)
image = forms.FileField()
class SigninForm(forms.Form):
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.contrib.auth.models import User
from django.conf import settings
from django.db.models import Q
from django.utils.text import slugify
from enum import Enum
# Create your models here.
@ -11,7 +13,7 @@ class PostState(Enum):
USER_SUBMITTED = 3
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)
body = models.CharField(max_length=10000)
url = models.CharField(max_length=200)
@ -19,25 +21,45 @@ class Post(models.Model):
state = models.IntegerField(default=0)
style = models.IntegerField(default=0)
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):
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):
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):
flat = []
for comment in self.comment_set.all():
# flat.append(comment)
flat.extend(comment.flat_children(0, user))
for comment in self.comment_set.filter(Q(parent_comment=None)).all():
children = comment.flat_children(0, user)
flat.extend(children)
return flat
def is_youtube_video(self):
return "youtube.com" in self.url
# 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 formatted_tags(self):
tag_names = map(lambda t: t.name, self.tag_set.all())
return ", ".join(tag_names)
def html_title(self):
if self.title:
return self.title
return 'Poker Rumble - Amazing content'
class Comment(models.Model):
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):
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)
def __str__(self):
@ -77,6 +99,6 @@ class Player(models.Model):
class Tag(models.Model):
name = models.CharField(max_length=100)
post = models.ForeignKey(Post, on_delete=models.CASCADE)
post = models.ManyToManyField(Post, blank=True)
def __str__(self):
return self.name

@ -46,10 +46,6 @@ header {
}
}
/* header a {
text-decoration: none;
} */
.title {
background-color: var(--header-bg-color);
}
@ -59,8 +55,7 @@ header h1 {
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-weight:900;
font-stretch:condensed; /* font-family: 'LibreBaskervilleBold'; */
/* letter-spacing: -1px; */
font-stretch:condensed;
text-transform: uppercase;
font-size: 32px;
}
@ -75,6 +70,9 @@ header h1 a {
color: #fff;
}
header h1 a:hover {
color: #BFA030;
}
header h2 {
margin-top: -10px;
padding: 0;
@ -83,7 +81,6 @@ header h2 {
nav {
padding: 4px;
/* margin-top: 4px; */
font-size: 14px;
background-color: #333;
}
@ -152,18 +149,6 @@ a h1 {
}
}
.inside_image_top {
position: absolute;
top: 12px;
left: 12px;
}
.inside_image_bottom {
position: absolute;
bottom: 12px;
left: 12px;
}
.details {
font-size: 14px;
color: #999;
@ -192,17 +177,39 @@ a h1 {
.imgcontainer {
position: relative;
color: white;
border-bottom: 10px solid #111;
border-top: 10px solid #111;
/* border-bottom: 0px solid #111; */
/* border-top: 20px solid #111; */
}
@media print, screen and (min-width: 40em) {
.imgcontainer {
width: 500px;
border-bottom: 10px solid #111;
border-top: 10px solid #111;
width: 600px;
/* border-bottom: 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 {
padding: 10px 0px;
margin-bottom: 10px;
@ -293,7 +300,7 @@ input[type=email] {
input[type=file] {
font-size: 14px;
padding:10px 15px;
background:#e8e8e8;
background:#555;
border:0 none;
cursor:pointer;
-webkit-border-radius: 8px;
@ -303,7 +310,7 @@ input[type=file] {
input[type=file]:hover {
font-size: 14px;
padding:10px 15px;
background:#fcf;
background:#777;
border:0 none;
cursor:pointer;
-webkit-border-radius: 8px;
@ -339,3 +346,26 @@ form .secondary_button {
.reply_form {
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="shortcut icon" type="image/png" href="{% static 'image/favicon.png' %}"/>
<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>
<body>
@ -61,7 +77,9 @@
<footer>
<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>

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

@ -2,7 +2,7 @@
{% load static %}
{% block title %}My amazing blog{% endblock %}
{% block title %}{{ post.html_title }}{% endblock %}
{% block content %}
@ -23,7 +23,9 @@
</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 }}"/>
{% endif %}
@ -36,6 +38,7 @@
{% endif %}
<br/>
{% if user.is_authenticated %}
<form action="{% url 'news:comment' post.id %}" method="post">
{% csrf_token %}
<p>Add comment</p>
@ -44,6 +47,11 @@
</p>
<button class="primary_button" type="submit">Submit</button>
</form>
{% else %}
<p>
Please <a href="{% url 'news:signin' %}">login</a> to comment the post
</p>
{% endif %}
<script type="text/javascript">
function myFunction(divID) {
@ -69,7 +77,7 @@
{{ comment.body }}
<div>
{% if comment.upvoted == False %}
{% if comment.upvoted == False and user.is_authenticated %}
<form action="{% url 'news:upvote' comment.id %}" method="post" class="inline">
{% csrf_token %}
<button class="primary_button" type="submit">+1</button>
@ -86,11 +94,18 @@
<button class="secondary_button inline" onclick="myFunction('{{ comment.id }}')">reply</button>
<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">
{% csrf_token %}
<textarea id="text_{{ comment.id}}" name="body" rows="3" cols="50"></textarea>
<button id="sub_{{ comment.id}}" class="primary_button" type="submit">Submit</button>
</form>
{% else %}
<p>
Please <a href="{% url 'news:signin' %}">login</a> to reply
</p>
{% endif %}
</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" %}
{% block title %}Contact{% endblock %}
{% block title %}Contact - Poker Rumble{% endblock %}
{% block content %}
<h1>Contact</h1>
<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>
{% endblock content %}

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

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

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

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

@ -1,5 +1,9 @@
{% extends 'base.html' %}
{% block title %}
Password changed - Poker Rumble
{% endblock %}
{% block content %}
<p>
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 %}
{% if validlink %}
<h3>Change password</h3>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button class="primary_button" type="submit">Change password</button>
<p>Please enter your new password twice so we can verify you typed it in correctly.</p>
<form method="post">{% csrf_token %}
<fieldset class="module aligned">
<div class="form-row field-password1">
{{ form.new_password1.errors }}
<label for="id_new_password1">New password:</label>
{{ form.new_password1 }}
</div>
<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>
<p>The password reset link was invalid, possibly because it has already been used. Please request a new password reset.</p>
{% endif %}
{% endblock %}

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

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

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

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

@ -8,9 +8,11 @@ app_name = 'news'
urlpatterns = [
# Static
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
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', views.comment, name='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',
email_template_name='news/user/password_reset_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'
), 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('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',
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'),
success_url='password-change/done'), name='password_reset_confirm'),
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.db.models import Q
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 datetime import datetime
import logging
@ -89,7 +90,7 @@ def index(request):
context = { 'latest_post_list' : posts }
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)
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.style = form.cleaned_data['style']
filename = str(uuid.uuid4())
handle_uploaded_file(filename, request.FILES['image'])
tags = parsed_tags(form.cleaned_data['tags'])
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
if request.user.is_staff:
post.state = PostState.PUBLISHED.value
pub_date = form.cleaned_data['pub_date']
@ -126,6 +134,15 @@ def submission(request):
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):
with open(settings.MEDIA_ROOT + filename, 'wb+') as destination:
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)
if comment_id is not None:
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.voters.add(request.user)
comment.save()

Binary file not shown.

@ -27,9 +27,16 @@ SECRET_KEY = 'erk4wh93pi(m(odwg74lsy60tb$rz4=ndyiv3#2lcx^!$^kq@4'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
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
@ -83,7 +90,7 @@ DATABASES = {
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'stax_rumble',
'NAME': 'stax_rumble_dev',
'USER': 'stax',
'PASSWORD': 'staxkikoo',
'HOST': 'postgresql-stax.alwaysdata.net',

@ -17,6 +17,6 @@ from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('news/', include('news.urls')),
path('', include('news.urls')),
path('admin/', admin.site.urls),
]

Loading…
Cancel
Save