예제 #1
0
class MiniSong(forms.ModelForm):
    # Used in album view for a quick add.
    comp_artist = ajax.ArtistField(required=False, label=u'Artist')
    album = forms.ModelChoiceField(models.Album.objects.all(),
                                   widget=forms.HiddenInput())

    def clean(self):
        data = self.cleaned_data
        if self._errors.get('comp_artist') is None and data[
                'comp_artist'] is None and data.get(
                    'album') and data['album'].artist is None:
            self._errors['comp_artist'] = forms.util.ErrorList(
                ['All songs on a compilation require an artist'])
            del data['comp_artist']
        return data

    class Media:
        js = (
            'jquery.js',
            'dj_pro/add_new_song.js',
        )

    class Meta:
        model = models.Song
        fields = (
            'album',
            'song',
            'comp_artist',
        )
예제 #2
0
class Album(forms.ModelForm):
    artist = ajax.ArtistField(required=False)

    class Media:
        css = {'all': ('jquery.autocomplete.css', )}
        js = ('jquery.js', 'jquery-ui.js', 'jquery.combobox.js',
              'dj_pro/ages.js', 'dj_pro/genres_ajax.js')

    class Meta:
        model = models.Album
        fields = ('album', 'artist', 'label', 'year', 'review', 'location',
                  'genres')
예제 #3
0
class Song(forms.ModelForm):
    rating = forms.TypedChoiceField(required=False,
                                    choices=(('', u''), (2, u'★'), (3, u'★★'),
                                             (4, u'★★★'), (5, u'★★★★'),
                                             (0, u'dirty')),
                                    label=u'Rating',
                                    coerce=int,
                                    empty_value=1)
    comp_artist = ajax.ArtistField(required=False, label=u'Artist')

    def clean(self):
        data = self.cleaned_data
        if self._errors.get('comp_artist') is None and data[
                'comp_artist'] is None and data['album'].artist is None:
            self._errors['comp_artist'] = forms.util.ErrorList(
                [u'All songs on a compilation require an artist'])
            del data['comp_artist']
        return data

    class Meta:
        model = models.Song
        fields = ('track', 'song', 'comp_artist', 'length', 'ramp', 'post',
                  'tempo', 'rating', 'album')
예제 #4
0
class SongForm(forms.forms.ModelForm):
    class Meta:
        model = models.Song
    
    comp_artist = ajax.ArtistField(required=False, label=u'Artist')
예제 #5
0
class FindOtherArtistForm(forms.forms.Form):
    # I want to find a way to make this *not* return the current 
    # artist.
    entry = ajax.ArtistField()