-
{% trans "Metadata" %}
-
{{ form.title }}
- {% for error in form.title.errors %}
-
{{ error | escape }}
- {% endfor %}
-
{{ form.subtitle }}
- {% for error in form.subtitle.errors %}
-
{{ error | escape }}
- {% endfor %}
-
{{ form.description }}
- {% for error in form.description.errors %}
-
{{ error | escape }}
- {% endfor %}
-
{{ form.series }}
- {% for error in form.series.errors %}
-
{{ error | escape }}
- {% endfor %}
-
{{ form.series_number }}
- {% for error in form.series_number.errors %}
-
{{ error | escape }}
- {% endfor %}
-
{{ form.first_published_date }}
- {% for error in form.first_published_date.errors %}
-
{{ error | escape }}
- {% endfor %}
-
{{ form.published_date }}
- {% for error in form.published_date.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% trans "Metadata" %}
+ {{ form.title }}
+ {% for error in form.title.errors %}
+ {{ error | escape }}
+ {% endfor %}
+ {{ form.subtitle }}
+ {% for error in form.subtitle.errors %}
+ {{ error | escape }}
+ {% endfor %}
+ {{ form.description }}
+ {% for error in form.description.errors %}
+ {{ error | escape }}
+ {% endfor %}
+ {{ form.series }}
+ {% for error in form.series.errors %}
+ {{ error | escape }}
+ {% endfor %}
+ {{ form.series_number }}
+ {% for error in form.series_number.errors %}
+ {{ error | escape }}
+ {% endfor %}
+ {{ form.first_published_date }}
+ {% for error in form.first_published_date.errors %}
+ {{ error | escape }}
+ {% endfor %}
+ {{ form.published_date }}
+ {% for error in form.published_date.errors %}
+ {{ error | escape }}
+ {% endfor %}
+
+
+
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py
index a741088a..dfb64c23 100644
--- a/bookwyrm/urls.py
+++ b/bookwyrm/urls.py
@@ -134,6 +134,7 @@ urlpatterns = [
re_path(r'^add-description/(?P
\d+)/?$', views.add_description),
re_path(r'^resolve-book/?$', views.resolve_book),
re_path(r'^switch-edition/?$', views.switch_edition),
+ re_path(r'^create-book/?$', views.EditBook.as_view()),
# author
re_path(r'^author/(?P\d+)(.json)?/?$', views.Author.as_view()),
diff --git a/bookwyrm/views/books.py b/bookwyrm/views/books.py
index 4d6afba9..1754982e 100644
--- a/bookwyrm/views/books.py
+++ b/bookwyrm/views/books.py
@@ -106,28 +106,40 @@ class Book(View):
name='dispatch')
class EditBook(View):
''' edit a book '''
- def get(self, request, book_id):
+ def get(self, request, book_id=None):
''' info about a book '''
- book = get_edition(book_id)
- if not book.description:
- book.description = book.parent_work.description
+ book = None
+ if book_id:
+ book = get_edition(book_id)
+ if not book.description:
+ book.description = book.parent_work.description
data = {
'book': book,
'form': forms.EditionForm(instance=book)
}
return TemplateResponse(request, 'edit_book.html', data)
- def post(self, request, book_id):
+ def post(self, request, book_id=None):
''' edit a book cool '''
- book = get_object_or_404(models.Edition, id=book_id)
-
+ book = get_object_or_404(models.Edition, id=book_id) if book_id \
+ else None
form = forms.EditionForm(request.POST, request.FILES, instance=book)
+
+ data = {
+ 'book': book,
+ 'form': form
+ }
if not form.is_valid():
- data = {
- 'book': book,
- 'form': form
- }
return TemplateResponse(request, 'edit_book.html', data)
+
+ if not book or form.author:
+ # creting a book or adding an author to a book needs another step
+ return TemplateResponse(request, 'confirm_book.html', data)
+
+ # remove authors
+ if request.POST.get('remove-author'):
+ import pdb;pdb.set_trace()
+ author = get_object_or_404(id=author_id)
book = form.save()
return redirect('/book/%s' % book.id)