Skip to content

Commit

Permalink
controlled import via repo 'ids-internal'; added Provider view; fixed…
Browse files Browse the repository at this point in the history
… download view #11; updated test
  • Loading branch information
Hans-Jörg Bibiko committed Nov 20, 2020
1 parent e5fa364 commit 2718277
Show file tree
Hide file tree
Showing 21 changed files with 459 additions and 49 deletions.
5 changes: 4 additions & 1 deletion ids/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

# we must make sure custom models are known at database initialization!
from ids import models
from ids.interfaces import IChapter
from ids.interfaces import IChapter, IProvider


_ = lambda a: a
_('Contribution')
_('Contributions')
_('Parameter')
_('Parameters')
_('Provider')
_('Providers')
_('Value')
_('Values')

Expand Down Expand Up @@ -62,4 +64,5 @@ def main(global_config, **settings):
extension='tab',
name='tab-separated values'), IContribution)
config.register_resource('chapter', models.Chapter, IChapter, with_index=True)
config.register_resource('provider', models.Provider, IProvider, with_index=True)
return config.make_wsgi_app()
2 changes: 1 addition & 1 deletion ids/appconf.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[clld]
menuitems_list = contributions chapters parameters values sources contributors
menuitems_list = contributions chapters parameters values sources contributors providers
app_template = ids.mako
github_repos = clld/ids
pacific_centered_maps = true
Expand Down
34 changes: 32 additions & 2 deletions ids/datatables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from sqlalchemy.orm import aliased, joinedload, contains_eager

from clld.web.datatables import Values, Sources
from clld.web.datatables.base import Col, LinkCol, LinkToMapCol, DataTable, IntegerIdCol
from clld.web.datatables.base import Col, LinkCol, LinkToMapCol, DataTable, IntegerIdCol, DetailsRowLinkCol, ExternalLinkCol
from clld.web.datatables.contribution import Contributions, CitationCol
from clld.web.datatables.source import TypeCol
from clld.web.datatables import contributor
from clld.web.datatables.parameter import Parameters
from clld.web.util.helpers import link
Expand All @@ -16,7 +17,7 @@
from clld_glottologfamily_plugin.datatables import MacroareaCol, FamilyCol
from clld_glottologfamily_plugin.models import Family

from ids.models import Chapter, Entry, ROLES, Dictionary, IdsLanguage
from ids.models import Chapter, Entry, ROLES, Dictionary, IdsLanguage, Provider


class IDSCodeCol(Col):
Expand Down Expand Up @@ -244,11 +245,25 @@ def col_defs(self):


class IDSSources(Sources):
def base_query(self, query):
return query.join(Provider)

def get_options(self):
opts = super(Sources, self).get_options()
opts["aaSorting"] = [[1, "asc"]]
return opts

def col_defs(self):
return [
DetailsRowLinkCol(self, 'd'),
LinkCol(self, 'name'),
LinkCol(self, 'id', get_obj=lambda i: i.provider, sTitle='Dataset', model_col=Provider.name),
Col(self, 'description', sTitle='Title', format=lambda i: HTML.span(i.description)),
Col(self, 'year'),
Col(self, 'author'),
TypeCol(self, 'bibtex_type'),
]


class Chapters(DataTable):
def col_defs(self):
Expand All @@ -259,8 +274,23 @@ def col_defs(self):
]


class Providers(DataTable):
def get_options(self):
opts = super(DataTable, self).get_options()
opts["aaSorting"] = []
return opts

def col_defs(self):
return [
LinkCol(self, 'name'),
ExternalLinkCol(self, 'url', sTitle='URL'),
DetailsRowLinkCol(self, 'd'),
]


def includeme(config):
config.register_datatable('chapters', Chapters)
config.register_datatable('providers', Providers)
config.register_datatable('values', Counterparts)
config.register_datatable('contributors', Compilers)
config.register_datatable('contributions', Dictionaries)
Expand Down
4 changes: 4 additions & 0 deletions ids/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@

class IChapter(Interface):
pass


class IProvider(Interface):
pass
Binary file modified ids/locale/en/LC_MESSAGES/clld.mo
Binary file not shown.
12 changes: 10 additions & 2 deletions ids/locale/en/LC_MESSAGES/clld.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2020-10-09 17:04+0200\n"
"POT-Creation-Date: 2020-11-20 10:31+0100\n"
"PO-Revision-Date: 2013-12-17 15:46+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
Expand Down Expand Up @@ -35,10 +35,18 @@ msgid "Parameters"
msgstr "Entries"

#: ids/__init__.py:19
msgid "Provider"
msgstr "Dataset"

#: ids/__init__.py:20
msgid "Providers"
msgstr "Datasets"

#: ids/__init__.py:21
msgid "Value"
msgstr "Counterparts"

#: ids/__init__.py:20
#: ids/__init__.py:22
msgid "Values"
msgstr "Counterparts"

12 changes: 10 additions & 2 deletions ids/locale/ids.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: ids 0.0\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2020-10-09 17:04+0200\n"
"POT-Creation-Date: 2020-11-20 10:31+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -34,10 +34,18 @@ msgid "Parameters"
msgstr ""

#: ids/__init__.py:19
msgid "Value"
msgid "Provider"
msgstr ""

#: ids/__init__.py:20
msgid "Providers"
msgstr ""

#: ids/__init__.py:21
msgid "Value"
msgstr ""

#: ids/__init__.py:22
msgid "Values"
msgstr ""

24 changes: 22 additions & 2 deletions ids/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
from clld import interfaces
from clld.db.meta import Base, CustomModelMixin
from clld.db.models.common import (
Parameter, IdNameDescriptionMixin, Contribution, Language, Value, Unit, ValueSet,
Parameter, IdNameDescriptionMixin, Contribution, Language, Value, Unit, ValueSet, Source
)
from clld.web.util import concepticon
from clld_glottologfamily_plugin.models import HasFamilyMixin

from ids.interfaces import IChapter
from ids.interfaces import IChapter, IProvider


ROLES = {
Expand Down Expand Up @@ -56,6 +56,17 @@ def concepticon_link(self, req):
obj_type='Concept')


@implementer(IProvider)
class Provider(Base, IdNameDescriptionMixin):
pk = Column(Integer, primary_key=True)
url = Column(Unicode)
license = Column(Unicode)
aboutUrl = Column(Unicode)
accessURL = Column(Unicode)
version = Column(Unicode)
doi = Column(Unicode)


@implementer(interfaces.ILanguage)
class IdsLanguage(CustomModelMixin, Language, HasFamilyMixin):
pk = Column(Integer, ForeignKey('language.pk'), primary_key=True)
Expand All @@ -66,6 +77,8 @@ class Dictionary(CustomModelMixin, Contribution):
pk = Column(Integer, ForeignKey('contribution.pk'), primary_key=True)
language_pk = Column(Integer, ForeignKey('language.pk'), nullable=False)
language = relationship(Language, backref=backref('dictionary', uselist=False))
provider_pk = Column(Integer, ForeignKey('provider.pk'), nullable=False)
provider = relationship(Provider, backref=backref('dictionaries', uselist=True))

default_representation = Column(Unicode)
alt_representation = Column(Unicode)
Expand Down Expand Up @@ -99,3 +112,10 @@ class Synset(CustomModelMixin, ValueSet):
pk = Column(Integer, ForeignKey('valueset.pk'), primary_key=True)

alt_representation = Column(Unicode)


@implementer(interfaces.ISource)
class IdsSource(CustomModelMixin, Source):
pk = Column(Integer, ForeignKey('source.pk'), primary_key=True)
provider_pk = Column(Integer, ForeignKey('provider.pk'), nullable=False)
provider = relationship(Provider, backref=backref('source', uselist=False))
Loading

0 comments on commit 2718277

Please sign in to comment.