def test_LanguageByFamilyMapMarker(self):
        from clld_glottologfamily_plugin.util import LanguageByFamilyMapMarker

        marker = LanguageByFamilyMapMarker()
        self.assertEqual(marker.get_icon(LanguageWithFamily.get('l1'), MagicMock()), 1)
        self.assertNotEqual(marker.get_icon(LanguageWithFamily.get('l2'), MagicMock()), 1)
        marker.get_icon(Family.first(), MagicMock())
예제 #2
0
 def __call__(self, ctx, req):
     if IValue.providedBy(ctx):
         #print ctx.jsondata['family']#,ctx,[self],ctx.domainelement.jsondata['icon']
         ##return ctx.domainelement.jsondata['icon']
         return req.static_url('lsi:static/icons/' +
                               ctx.jsondata['family'] +
                               ctx.domainelement.jsondata['icon'] + '.png')
         ##return req.static_url('lsi:static/icons/c000000.png')
     if IValueSet.providedBy(ctx):
         #print ctx.domainelement
         ##return ctx.values[0].domainelement.jsondata['icon']
         req.static_url('lsi:static/icons/' +
                        ctx.values[0].domainelement.jsondata['icon'] +
                        '.png')
     if IDomainElement.providedBy(ctx):
         ##return None
         print ctx.jsondata
         return req.static_url('lsi:static/icons/' + 'cr' +
                               ''.join(ctx.jsondata['icon'][:]) + '.png')
         ##return ctx.jsondata['icon']
     #print LanguageByFamilyMapMarker
     #print LanguageByFamilyMapMarker.get_icon(self, ctx, req)
     ##return LanguageByFamilyMapMarker.get_icon(self, ctx, req)
     return req.static_url(
         'lsi:static/icons/' +
         LanguageByFamilyMapMarker.get_icon(self, ctx, req) + '.png')
예제 #3
0
 def get_icon(self, ctx, req):
     if IValue.providedBy(ctx):
         return ctx.domainelement.jsondata['icon']
     if IValueSet.providedBy(ctx):
         return ctx.values[0].domainelement.jsondata['icon']
     if IDomainElement.providedBy(ctx):
         return ctx.jsondata['icon']
     return LanguageByFamilyMapMarker.get_icon(self, ctx, req)
예제 #4
0
 def get_icon(self, ctx, req):
     if IValue.providedBy(ctx):
         return ctx.domainelement.jsondata['icon']
     if IValueSet.providedBy(ctx):
         return ctx.values[0].domainelement.jsondata['icon']
     if IDomainElement.providedBy(ctx):
         return ctx.jsondata['icon']
     return LanguageByFamilyMapMarker.get_icon(self, ctx, req)
예제 #5
0
 def __call__(self, ctx, req):
     if IValue.providedBy(ctx):
         icon = ctx.domainelement.jsondata['icon']
     elif IValueSet.providedBy(ctx):
         icon = ctx.values[0].domainelement.jsondata['icon']
     elif IDomainElement.providedBy(ctx):
         icon = ctx.jsondata['icon']
     else:
         icon = LanguageByFamilyMapMarker.get_icon(self, ctx, req)
     icon = {
         'cffffff': 'c0077bb',
         'cff0000': 'ccc3311',
         'c0000ff': 'c009988',
         'cffff00': 'cee7733',
     }.get(icon, icon)
     return svg.data_url(svg.icon(icon, opacity=0.8))
예제 #6
0
 def get_icon(self, ctx, req):
     if IValue.providedBy(ctx):
         ctx = ctx.valueset
     if IValueSet.providedBy(ctx):
         ctx = ctx.language
     return LanguageByFamilyMapMarker.get_icon(self, ctx, req)
예제 #7
0
파일: __init__.py 프로젝트: MacyL/lexibank
 def get_icon(self, ctx, req):
     if IValue.providedBy(ctx):
         ctx = ctx.valueset
     if IValueSet.providedBy(ctx):
         ctx = ctx.language
     return LanguageByFamilyMapMarker.get_icon(self, ctx, req)