Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks and fixes #73

Merged
merged 27 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
120cbf4
Settings: Remove title uniqueness constraint
tobyspark Jun 21, 2018
9a8f45d
Fix: profile page previews
tobyspark Jun 21, 2018
f2777ba
abcjs 5.1.2
tobyspark Jun 21, 2018
495ca5d
downloadClass fix in 5.1.2-min.js
tobyspark Jun 21, 2018
9e337cd
Two missed redirect back here on login links
tobyspark Jun 21, 2018
4bca3a7
fix: backup error typo
tobyspark Jun 21, 2018
6b14d3d
backup: excludes contenttypes etc.
tobyspark Jun 21, 2018
2aa69d8
Enforce X: values on creation through post_save signal
tobyspark Jun 28, 2018
71832e1
ABCModel will set X: when no X: found
tobyspark Jun 28, 2018
45f5151
Idomatic setting validation; e.g. works in admin too
tobyspark Jun 28, 2018
34f515a
Idomatic tune validation; e.g. works in admin too
tobyspark Jun 28, 2018
324f65a
Make ABC validity optional
tobyspark Jun 29, 2018
879d14b
Remove error display on uncheck of 'check abc'
tobyspark Jun 29, 2018
7a8251f
Set X: on every save
tobyspark Jun 29, 2018
84ceeeb
Fix: auto_x naming clash
tobyspark Jun 29, 2018
01476a5
Transliterate unicode to ASCII chars for ABC conform
tobyspark Jul 2, 2018
11ccc9c
folk-rnn archive records valid_abc on archival
tobyspark Jul 2, 2018
0ec2478
Add attribution S,F information fields to downloaded ABC
tobyspark Jul 3, 2018
d401062
ABCModel tidy-up
tobyspark Jul 3, 2018
05a2437
Archiver Model tidy-up
tobyspark Jul 3, 2018
6dbfd1f
Pass unit note length field in abc preview
tobyspark Jul 3, 2018
3eca26b
Dataset tidy-up
tobyspark Jul 3, 2018
1556176
Forms tidy-up
tobyspark Jul 3, 2018
aefeb5b
Fix: javascript error with anonymous user
tobyspark Jul 3, 2018
d8e71ab
Rationalise abcjs-headend include
tobyspark Jul 4, 2018
452d6a5
/tune correctness
tobyspark Jul 4, 2018
aa7fea5
Errant (but inconsequential) space in ABC X: setter
tobyspark Jul 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion folk_rnn_site/archiver/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

from archiver.models import Tune, Setting

Datum = namedtuple('SettingDatum', [
"""
Datum is a superset of (what we want out of) a tune and setting
e.g. the columns in a CSV of tunes and settings
"""
Datum = namedtuple('Datum', [
'tune_id',
'setting_id',
'name',
Expand All @@ -17,6 +21,9 @@
])

def tune_dataset():
"""
Return a generator of Tune Data
"""
return (Datum(tune_id=x.id,
setting_id='',
name=x.title,
Expand All @@ -30,6 +37,9 @@ def tune_dataset():
) for x in Tune.objects.all())

def setting_dataset():
"""
Return a generator Setting Data
"""
return (Datum(tune_id=x.tune.id,
setting_id=x.id,
name=x.title,
Expand All @@ -43,6 +53,9 @@ def setting_dataset():
) for x in Setting.objects.all())

def dataset_as_csv(f):
"""
Write tune and setting data in comma separated value format to the supplied file handle
"""
setting_writer = csv.writer(f)
setting_writer.writerow(Datum._fields)
setting_writer.writerows(tune_dataset())
Expand Down
69 changes: 49 additions & 20 deletions folk_rnn_site/archiver/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,87 @@

from folk_rnn_site.models import conform_abc
from archiver import YEAR_CHOICES
from archiver.models import User
from archiver.models import User, Tune, TuneAttribution, Setting

class AttributionForm(forms.Form):
text = forms.CharField(required=False)
url = forms.URLField(required=False)

class SettingForm(forms.Form):
abc = forms.CharField(label='', widget=forms.Textarea(attrs={'id': 'abc'}))
class SettingForm(forms.ModelForm):
"""
User input to create a Setting
"""
class Meta:
model = Setting
fields = ['abc', 'check_valid_abc']

class CommentForm(forms.Form):
"""
User input to create a Comment
"""
text = forms.CharField(label='Comment:', widget=forms.Textarea(attrs={'id': 'new_comment'}))

class ContactForm(forms.Form):
"""
For sending a message to site admins
"""
text = forms.CharField(widget=forms.Textarea())
email = forms.EmailField(required=False)

class TuneForm(forms.Form):
abc = forms.CharField(widget=forms.Textarea())
text = forms.CharField(widget=forms.Textarea())
url = forms.URLField(required=False)

def clean_abc(self):
try:
abc = conform_abc(self.cleaned_data['abc'])
except AttributeError as e:
raise forms.ValidationError(e)
return abc
class TuneForm(forms.ModelForm):
"""
User input to create a Tune
"""
class Meta:
model = Tune
fields = ['abc', 'check_valid_abc']

class TuneAttributionForm(forms.ModelForm):
"""
User input to create a TuneAttribution
"""
class Meta:
model = TuneAttribution
fields = ['text', 'url']

class RecordingForm(forms.Form):
"""
User input to create a Recording
"""
title = forms.CharField()
body = forms.CharField(widget=forms.Textarea())
date = forms.DateField(widget=SelectDateWidget(years=YEAR_CHOICES))
url = EmbedVideoFormField()

class EventForm(forms.Form):
"""
User input to create an Event
"""
title = forms.CharField()
body = forms.CharField(widget=forms.Textarea())
date = forms.DateField(widget=SelectDateWidget(years=YEAR_CHOICES))

class TunebookForm(forms.Form):
"""
User input for 'In your tunebook:'
"""
add = forms.BooleanField(required=False)

class SearchForm(forms.Form):
"""
User input for search field
"""
search = forms.CharField(required=False)

# As per registration docs, this should subclass registration.forms.RegistrationFormUniqueEmail.
# That wasn't working, so here instead is an equivalent, based on some of that code.
def validate_duplicate_email(value):
"""
Raise if value is an existing email address
"""
if User.objects.filter(email__iexact=value):
raise forms.ValidationError(validators.DUPLICATE_EMAIL, code='invalid')

class RegistrationForm(UserCreationForm):
"""
User input for sign-up
As per registration docs, this should be a minimal subclass of registration.forms.RegistrationFormUniqueEmail.
However that wasn't working, so this instead is an equivalent, based on some of that code.
"""
class Meta:
model = User
fields = [
Expand Down
25 changes: 25 additions & 0 deletions folk_rnn_site/archiver/migrations/0010_auto_20180629_0944.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-06-29 09:44
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('archiver', '0009_tunebookentry'),
]

operations = [
migrations.AddField(
model_name='setting',
name='check_valid_abc',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='tune',
name='check_valid_abc',
field=models.BooleanField(default=True),
),
]
Loading