mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 08:36:32 +00:00
Add a form to upload goodreads data.
This commit is contained in:
parent
ea735fd570
commit
8bcd3da25e
5 changed files with 25 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
''' usin django model forms '''
|
''' usin django model forms '''
|
||||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||||
from django.forms import ModelForm, PasswordInput, IntegerField
|
from django.forms import ModelForm, PasswordInput, IntegerField
|
||||||
|
from django import forms
|
||||||
|
|
||||||
from fedireads import models
|
from fedireads import models
|
||||||
|
|
||||||
|
@ -73,3 +74,6 @@ class TagForm(ModelForm):
|
||||||
help_texts = {f: None for f in fields}
|
help_texts = {f: None for f in fields}
|
||||||
labels = {'name': 'Add a tag'}
|
labels = {'name': 'Add a tag'}
|
||||||
|
|
||||||
|
|
||||||
|
class ImportForm(forms.Form):
|
||||||
|
csv_file = forms.FileField()
|
||||||
|
|
10
fedireads/templates/import.html
Normal file
10
fedireads/templates/import.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{% extends 'layout.html' %}
|
||||||
|
{% block content %}
|
||||||
|
<div id="content">
|
||||||
|
<form name="import" action="/import_data/" method="post" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ import_form.as_p }}
|
||||||
|
<button type="submit">Import</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -29,6 +29,7 @@
|
||||||
<li><a href="/user/{{request.user.localname}}/shelves">Your shelves</a></li>
|
<li><a href="/user/{{request.user.localname}}/shelves">Your shelves</a></li>
|
||||||
<li><a href="/#feed">Updates</a></li>
|
<li><a href="/#feed">Updates</a></li>
|
||||||
<li><a href="/books">Discover Books</a></li>
|
<li><a href="/books">Discover Books</a></li>
|
||||||
|
<li><a href="/import">Import Books</a><li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div id="actions">
|
<div id="actions">
|
||||||
|
|
|
@ -34,6 +34,7 @@ urlpatterns = [
|
||||||
re_path(r'^(?P<tab>home|local|federated)/?$', views.home_tab),
|
re_path(r'^(?P<tab>home|local|federated)/?$', views.home_tab),
|
||||||
re_path(r'^notifications/?', views.notifications_page),
|
re_path(r'^notifications/?', views.notifications_page),
|
||||||
re_path(r'books/?$', views.books_page),
|
re_path(r'books/?$', views.books_page),
|
||||||
|
re_path(r'import/?$', views.import_page),
|
||||||
|
|
||||||
# should return a ui view or activitypub json blob as requested
|
# should return a ui view or activitypub json blob as requested
|
||||||
# users
|
# users
|
||||||
|
@ -81,5 +82,6 @@ urlpatterns = [
|
||||||
re_path(r'^accept_follow_request/?$', actions.accept_follow_request),
|
re_path(r'^accept_follow_request/?$', actions.accept_follow_request),
|
||||||
re_path(r'^delete_follow_request/?$', actions.delete_follow_request),
|
re_path(r'^delete_follow_request/?$', actions.delete_follow_request),
|
||||||
|
|
||||||
|
re_path(r'import_data', actions.import_data),
|
||||||
|
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
|
@ -108,6 +108,14 @@ def books_page(request):
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, 'books.html', data)
|
return TemplateResponse(request, 'books.html', data)
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def import_page(request):
|
||||||
|
''' import history from goodreads '''
|
||||||
|
return TemplateResponse(request, 'import.html', {
|
||||||
|
'import_form': forms.ImportForm(),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def login_page(request):
|
def login_page(request):
|
||||||
''' authentication '''
|
''' authentication '''
|
||||||
|
|
Loading…
Reference in a new issue