fix for UserMisc not being created. this fixes issue #1

This commit is contained in:
2017-11-22 14:24:34 +00:00
parent 286c5aa497
commit 28a2f29f5e
5 changed files with 18 additions and 14 deletions

View File

@@ -13,11 +13,12 @@ class RecentComics(Feed):
link = "/comics/"
description = "Recently added Comics"
def get_object(self, request: HttpRequest, user_selector: str) -> UserMisc:
def get_object(self, request: HttpRequest, user_selector: str, *args, **kwargs) -> UserMisc:
user_selector = uuid.UUID(bytes=urlsafe_base64_decode(user_selector))
return get_object_or_404(UserMisc, feed_id=user_selector)
def items(self) -> ComicBook:
@staticmethod
def items() -> ComicBook:
return ComicBook.objects.order_by('-date_added')[:10]
def item_title(self, item: ComicBook) -> str:

View File

@@ -1,8 +1,8 @@
from os import path
from django import forms
from django.contrib.auth.models import User
from os import path
from comic.models import Setting
@@ -233,10 +233,10 @@ class SettingsForm(forms.Form):
@staticmethod
def get_initial_values():
base_dir, created = Setting.objects.get_or_create(name='BASE_DIR')
recaptcha_public_key, created = Setting.objects.get_or_create(name='RECAPTCHA_PUBLIC_KEY')
recaptcha_private_key, created = Setting.objects.get_or_create(name='RECAPTCHA_PRIVATE_KEY')
recaptcha, created = Setting.objects.get_or_create(name='RECAPTCHA')
base_dir, _ = Setting.objects.get_or_create(name='BASE_DIR')
recaptcha_public_key, _ = Setting.objects.get_or_create(name='RECAPTCHA_PUBLIC_KEY')
recaptcha_private_key, _ = Setting.objects.get_or_create(name='RECAPTCHA_PRIVATE_KEY')
recaptcha, _ = Setting.objects.get_or_create(name='RECAPTCHA')
if recaptcha.value == '1':
recaptcha = True
else:

View File

@@ -18,7 +18,7 @@
<tr>
<th id="select-all"><input type="checkbox" id="select-all-cb"></th>
<th>
<center><span class="glyphicon glyphicon-file"></span></center>
<div style="text-align: center;"><span class="glyphicon glyphicon-file"></span></div>
</th>
<th width="100%">File/Folder</th>
<th>Date&nbsp;Added</th>
@@ -58,7 +58,7 @@ $(document).ready(function() {
var r = $(row);
var cols = $('td:nth-child(n+2)', row);
cols.attr('data-href', data['url']);
cols.attr('style', 'cursor: pointer;');;;;;;;;;;;;;;;;;;;;;;;;;;;;
cols.attr('style', 'cursor: pointer;');
cols.click(function() {
window.document.location = $(this).data("href");
});
@@ -74,7 +74,7 @@ $(document).ready(function() {
var tds = $('table tr td:first-child');
tds.click(function(event){
if (!$(event.target).is('input')) {
var $cb = $('input', this);;;;;;;;;;;;;;;;;;;;;;;;;;;;
var $cb = $('input', this);
$cb.click();
}
});
@@ -104,12 +104,12 @@ $(document).ready(function() {
});
$('#select-all').click(function(event){
var cb = $('input', this);;;;;;;;;;;;;;;;;;;;;;;;;;;;
var cb = $('input', this);
if (!$(event.target).is('input')) {
cb.click();
}
$('table tr td:first-child input').each(function(chkbx) {
row = $(this);;;;;;;;;;;;;;;;;;;;;;;;;;;;
row = $(this);
if (row.prop('checked') != cb.prop('checked')){
row.click();
}

View File

@@ -86,7 +86,7 @@ def comic_list_json(request, directory_selector=False):
@login_required
def recent_comics(request):
feed_id = UserMisc.objects.get(user=request.user)
feed_id, _ = UserMisc.objects.get_or_create(user=request.user)
return render(request,
'comic/recent_comics.html',
@@ -261,6 +261,7 @@ def user_add_page(request):
)
user.set_password(form.cleaned_data['password'])
user.save()
UserMisc.objects.create(user=user)
success_message = 'User {} created.'.format(user.username)
else:

2
requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
ujson
django