bisac adding now works
parent
1df3cfee79
commit
b5bae66f08
|
@ -69,6 +69,7 @@ from regluit.utils.localdatetime import now
|
|||
from regluit.utils.fields import EpubFileField, ISBNField
|
||||
from regluit.mobi import Mobi
|
||||
from regluit.pyepub import EPUB
|
||||
from regluit.bisac.models import BisacHeading
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
nulls = [False, 'delete', '']
|
||||
|
@ -78,10 +79,16 @@ CREATOR_RELATIONS = (
|
|||
('trl', 'Translator'),
|
||||
('ill', 'Illustrator'),
|
||||
)
|
||||
|
||||
bisac_headings = BisacHeading.objects.all()
|
||||
|
||||
|
||||
class EditionForm(forms.ModelForm):
|
||||
add_author = forms.CharField(max_length=500, required=False)
|
||||
add_author_relation = forms.ChoiceField(choices=CREATOR_RELATIONS, initial=('aut', 'Author'))
|
||||
add_subject = forms.CharField(max_length=200, required=False)
|
||||
bisac = forms.ModelChoiceField( bisac_headings, required=False )
|
||||
|
||||
publisher_name = AutoCompleteSelectField(
|
||||
PublisherNameLookup,
|
||||
label='Publisher Name',
|
||||
|
|
|
@ -3,9 +3,56 @@
|
|||
|
||||
{% block extra_extra_head %}
|
||||
{{ block.super }}
|
||||
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="/static/css/ui-lightness/jquery-ui-1.8.16.custom.css" type="text/css" media="screen">
|
||||
<link href="/static/css/ui.fancytree.min.css" rel="stylesheet" type="text/css">
|
||||
<style type="text/css">
|
||||
ul.fancytree-container {
|
||||
width: 100%;
|
||||
height: 10em;
|
||||
overflow: auto;
|
||||
position: relative;
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
</style>
|
||||
{{ form.media.css }}
|
||||
<script type="text/javascript" src="{{ jquery_ui_home }}" ></script>
|
||||
<script src="/static/js/jquery.fancytree-all.min.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
$j(function(){
|
||||
// Initialize Fancytree
|
||||
$j("#tree").fancytree({
|
||||
extensions: ["glyph"],
|
||||
checkbox: true,
|
||||
selectMode: 1,
|
||||
glyph: {
|
||||
map: {
|
||||
doc: "fa fa-file-o",
|
||||
docOpen: "fa fa-file-o",
|
||||
checkbox: "fa fa-square-o",
|
||||
checkboxSelected: "fa fa-check-square-o",
|
||||
checkboxUnknown: "fa fa-square",
|
||||
dragHelper: "fa arrow-right",
|
||||
dropMarker: "fa long-arrow-right",
|
||||
error: "fa fa-warning",
|
||||
expanderClosed: "fa fa-caret-right",
|
||||
expanderLazy: "fa fa-angle-right",
|
||||
expanderOpen: "fa fa-caret-down",
|
||||
folder: "fa fa-folder-o",
|
||||
folderOpen: "fa fa-folder-open-o",
|
||||
loading: "fa fa-spinner fa-pulse"
|
||||
}
|
||||
},
|
||||
source: { url: "/bisac/tree", cache: true }
|
||||
});
|
||||
$j("#editform").submit(function() {
|
||||
// Render hidden <input> elements for active and selected nodes
|
||||
$j("#tree").fancytree("getTree").generateFormElements(selected="bisac");
|
||||
//alert("POST data:\n" + $j.param($j(this).serializeArray()));
|
||||
return true;
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
{{ form.media.js }}
|
||||
{% endblock %}
|
||||
|
@ -95,6 +142,12 @@
|
|||
<b>Add a Subject</b>: {{ form.add_subject.errors }}{{ form.add_subject }}
|
||||
<input type="submit" name="add_subject_submit" value="Add Subject" id="submit_subject"></p>
|
||||
{% endcomment %}
|
||||
<p id="tree" name="is_bisac"><b>Add BISAC Subject</b>:
|
||||
{% for bisacsh in edition.work.bisac_headings %}
|
||||
<br />{{ bisacsh.name }}
|
||||
{% endfor %}<br /><br /><b>add headings</b>:
|
||||
</p>
|
||||
|
||||
<p><b>Cover Image</b>: <br />
|
||||
{% if edition.cover_image %}
|
||||
<img src="{{edition.cover_image}}" /><br />
|
||||
|
|
|
@ -493,6 +493,13 @@ def edition_uploads(request, edition_id):
|
|||
})
|
||||
return render(request, 'edition_uploads.html', context )
|
||||
|
||||
def add_subject(subject_name,work, authority=None):
|
||||
try:
|
||||
subject= models.Subject.objects.get(name=subject_name)
|
||||
except models.Subject.DoesNotExist:
|
||||
subject=models.Subject.objects.create(name=subject_name, authority=authority)
|
||||
subject.works.add(work)
|
||||
|
||||
@login_required
|
||||
def new_edition(request, work_id, edition_id, by=None):
|
||||
if not request.user.is_authenticated() :
|
||||
|
@ -617,12 +624,13 @@ def new_edition(request, work_id, edition_id, by=None):
|
|||
relator.set(new_relation)
|
||||
for (author_name, author_relation) in edition.new_authors:
|
||||
edition.add_author(author_name,author_relation)
|
||||
if form.cleaned_data.has_key('bisac'):
|
||||
bisacsh=form.cleaned_data['bisac']
|
||||
while bisacsh:
|
||||
add_subject(bisacsh.full_label, work, authority="bisacsh")
|
||||
bisacsh = bisacsh.parent
|
||||
for subject_name in edition.new_subjects:
|
||||
try:
|
||||
subject= models.Subject.objects.get(name=subject_name)
|
||||
except models.Subject.DoesNotExist:
|
||||
subject=models.Subject.objects.create(name=subject_name)
|
||||
subject.works.add(work)
|
||||
add_subject(subject_name, work)
|
||||
work_url = reverse('work', kwargs={'work_id': edition.work.id})
|
||||
cover_file=form.cleaned_data.get("coverfile",None)
|
||||
if cover_file:
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue