Format code using black

This commit is contained in:
jo 2021-05-27 16:23:02 +02:00
parent efe4fa027e
commit c27f020d73
85 changed files with 3238 additions and 2243 deletions

View file

@ -15,18 +15,20 @@ class LoginAttempt(models.Model):
class Meta:
managed = False
db_table = 'cc_login_attempts'
db_table = "cc_login_attempts"
class Session(models.Model):
sessid = models.CharField(primary_key=True, max_length=32)
userid = models.ForeignKey('User', models.DO_NOTHING, db_column='userid', blank=True, null=True)
userid = models.ForeignKey(
"User", models.DO_NOTHING, db_column="userid", blank=True, null=True
)
login = models.CharField(max_length=255, blank=True, null=True)
ts = models.DateTimeField(blank=True, null=True)
class Meta:
managed = False
db_table = 'cc_sess'
db_table = "cc_sess"
USER_TYPE_CHOICES = ()
@ -35,12 +37,14 @@ for item in USER_TYPES.items():
class User(AbstractBaseUser):
username = models.CharField(db_column='login', unique=True, max_length=255)
password = models.CharField(db_column='pass', max_length=255) # Field renamed because it was a Python reserved word.
username = models.CharField(db_column="login", unique=True, max_length=255)
password = models.CharField(
db_column="pass", max_length=255
) # Field renamed because it was a Python reserved word.
type = models.CharField(max_length=1, choices=USER_TYPE_CHOICES)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
last_login = models.DateTimeField(db_column='lastlogin', blank=True, null=True)
last_login = models.DateTimeField(db_column="lastlogin", blank=True, null=True)
lastfail = models.DateTimeField(blank=True, null=True)
skype_contact = models.CharField(max_length=1024, blank=True, null=True)
jabber_contact = models.CharField(max_length=1024, blank=True, null=True)
@ -48,13 +52,13 @@ class User(AbstractBaseUser):
cell_phone = models.CharField(max_length=1024, blank=True, null=True)
login_attempts = models.IntegerField(blank=True, null=True)
USERNAME_FIELD = 'username'
EMAIL_FIELD = 'email'
REQUIRED_FIELDS = ['type', 'email', 'first_name', 'last_name']
USERNAME_FIELD = "username"
EMAIL_FIELD = "email"
REQUIRED_FIELDS = ["type", "email", "first_name", "last_name"]
objects = UserManager()
def get_full_name(self):
return '{} {}'.format(self.first_name, self.last_name)
return "{} {}".format(self.first_name, self.last_name)
def get_short_name(self):
return self.first_name
@ -66,7 +70,7 @@ class User(AbstractBaseUser):
self.password = hashlib.md5(password.encode()).hexdigest()
def is_staff(self):
print('is_staff')
print("is_staff")
return self.type == ADMIN
def check_password(self, password):
@ -82,6 +86,7 @@ class User(AbstractBaseUser):
(managed = True), then this can be replaced with
django.contrib.auth.models.PermissionMixin.
"""
def is_superuser(self):
return self.type == ADMIN
@ -125,7 +130,7 @@ class User(AbstractBaseUser):
class Meta:
managed = False
db_table = 'cc_subjs'
db_table = "cc_subjs"
class UserToken(models.Model):
@ -139,4 +144,4 @@ class UserToken(models.Model):
class Meta:
managed = False
db_table = 'cc_subjs_token'
db_table = "cc_subjs_token"

View file

@ -4,11 +4,13 @@ from django.db import models
class CeleryTask(models.Model):
task_id = models.CharField(max_length=256)
track_reference = models.ForeignKey('ThirdPartyTrackReference', models.DO_NOTHING, db_column='track_reference')
track_reference = models.ForeignKey(
"ThirdPartyTrackReference", models.DO_NOTHING, db_column="track_reference"
)
name = models.CharField(max_length=256, blank=True, null=True)
dispatch_time = models.DateTimeField(blank=True, null=True)
status = models.CharField(max_length=256)
class Meta:
managed = False
db_table = 'celery_tasks'
db_table = "celery_tasks"

View file

@ -8,5 +8,4 @@ class Country(models.Model):
class Meta:
managed = False
db_table = 'cc_country'
db_table = "cc_country"

View file

@ -6,11 +6,20 @@ class File(models.Model):
name = models.CharField(max_length=255)
mime = models.CharField(max_length=255)
ftype = models.CharField(max_length=128)
directory = models.ForeignKey('MusicDir', models.DO_NOTHING, db_column='directory', blank=True, null=True)
directory = models.ForeignKey(
"MusicDir", models.DO_NOTHING, db_column="directory", blank=True, null=True
)
filepath = models.TextField(blank=True, null=True)
import_status = models.IntegerField()
currently_accessing = models.IntegerField(db_column='currentlyaccessing')
edited_by = models.ForeignKey('User', models.DO_NOTHING, db_column='editedby', blank=True, null=True, related_name='edited_files')
currently_accessing = models.IntegerField(db_column="currentlyaccessing")
edited_by = models.ForeignKey(
"User",
models.DO_NOTHING,
db_column="editedby",
blank=True,
null=True,
related_name="edited_files",
)
mtime = models.DateTimeField(blank=True, null=True)
utime = models.DateTimeField(blank=True, null=True)
lptime = models.DateTimeField(blank=True, null=True)
@ -59,8 +68,10 @@ class File(models.Model):
contributor = models.CharField(max_length=512, blank=True, null=True)
language = models.CharField(max_length=512, blank=True, null=True)
file_exists = models.BooleanField(blank=True, null=True)
replay_gain = models.DecimalField(max_digits=8, decimal_places=2, blank=True, null=True)
owner = models.ForeignKey('User', models.DO_NOTHING, blank=True, null=True)
replay_gain = models.DecimalField(
max_digits=8, decimal_places=2, blank=True, null=True
)
owner = models.ForeignKey("User", models.DO_NOTHING, blank=True, null=True)
cuein = models.DurationField(blank=True, null=True)
cueout = models.DurationField(blank=True, null=True)
silan_check = models.BooleanField(blank=True, null=True)
@ -77,10 +88,10 @@ class File(models.Model):
class Meta:
managed = False
db_table = 'cc_files'
db_table = "cc_files"
permissions = [
('change_own_file', 'Change the files where they are the owner'),
('delete_own_file', 'Delete the files where they are the owner'),
("change_own_file", "Change the files where they are the owner"),
("delete_own_file", "Delete the files where they are the owner"),
]
@ -92,15 +103,16 @@ class MusicDir(models.Model):
class Meta:
managed = False
db_table = 'cc_music_dirs'
db_table = "cc_music_dirs"
class CloudFile(models.Model):
storage_backend = models.CharField(max_length=512)
resource_id = models.TextField()
filename = models.ForeignKey(File, models.DO_NOTHING, blank=True, null=True,
db_column='cc_file_id')
filename = models.ForeignKey(
File, models.DO_NOTHING, blank=True, null=True, db_column="cc_file_id"
)
class Meta:
managed = False
db_table = 'cloud_file'
db_table = "cloud_file"

View file

@ -8,7 +8,7 @@ class Playlist(models.Model):
name = models.CharField(max_length=255)
mtime = models.DateTimeField(blank=True, null=True)
utime = models.DateTimeField(blank=True, null=True)
creator = models.ForeignKey('User', models.DO_NOTHING, blank=True, null=True)
creator = models.ForeignKey("User", models.DO_NOTHING, blank=True, null=True)
description = models.CharField(max_length=512, blank=True, null=True)
length = models.DurationField(blank=True, null=True)
@ -17,7 +17,7 @@ class Playlist(models.Model):
class Meta:
managed = False
db_table = 'cc_playlist'
db_table = "cc_playlist"
class PlaylistContent(models.Model):
@ -39,4 +39,4 @@ class PlaylistContent(models.Model):
class Meta:
managed = False
db_table = 'cc_playlistcontents'
db_table = "cc_playlistcontents"

View file

@ -4,13 +4,13 @@ from .files import File
class ListenerCount(models.Model):
timestamp = models.ForeignKey('Timestamp', models.DO_NOTHING)
mount_name = models.ForeignKey('MountName', models.DO_NOTHING)
timestamp = models.ForeignKey("Timestamp", models.DO_NOTHING)
mount_name = models.ForeignKey("MountName", models.DO_NOTHING)
listener_count = models.IntegerField()
class Meta:
managed = False
db_table = 'cc_listener_count'
db_table = "cc_listener_count"
class LiveLog(models.Model):
@ -20,18 +20,20 @@ class LiveLog(models.Model):
class Meta:
managed = False
db_table = 'cc_live_log'
db_table = "cc_live_log"
class PlayoutHistory(models.Model):
file = models.ForeignKey(File, models.DO_NOTHING, blank=True, null=True)
starts = models.DateTimeField()
ends = models.DateTimeField(blank=True, null=True)
instance = models.ForeignKey('ShowInstance', models.DO_NOTHING, blank=True, null=True)
instance = models.ForeignKey(
"ShowInstance", models.DO_NOTHING, blank=True, null=True
)
class Meta:
managed = False
db_table = 'cc_playout_history'
db_table = "cc_playout_history"
class PlayoutHistoryMetadata(models.Model):
@ -41,7 +43,7 @@ class PlayoutHistoryMetadata(models.Model):
class Meta:
managed = False
db_table = 'cc_playout_history_metadata'
db_table = "cc_playout_history_metadata"
class PlayoutHistoryTemplate(models.Model):
@ -50,7 +52,7 @@ class PlayoutHistoryTemplate(models.Model):
class Meta:
managed = False
db_table = 'cc_playout_history_template'
db_table = "cc_playout_history_template"
class PlayoutHistoryTemplateField(models.Model):
@ -63,7 +65,7 @@ class PlayoutHistoryTemplateField(models.Model):
class Meta:
managed = False
db_table = 'cc_playout_history_template_field'
db_table = "cc_playout_history_template_field"
class Timestamp(models.Model):
@ -71,4 +73,4 @@ class Timestamp(models.Model):
class Meta:
managed = False
db_table = 'cc_timestamp'
db_table = "cc_timestamp"

View file

@ -8,14 +8,14 @@ class ImportedPodcast(models.Model):
auto_ingest = models.BooleanField()
auto_ingest_timestamp = models.DateTimeField(blank=True, null=True)
album_override = models.BooleanField()
podcast = models.ForeignKey('Podcast', models.DO_NOTHING)
podcast = models.ForeignKey("Podcast", models.DO_NOTHING)
def get_owner(self):
return self.podcast.owner
class Meta:
managed = False
db_table = 'imported_podcast'
db_table = "imported_podcast"
class Podcast(models.Model):
@ -32,17 +32,19 @@ class Podcast(models.Model):
itunes_subtitle = models.CharField(max_length=4096, blank=True, null=True)
itunes_category = models.CharField(max_length=4096, blank=True, null=True)
itunes_explicit = models.CharField(max_length=4096, blank=True, null=True)
owner = models.ForeignKey(User, models.DO_NOTHING, db_column='owner', blank=True, null=True)
owner = models.ForeignKey(
User, models.DO_NOTHING, db_column="owner", blank=True, null=True
)
def get_owner(self):
return self.owner
class Meta:
managed = False
db_table = 'podcast'
db_table = "podcast"
permissions = [
('change_own_podcast', 'Change the podcasts where they are the owner'),
('delete_own_podcast', 'Delete the podcasts where they are the owner'),
("change_own_podcast", "Change the podcasts where they are the owner"),
("delete_own_podcast", "Delete the podcasts where they are the owner"),
]
@ -60,10 +62,16 @@ class PodcastEpisode(models.Model):
class Meta:
managed = False
db_table = 'podcast_episodes'
db_table = "podcast_episodes"
permissions = [
('change_own_podcastepisode', 'Change the episodes of podcasts where they are the owner'),
('delete_own_podcastepisode', 'Delete the episodes of podcasts where they are the owner'),
(
"change_own_podcastepisode",
"Change the episodes of podcasts where they are the owner",
),
(
"delete_own_podcastepisode",
"Delete the episodes of podcasts where they are the owner",
),
]
@ -75,4 +83,4 @@ class StationPodcast(models.Model):
class Meta:
managed = False
db_table = 'station_podcast'
db_table = "station_podcast"

View file

@ -3,14 +3,16 @@ from django.db import models
class Preference(models.Model):
subjid = models.ForeignKey('User', models.DO_NOTHING, db_column='subjid', blank=True, null=True)
subjid = models.ForeignKey(
"User", models.DO_NOTHING, db_column="subjid", blank=True, null=True
)
keystr = models.CharField(unique=True, max_length=255, blank=True, null=True)
valstr = models.TextField(blank=True, null=True)
class Meta:
managed = False
db_table = 'cc_pref'
unique_together = (('subjid', 'keystr'),)
db_table = "cc_pref"
unique_together = (("subjid", "keystr"),)
class MountName(models.Model):
@ -18,7 +20,7 @@ class MountName(models.Model):
class Meta:
managed = False
db_table = 'cc_mount_name'
db_table = "cc_mount_name"
class StreamSetting(models.Model):
@ -28,4 +30,4 @@ class StreamSetting(models.Model):
class Meta:
managed = False
db_table = 'cc_stream_setting'
db_table = "cc_stream_setting"

View file

@ -7,14 +7,14 @@ class Schedule(models.Model):
starts = models.DateTimeField()
ends = models.DateTimeField()
file = models.ForeignKey(File, models.DO_NOTHING, blank=True, null=True)
stream = models.ForeignKey('Webstream', models.DO_NOTHING, blank=True, null=True)
stream = models.ForeignKey("Webstream", models.DO_NOTHING, blank=True, null=True)
clip_length = models.DurationField(blank=True, null=True)
fade_in = models.TimeField(blank=True, null=True)
fade_out = models.TimeField(blank=True, null=True)
cue_in = models.DurationField()
cue_out = models.DurationField()
media_item_played = models.BooleanField(blank=True, null=True)
instance = models.ForeignKey('ShowInstance', models.DO_NOTHING)
instance = models.ForeignKey("ShowInstance", models.DO_NOTHING)
playout_status = models.SmallIntegerField()
broadcasted = models.SmallIntegerField()
position = models.IntegerField()
@ -24,8 +24,8 @@ class Schedule(models.Model):
class Meta:
managed = False
db_table = 'cc_schedule'
db_table = "cc_schedule"
permissions = [
('change_own_schedule', 'Change the content on their shows'),
('delete_own_schedule', 'Delete the content on their shows'),
("change_own_schedule", "Change the content on their shows"),
("delete_own_schedule", "Delete the content on their shows"),
]

View file

@ -8,5 +8,4 @@ class ServiceRegister(models.Model):
class Meta:
managed = False
db_table = 'cc_service_register'
db_table = "cc_service_register"

View file

@ -27,7 +27,7 @@ class Show(models.Model):
class Meta:
managed = False
db_table = 'cc_show'
db_table = "cc_show"
class ShowDays(models.Model):
@ -47,16 +47,16 @@ class ShowDays(models.Model):
class Meta:
managed = False
db_table = 'cc_show_days'
db_table = "cc_show_days"
class ShowHost(models.Model):
show = models.ForeignKey(Show, models.DO_NOTHING)
subjs = models.ForeignKey('User', models.DO_NOTHING)
subjs = models.ForeignKey("User", models.DO_NOTHING)
class Meta:
managed = False
db_table = 'cc_show_hosts'
db_table = "cc_show_hosts"
class ShowInstance(models.Model):
@ -66,7 +66,7 @@ class ShowInstance(models.Model):
show = models.ForeignKey(Show, models.DO_NOTHING)
record = models.SmallIntegerField(blank=True, null=True)
rebroadcast = models.SmallIntegerField(blank=True, null=True)
instance = models.ForeignKey('self', models.DO_NOTHING, blank=True, null=True)
instance = models.ForeignKey("self", models.DO_NOTHING, blank=True, null=True)
file = models.ForeignKey(File, models.DO_NOTHING, blank=True, null=True)
time_filled = models.DurationField(blank=True, null=True)
created = models.DateTimeField()
@ -79,7 +79,7 @@ class ShowInstance(models.Model):
class Meta:
managed = False
db_table = 'cc_show_instances'
db_table = "cc_show_instances"
class ShowRebroadcast(models.Model):
@ -92,4 +92,4 @@ class ShowRebroadcast(models.Model):
class Meta:
managed = False
db_table = 'cc_show_rebroadcast'
db_table = "cc_show_rebroadcast"

View file

@ -6,7 +6,7 @@ class SmartBlock(models.Model):
name = models.CharField(max_length=255)
mtime = models.DateTimeField(blank=True, null=True)
utime = models.DateTimeField(blank=True, null=True)
creator = models.ForeignKey('User', models.DO_NOTHING, blank=True, null=True)
creator = models.ForeignKey("User", models.DO_NOTHING, blank=True, null=True)
description = models.CharField(max_length=512, blank=True, null=True)
length = models.DurationField(blank=True, null=True)
type = models.CharField(max_length=7, blank=True, null=True)
@ -16,16 +16,22 @@ class SmartBlock(models.Model):
class Meta:
managed = False
db_table = 'cc_block'
db_table = "cc_block"
permissions = [
('change_own_smartblock', 'Change the smartblocks where they are the owner'),
('delete_own_smartblock', 'Delete the smartblocks where they are the owner'),
(
"change_own_smartblock",
"Change the smartblocks where they are the owner",
),
(
"delete_own_smartblock",
"Delete the smartblocks where they are the owner",
),
]
class SmartBlockContent(models.Model):
block = models.ForeignKey(SmartBlock, models.DO_NOTHING, blank=True, null=True)
file = models.ForeignKey('File', models.DO_NOTHING, blank=True, null=True)
file = models.ForeignKey("File", models.DO_NOTHING, blank=True, null=True)
position = models.IntegerField(blank=True, null=True)
trackoffset = models.FloatField()
cliplength = models.DurationField(blank=True, null=True)
@ -39,10 +45,16 @@ class SmartBlockContent(models.Model):
class Meta:
managed = False
db_table = 'cc_blockcontents'
db_table = "cc_blockcontents"
permissions = [
('change_own_smartblockcontent', 'Change the content of smartblocks where they are the owner'),
('delete_own_smartblockcontent', 'Delete the content of smartblocks where they are the owner'),
(
"change_own_smartblockcontent",
"Change the content of smartblocks where they are the owner",
),
(
"delete_own_smartblockcontent",
"Delete the content of smartblocks where they are the owner",
),
]
@ -59,9 +71,14 @@ class SmartBlockCriteria(models.Model):
class Meta:
managed = False
db_table = 'cc_blockcriteria'
db_table = "cc_blockcriteria"
permissions = [
('change_own_smartblockcriteria', 'Change the criteria of smartblocks where they are the owner'),
('delete_own_smartblockcriteria', 'Delete the criteria of smartblocks where they are the owner'),
(
"change_own_smartblockcriteria",
"Change the criteria of smartblocks where they are the owner",
),
(
"delete_own_smartblockcriteria",
"Delete the criteria of smartblocks where they are the owner",
),
]

View file

@ -12,7 +12,8 @@ class ThirdPartyTrackReference(models.Model):
class Meta:
managed = False
db_table = 'third_party_track_references'
db_table = "third_party_track_references"
class TrackType(models.Model):
code = models.CharField(max_length=16, unique=True)
@ -22,5 +23,4 @@ class TrackType(models.Model):
class Meta:
managed = False
db_table = 'cc_track_types'
db_table = "cc_track_types"

View file

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
GUEST = 'G'
DJ = 'H'
PROGRAM_MANAGER = 'P'
ADMIN = 'A'
GUEST = "G"
DJ = "H"
PROGRAM_MANAGER = "P"
ADMIN = "A"
USER_TYPES = {
GUEST: 'Guest',
DJ: 'DJ',
PROGRAM_MANAGER: 'Program Manager',
ADMIN: 'Admin',
GUEST: "Guest",
DJ: "DJ",
PROGRAM_MANAGER: "Program Manager",
ADMIN: "Admin",
}

View file

@ -21,10 +21,10 @@ class Webstream(models.Model):
class Meta:
managed = False
db_table = 'cc_webstream'
db_table = "cc_webstream"
permissions = [
('change_own_webstream', 'Change the webstreams where they are the owner'),
('delete_own_webstream', 'Delete the webstreams where they are the owner'),
("change_own_webstream", "Change the webstreams where they are the owner"),
("delete_own_webstream", "Delete the webstreams where they are the owner"),
]
@ -38,4 +38,4 @@ class WebstreamMetadata(models.Model):
class Meta:
managed = False
db_table = 'cc_webstream_metadata'
db_table = "cc_webstream_metadata"