# Check mp3 in media upload path
def check_mp3(file_list, file_path):
- file_exists = [os.path.exists(os.path.join(file_path, file_name))
+ abs_file_path = os.path.join(settings.MEDIA_ROOT, file_path)
+ file_exists = [os.path.exists(os.path.join(abs_file_path, file_name))
for file_name in file_list]
missing_files = [file_name for (file_name, ok) in zip(file_list, file_exists) if not ok]
# MP3 for mix
mp3_mix_list = [mix.mp3 for mix in rec_models.Mix.objects.all()]
- check_mp3(mp3_mix_list, PODCAST_AUDIO_PATH)
+ check_mp3(mp3_mix_list, os.join(PODCAST_AUDIO_PATH)
ordered_mix_list = sorted(rec_models.Mix.objects.all(), key=lambda mix: mix.ordre)
count = 0
d = ''
print n.titre, ' - ', d
+
+ def get_year(date):
+ import parsedatime
+ cal = parsedatetime.Calendar()
+ res_date, flag = cal.parse(date)
+ if flag:
+ return res_date.tm_year, (res_date.tm_year//10) * 10
+ else:
+ return (None,None)
+
# SHOPS TO RECORDS
def populate_record(self):
self.stdout.write('Records\n-------\n')
- AUDIO_PATH = os.path.join(settings.MEDIA_ROOT, 'uploads/audio/')
+ AUDIO_PATH = 'uploads/audio/'
RECORDS_PATH = os.path.join(AUDIO_PATH, "records")
shop_list = rec_models.Shop.objects.all()
obj.country = rec_models.Country.objects.get(name = shop.pays)
obj.audio_file = os.path.join(RECORDS_PATH, shop.mp3)
# product_id --> FK
- #obj.release_date =
+ #obj.release_year =
+ # obj.release_decade =
obj.date_text = shop.date
obj.record_status = shop.new
obj.label = rec_models.Label.objects.get(name = shop.label)
--- /dev/null
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('records', '0003_record_date_text'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='record',
+ name='release_date',
+ ),
+ migrations.AddField(
+ model_name='record',
+ name='release_decade',
+ field=models.CharField(max_length=8, null=True, verbose_name='release decade', choices=[(1920, '1920s'), (1930, '1930s'), (1940, '1940s'), (1950, '1950s'), (1960, '1960s'), (1970, '1970s'), (1980, '1980s'), (1990, '1990s'), (2000, '2000s'), (2010, '2010s'), (2020, '2020s')]),
+ ),
+ migrations.AddField(
+ model_name='record',
+ name='release_year',
+ field=models.IntegerField(null=True, verbose_name='release year', choices=[(1920, 1920), (1921, 1921), (1922, 1922), (1923, 1923), (1924, 1924), (1925, 1925), (1926, 1926), (1927, 1927), (1928, 1928), (1929, 1929), (1930, 1930), (1931, 1931), (1932, 1932), (1933, 1933), (1934, 1934), (1935, 1935), (1936, 1936), (1937, 1937), (1938, 1938), (1939, 1939), (1940, 1940), (1941, 1941), (1942, 1942), (1943, 1943), (1944, 1944), (1945, 1945), (1946, 1946), (1947, 1947), (1948, 1948), (1949, 1949), (1950, 1950), (1951, 1951), (1952, 1952), (1953, 1953), (1954, 1954), (1955, 1955), (1956, 1956), (1957, 1957), (1958, 1958), (1959, 1959), (1960, 1960), (1961, 1961), (1962, 1962), (1963, 1963), (1964, 1964), (1965, 1965), (1966, 1966), (1967, 1967), (1968, 1968), (1969, 1969), (1970, 1970), (1971, 1971), (1972, 1972), (1973, 1973), (1974, 1974), (1975, 1975), (1976, 1976), (1977, 1977), (1978, 1978), (1979, 1979), (1980, 1980), (1981, 1981), (1982, 1982), (1983, 1983), (1984, 1984), (1985, 1985), (1986, 1986), (1987, 1987), (1988, 1988), (1989, 1989), (1990, 1990), (1991, 1991), (1992, 1992), (1993, 1993), (1994, 1994), (1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024)]),
+ ),
+ ]
from django.db import models
from django.utils.translation import ugettext_lazy as _
+import datetime
+
from mezzanine.core.fields import FileField
from mezzanine.core.models import CONTENT_STATUS_DRAFT, CONTENT_STATUS_PUBLISHED
from mezzanine.blog.models import BlogPost
from cartridge.shop.models import Product, ProductVariation
+
# Auto-generated Django models with manage.py inspectdb on the old database
# You'll have to do the following manually to clean this up:
# * Make sure each model has one field with primary_key=True
(ON_HOLD, 'On Hold'),
(JUST_SOLD, 'Just Sold')
)
+
+ YEAR_START = 1920
+
+ YEAR_STOP = datetime.datetime.now().year + 10
+ DECADE_START = (YEAR_START // 10) * 10
+ YEAR_CHOICES = [(y, y) for y in range(YEAR_START, YEAR_STOP)]
+ DECADE_CHOICES = [(d, str(d)+'s') for d in range (DECADE_START, YEAR_STOP, 10)]
+
title = models.CharField(max_length=128)
artist = models.ForeignKey(Artist, verbose_name=_('artist'), related_name='records_artists', null=True, on_delete=models.SET_NULL)
performers = models.ManyToManyField(Artist, verbose_name=_('performers'), related_name='records_performers')
record_status = models.IntegerField(_('record status'), choices=NOVELTY_CHOICES, default=NEW)
label = models.ForeignKey(Label, verbose_name=_('label'), related_name='records', null=True, on_delete=models.SET_NULL)
- release_date = models.DateField(_('release date'), null=True)
+ release_year = models.IntegerField(_('release year'), null=True, choices=YEAR_CHOICES)
+ release_decade = models.CharField(_('release decade'), max_length=8, null=True, choices=DECADE_CHOICES)
date_text = models.CharField(_('date text'), max_length=8, null=True)
country = models.ForeignKey(Country, verbose_name=_('country'), related_name='records', null=True, on_delete=models.SET_NULL)
#cover_state = models.ForeignKey(ConditionGrading, verbose_name=_('cover condition'), related_name='records_cover_condition', null=True, on_delete=models.SET_NULL)