-
Notifications
You must be signed in to change notification settings - Fork 38
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
Adding a authorities/responsabilities models #225
Open
AnasGhrab
wants to merge
4
commits into
Parisson:dev
Choose a base branch
from
AnasGhrab:master
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ tmp | |
dist | ||
doc/output/ | ||
doc/pelican-plugins/ | ||
doc/pelican-themes/ | ||
doc/api/telemeta | ||
|
||
# Installer logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import telemeta.models.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('telemeta', '0007_auto_20190505_1749'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Authority', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('first_name', models.CharField(max_length=50, verbose_name='firstname')), | ||
('last_name', models.CharField(max_length=50, verbose_name='lastname')), | ||
], | ||
options={ | ||
'db_table': 'media_authority', | ||
'verbose_name': 'authority', | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='mediaitem', | ||
name='authority', | ||
field=telemeta.models.fields.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, default=None, blank=True, to='telemeta.Authority', null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('telemeta', '0008_auto_20200531_0733'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='mediaitem', | ||
old_name='authority', | ||
new_name='collector2', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('telemeta', '0009_auto_20200531_0805'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='authority', | ||
name='biography', | ||
field=models.TextField(null=True, verbose_name='biography', blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='authority', | ||
name='birth', | ||
field=models.DateField(help_text='YYYY-MM-DD', null=True, verbose_name='birth', blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='authority', | ||
name='death', | ||
field=models.DateField(help_text='YYYY-MM-DD', null=True, verbose_name='death', blank=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('telemeta', '0010_auto_20200531_0811'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='authority', | ||
name='isni', | ||
field=models.PositiveIntegerField(help_text='International Standard Name Identifier', null=True, verbose_name='isni', blank=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('telemeta', '0011_authority_isni'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='authority', | ||
name='first_name_lat', | ||
field=models.CharField(help_text='First name in latin characters, usage form', max_length=50, null=True, verbose_name='firstname_lat', blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='authority', | ||
name='first_name_translit', | ||
field=models.CharField(help_text='First name transliterated', max_length=50, null=True, verbose_name='firstname_translit', blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='authority', | ||
name='last_name_lat', | ||
field=models.CharField(help_text='Last name in latin character, usage form', max_length=50, null=True, verbose_name='lastname_lat', blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='authority', | ||
name='last_name_translit', | ||
field=models.CharField(help_text='Last name transliterated', max_length=50, null=True, verbose_name='lastname_translit', blank=True), | ||
), | ||
migrations.AlterField( | ||
model_name='authority', | ||
name='first_name', | ||
field=models.CharField(help_text='First name in original language', max_length=50, verbose_name='firstname'), | ||
), | ||
migrations.AlterField( | ||
model_name='authority', | ||
name='last_name', | ||
field=models.CharField(help_text='Last name in original language', max_length=50, verbose_name='lastname'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('telemeta', '0012_auto_20200531_0822'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='mediaitem', | ||
name='collector2', | ||
), | ||
migrations.DeleteModel( | ||
name='Authority', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('telemeta', '0013_auto_20200531_0849'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Authority', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('first_name', models.CharField(help_text='First name in original language', max_length=50, verbose_name='firstname')), | ||
('last_name', models.CharField(help_text='Last name in original language', max_length=50, verbose_name='lastname')), | ||
('first_name_lat', models.CharField(help_text='First name in latin characters, usage form', max_length=50, null=True, verbose_name='firstname_lat', blank=True)), | ||
('last_name_lat', models.CharField(help_text='Last name in latin character, usage form', max_length=50, null=True, verbose_name='lastname_lat', blank=True)), | ||
('first_name_translit', models.CharField(help_text='First name transliterated', max_length=50, null=True, verbose_name='firstname_translit', blank=True)), | ||
('last_name_translit', models.CharField(help_text='Last name transliterated', max_length=50, null=True, verbose_name='lastname_translit', blank=True)), | ||
('birth', models.DateField(help_text='YYYY-MM-DD', null=True, verbose_name='birth', blank=True)), | ||
('death', models.DateField(help_text='YYYY-MM-DD', null=True, verbose_name='death', blank=True)), | ||
('biography', models.TextField(null=True, verbose_name='biography', blank=True)), | ||
('isni', models.PositiveIntegerField(help_text='International Standard Name Identifier', null=True, verbose_name='isni', blank=True)), | ||
], | ||
options={ | ||
'db_table': 'media_authority', | ||
'verbose_name': 'authority', | ||
'verbose_name_plural': 'authorities', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Responsability', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('authority', models.ForeignKey(to='telemeta.Authority')), | ||
('collection', models.ForeignKey(to='telemeta.MediaCollection')), | ||
('item', models.ForeignKey(to='telemeta.MediaItem')), | ||
], | ||
options={ | ||
'db_table': 'media_responsability', | ||
'verbose_name': 'responsability', | ||
'verbose_name_plural': 'responsabilites', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Role', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('intitule', models.CharField(help_text='List of roles', max_length=50, verbose_name='role')), | ||
], | ||
options={ | ||
'db_table': 'media_role', | ||
'verbose_name': 'role', | ||
'verbose_name_plural': 'roles', | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='responsability', | ||
name='role', | ||
field=models.ForeignKey(to='telemeta.Role'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of Telemeta. | ||
|
||
# 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/>. | ||
# | ||
# Authors: Anas Ghrab <[email protected]> | ||
|
||
from __future__ import division | ||
from django.db import models | ||
from django.utils.translation import ugettext_lazy as _ | ||
from telemeta.models.item import * | ||
from telemeta.models.collection import * | ||
|
||
class Authority(models.Model): | ||
"Describe an autority" | ||
|
||
first_name = models.CharField(_('firstname'), max_length=50, help_text=_('First name in original language')) | ||
last_name = models.CharField(_('lastname'), max_length=50, help_text=_('Last name in original language')) | ||
first_name_lat = models.CharField(_('firstname_lat'), max_length=50, null=True, blank=True, help_text=_('First name in latin characters, usage form')) | ||
last_name_lat = models.CharField(_('lastname_lat'), max_length=50, null=True, blank=True, help_text=_('Last name in latin character, usage form')) | ||
first_name_translit = models.CharField(_('firstname_translit'), max_length=50, null=True, blank=True, help_text=_('First name transliterated')) | ||
last_name_translit = models.CharField(_('lastname_translit'), max_length=50, null=True, blank=True, help_text=_('Last name transliterated')) | ||
birth = models.DateField(_('birth'), null=True, blank=True, help_text=_('YYYY-MM-DD')) | ||
death = models.DateField(_('death'), null=True, blank=True, help_text=_('YYYY-MM-DD')) | ||
biography = models.TextField(_('biography'), null=True, blank=True) | ||
isni = models.PositiveIntegerField(_('isni'), null=True, blank=True, help_text=_('International Standard Name Identifier')) | ||
#photo = | ||
|
||
class Meta: | ||
db_table = 'media_authority' | ||
verbose_name = _('authority') | ||
verbose_name_plural = _('authorities') | ||
|
||
def __str__(self): | ||
return '%s %s' % (self.prenom, self.nom) | ||
|
||
class Role(models.Model): | ||
"Describe a role related to items" | ||
|
||
intitule = models.CharField(_('role'), max_length=50, help_text=_('List of roles')) | ||
|
||
class Meta: | ||
db_table = 'media_role' | ||
verbose_name = _('role') | ||
verbose_name_plural = _('roles') | ||
|
||
def __str__(self): | ||
return '%s %s' % (self.intitule) | ||
|
||
class Responsability(models.Model): | ||
"Describe a responsability in making an item" | ||
|
||
authority = models.ForeignKey('Authority', on_delete = models.CASCADE) | ||
role = models.ForeignKey('Role', on_delete = models.CASCADE) | ||
item = models.ForeignKey('MediaItem', on_delete = models.CASCADE) | ||
collection = models.ForeignKey('MediaCollection', on_delete = models.CASCADE) | ||
|
||
class Meta: | ||
db_table = 'media_responsability' | ||
verbose_name = _('responsability') | ||
verbose_name_plural = _('responsabilites') | ||
|
||
def __str__(self): | ||
return '%s %s' % (self.authority, self.role) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For those 4 fields, to avoid cascade deleting, I strongly advise to set
on_delete=models.SET_NULL
.If not, in this case and for example, a Responsability could be deleted when the related Role or Item is deleted.