Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit 8ffd2e3

Browse files
committed
Merge pull request #232 from editorsnotes/dev
Finish replacing form admin with JS <=> API interface.
2 parents 0fd763a + 359b4dc commit 8ffd2e3

File tree

232 files changed

+25226
-17274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+25226
-17274
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ before_script:
2222
- psql -c "CREATE DATABASE testdb;" -U postgres
2323

2424
script:
25-
- python manage.py test main api admin
25+
- python manage.py test main api

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ and make sure you have the following dependencies
1414
2. Edit the generated "editorsnotes/settings\_local.py" file with your database information
1515
3. Run `fab sync_database`
1616
4. Start the development server with `fab runserver`
17+
18+
## Browser compatibility
19+
Editors' Notes is tested against the latest versions of Firefox, Chrome, Safari, and Opera, as well as Internet Explorer 10+.
20+
21+
[![browser support](https://ci.testling.com/editorsnotes/editorsnotes.png)
22+
](https://ci.testling.com/editorsnotes/editorsnotes)

editorsnotes/admin/fields.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

editorsnotes/admin/forms/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
from common import *
21
from documents import *
3-
from notes import *
42
from projects import *
5-
from topics import *

editorsnotes/admin/forms/common.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

editorsnotes/admin/forms/documents.py

Lines changed: 1 addition & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -3,137 +3,7 @@
33
from django import forms
44
from django.forms.models import ModelForm, inlineformset_factory
55

6-
from editorsnotes.djotero.widgets import ZoteroWidget
7-
from editorsnotes.djotero.models import ZoteroLink
8-
from editorsnotes.main.models import (
9-
Document, DocumentLink, Scan, Transcript, Footnote)
10-
11-
from ..fields import MultipleFileInput
12-
13-
class DocumentForm(ModelForm):
14-
zotero_string = forms.CharField(required=False, widget=ZoteroWidget())
15-
class Media:
16-
js = (
17-
"function/admin-bootstrap-document.js",
18-
)
19-
class Meta:
20-
model = Document
21-
fields = ('description', 'edtf_date',)
22-
widgets = {
23-
'edtf_date': forms.widgets.HiddenInput()
24-
}
25-
26-
def __init__(self, *args, **kwargs):
27-
super(DocumentForm, self).__init__(*args, **kwargs)
28-
29-
if kwargs.has_key('instance'):
30-
document = kwargs['instance']
31-
self.initial['zotero_string'] = document.zotero_data or ''
32-
33-
def save_zotero_data(self):
34-
document = self.instance
35-
if self.data.get('zotero-data-DELETE', '') == 'DELETE':
36-
document.zotero_data = None
37-
document.save()
38-
if document.zotero_link is not None:
39-
document.zotero_link.delete()
40-
elif self.changed_data is not None and 'zotero_string' in self.changed_data:
41-
document.zotero_data = self.cleaned_data['zotero_string']
42-
document.save()
43-
if not document.zotero_link:
44-
ZoteroLink.objects.create(zotero_item=document)
45-
else:
46-
document.zotero_link.save()
47-
return document
48-
49-
class DocumentLinkForm(ModelForm):
50-
class Meta:
51-
model = DocumentLink
52-
exclude = ('affiliated_projects',)
53-
widgets = {
54-
'description': forms.widgets.Textarea(
55-
attrs={ 'cols': 80, 'rows': 2 })
56-
}
57-
DocumentLinkFormset = inlineformset_factory(
58-
Document, DocumentLink, form=DocumentLinkForm, extra=1)
59-
60-
class ScanForm(ModelForm):
61-
class Meta:
62-
fields = ('image', 'ordering')
63-
model = Scan
64-
widgets = {
65-
'image': MultipleFileInput(),
66-
'ordering': forms.HiddenInput()
67-
}
68-
69-
class ScanFormset(forms.models.BaseInlineFormSet):
70-
"""
71-
If multiple images were posted from a single file input with the attribute
72-
"multiple", this formset will split them up into regular forms
73-
"""
74-
def _construct_forms(self):
75-
self.forms = []
76-
forms_from_multiple_input = []
77-
78-
for i in xrange(self.total_form_count()):
79-
form = self._construct_form(i)
80-
81-
# Only pay attention to multiple files from an input if this is the
82-
# last image field and there is something to save
83-
if (i < self.total_form_count() - 1 or not form.files):
84-
self.forms.append(form)
85-
continue
86-
87-
# If only one image was posted from this input, treat it as a normal
88-
# one. This allows us to treat this formset as it normally would be,
89-
# which is beneficial for several reasons, including continued
90-
# support for browsers that don't support the "multiple" attribute.
91-
images = form.files.getlist('%s-image' % form.prefix)
92-
if len(images) == 1:
93-
self.forms.append(form)
94-
continue
95-
96-
# Make a copy of the file & data dictionaries, which will be amended
97-
# in order to make new ScanForm instances
98-
newfiles = dict((k, v) for k, v in form.files.items())
99-
newdata = dict((k, v) for k, v in form.data.items())
100-
101-
# Pretend that each image was posted individually
102-
j = i
103-
for image in images:
104-
prefix = self.add_prefix(j)
105-
newfiles['%s-image' % prefix] = image
106-
newdata['%s-ordering' % prefix] = j
107-
newform = self._construct_form(j, files=newfiles, data=newdata)
108-
forms_from_multiple_input.append(newform)
109-
j += 1
110-
111-
# Only add these new forms to the formset if the images are valid. This
112-
# does go against the normal flow of validation, but it makes the
113-
# workflow for adding scans *much* less complicated to take an
114-
# all-or-nothing approach to accepting multiple images.
115-
if all(map(lambda f: f.is_valid(), forms_from_multiple_input)):
116-
self.forms += forms_from_multiple_input
117-
else:
118-
# Make the last form an empty one, like it was previously
119-
self.forms.append(
120-
self._construct_form(self.total_form_count() - 1, files=None))
121-
self.bad_multi_images = 'One or more files uploaded were not valid images.'
122-
123-
# Does the management form need to be changed at all? I can't think of
124-
# any situation where it would be, but here's how it probably would be
125-
# done if needed.
126-
# self.management_form['initial']['TOTAL_FORMS'] = len(self.forms)
127-
128-
# Display errors from a multiple upload field as a non-form error-- in the
129-
# formset, not the individual form
130-
def clean(self):
131-
if hasattr(self, 'bad_multi_images'):
132-
raise forms.ValidationError(self.bad_multi_images)
133-
134-
ScanFormset = inlineformset_factory(
135-
Document, Scan,
136-
form=ScanForm, formset=ScanFormset, extra=1)
6+
from editorsnotes.main.models import Transcript, Footnote
1377

1388
class TranscriptForm(ModelForm):
1399
class Media:

editorsnotes/admin/forms/notes.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

editorsnotes/admin/forms/topics.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

editorsnotes/admin/static/function/admin-bootstrap-base.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ $(document).ready(function () {
8888
.on('click', '.collapsable legend', function () {
8989
var $this = $(this);
9090
$this.toggleClass('.collapsed')
91-
.find('i').toggleClass('icon-plus icon-minus');
91+
.find('i').toggleClass('fa-plus fa-minus');
9292
$this.siblings('.fieldset-content').toggle();
9393
})
9494

@@ -108,7 +108,7 @@ $(document).ready(function () {
108108
.css('cursor', 'pointer')
109109
.each(function () {
110110
$('<i>', {
111-
'class': 'icon-minus',
111+
'class': 'fa fa-minus',
112112
'css': {'margin': '6px 0 0 3px'}
113113
}).appendTo(this);
114114
})
@@ -122,7 +122,7 @@ $(document).ready(function () {
122122
$('<a>', {
123123
'class': 'remove-related-topic',
124124
'href': '#',
125-
'html': '<i class="icon-remove-sign"></i>'
125+
'html': '<i class="fa fa-times-circle"></i>'
126126
}).appendTo($(this).hide().parents('.topicassignment'));
127127
});
128128

editorsnotes/admin/static/function/admin-bootstrap-document.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)