Initial setup
This commit is contained in:
parent
ffefc76acc
commit
c6e69496cf
5 changed files with 35 additions and 1 deletions
|
|
@ -1,9 +1,11 @@
|
|||
from django import forms
|
||||
|
||||
from newsreader.accounts.models import User
|
||||
from newsreader.core.forms import CheckboxInput
|
||||
|
||||
|
||||
class UserSettingsForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ("first_name", "last_name")
|
||||
fields = ("first_name", "last_name", "auto_mark_read")
|
||||
widgets = {"auto_mark_read": CheckboxInput}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 3.0.7 on 2020-10-27 21:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("accounts", "0012_remove_user_task")]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="user",
|
||||
name="auto_mark_read",
|
||||
field=models.BooleanField(
|
||||
default=True,
|
||||
help_text="Wether posts should be marked as read after x amount of seconds of reading",
|
||||
verbose_name="Auto read marking",
|
||||
),
|
||||
)
|
||||
]
|
||||
|
|
@ -45,6 +45,15 @@ class User(AbstractUser):
|
|||
twitter_oauth_token = models.CharField(max_length=255, blank=True, null=True)
|
||||
twitter_oauth_token_secret = models.CharField(max_length=255, blank=True, null=True)
|
||||
|
||||
# settings
|
||||
auto_mark_read = models.BooleanField(
|
||||
_("Auto read marking"),
|
||||
default=True,
|
||||
help_text=_(
|
||||
"Wether posts should be marked as read after x amount of seconds of reading"
|
||||
),
|
||||
)
|
||||
|
||||
username = None
|
||||
|
||||
objects = UserManager()
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import {
|
|||
} from '../constants.js';
|
||||
import { formatDatetime } from '../../../utils.js';
|
||||
|
||||
// TODO add "Mark as read" button
|
||||
class PostModal extends React.Component {
|
||||
modalListener = ::this.modalListener;
|
||||
readTimer = null;
|
||||
|
|
@ -21,6 +22,7 @@ class PostModal extends React.Component {
|
|||
const markPostRead = this.props.markPostRead;
|
||||
const token = Cookies.get('csrftoken');
|
||||
|
||||
// TODO set timer depending on user setting
|
||||
if (!post.read) {
|
||||
this.readTimer = setTimeout(markPostRead, 3000, post, token);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class NewsView(TemplateView):
|
|||
),
|
||||
"categoriesUrl": reverse_lazy("news:core:category-update", args=(0,)),
|
||||
"timezone": settings.TIME_ZONE,
|
||||
"autoMarking": self.request.user.auto_mark_read,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue