]> git.0d.be Git - earwig.git/commitdiff
add initial models for channels and sounds
authorFrédéric Péters <fpeters@0d.be>
Sat, 1 Sep 2018 08:00:24 +0000 (10:00 +0200)
committerFrédéric Péters <fpeters@0d.be>
Sat, 1 Sep 2018 17:22:48 +0000 (19:22 +0200)
earwig/settings.py
earwig/sounds/__init__.py [new file with mode: 0644]
earwig/sounds/admin.py [new file with mode: 0644]
earwig/sounds/migrations/0001_initial.py [new file with mode: 0644]
earwig/sounds/migrations/__init__.py [new file with mode: 0644]
earwig/sounds/models.py [new file with mode: 0644]

index c22055c835aadeb28ecd232bd39dba80c1ad6dc5..0b9f4db1507b4be50826fdd7b74ae809bfbb54c2 100644 (file)
@@ -35,6 +35,7 @@ INSTALLED_APPS = [
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
+    'earwig.sounds',
     'earwig.users',
 ]
 
diff --git a/earwig/sounds/__init__.py b/earwig/sounds/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/earwig/sounds/admin.py b/earwig/sounds/admin.py
new file mode 100644 (file)
index 0000000..69e1aa2
--- /dev/null
@@ -0,0 +1,21 @@
+# earwig
+# Copyright (C) 2018  Frederic Peters
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from django.contrib import admin
+from .models import Channel, Sound
+
+admin.site.register(Channel)
+admin.site.register(Sound)
diff --git a/earwig/sounds/migrations/0001_initial.py b/earwig/sounds/migrations/0001_initial.py
new file mode 100644 (file)
index 0000000..6525616
--- /dev/null
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.11 on 2018-09-01 08:53
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Channel',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('channel_url', models.URLField(verbose_name='Channel URL')),
+                ('title', models.CharField(max_length=200, verbose_name='Title')),
+                ('feed_url', models.URLField(blank=True, verbose_name='Feed URL')),
+                ('creation_timestamp', models.DateTimeField(auto_now_add=True)),
+                ('last_update_timestamp', models.DateTimeField(auto_now=True)),
+            ],
+        ),
+        migrations.CreateModel(
+            name='Sound',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('sound_url', models.URLField(verbose_name='Sound URL')),
+                ('title', models.CharField(max_length=200, verbose_name='Title')),
+                ('description', models.TextField(blank=True, verbose_name='Description')),
+                ('page_url', models.URLField(blank=True, verbose_name='Page URL')),
+                ('uuid', models.CharField(blank=True, max_length=200, null=True, verbose_name='Unique Identifier')),
+                ('original_publication_date', models.DateTimeField(blank=True, null=True, verbose_name='Original Publication Date')),
+                ('file_type', models.CharField(blank=True, max_length=20, null=True, verbose_name='File Type')),
+                ('file_size', models.IntegerField(blank=True, null=True, verbose_name='File Size')),
+                ('duration', models.IntegerField(blank=True, null=True, verbose_name='Duration')),
+                ('creation_timestamp', models.DateTimeField(auto_now_add=True)),
+                ('last_update_timestamp', models.DateTimeField(auto_now=True)),
+                ('channel', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sounds.Channel')),
+            ],
+        ),
+    ]
diff --git a/earwig/sounds/migrations/__init__.py b/earwig/sounds/migrations/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/earwig/sounds/models.py b/earwig/sounds/models.py
new file mode 100644 (file)
index 0000000..93fe3fe
--- /dev/null
@@ -0,0 +1,51 @@
+# earwig
+# Copyright (C) 2018  Frederic Peters
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+
+class Channel(models.Model):
+    channel_url = models.URLField(_('Channel URL'))
+    title = models.CharField(_('Title'), max_length=200)
+    feed_url = models.URLField(_('Feed URL'), blank=True)
+
+    creation_timestamp = models.DateTimeField(auto_now_add=True)
+    last_update_timestamp = models.DateTimeField(auto_now=True)
+
+    def __str__(self):
+        return self.title
+
+
+class Sound(models.Model):
+    sound_url = models.URLField(_('Sound URL'))
+    title = models.CharField(_('Title'), max_length=200)
+    description = models.TextField(_('Description'), blank=True)
+    page_url = models.URLField(_('Page URL'), blank=True)
+    uuid = models.CharField(_('Unique Identifier'), max_length=200, blank=True, null=True)
+    channel = models.ForeignKey('Channel', on_delete=models.SET_NULL, blank=True, null=True)
+
+    original_publication_date = models.DateTimeField(
+            _('Original Publication Date'), blank=True, null=True)
+    file_type = models.CharField(_('File Type'), max_length=20, blank=True, null=True)
+    file_size = models.IntegerField(_('File Size'), blank=True, null=True)
+    duration = models.IntegerField(_('Duration'), blank=True, null=True)  # in seconds
+
+    creation_timestamp = models.DateTimeField(auto_now_add=True)
+    last_update_timestamp = models.DateTimeField(auto_now=True)
+
+    def __str__(self):
+        return self.title