Skip to content
Browse files

adpated to refactored dependencies

  • Loading branch information...
1 parent f68496f commit f23db4fb9af7d7f5ba61d0d0d214618264bfd4e8 @xrotwang xrotwang committed Feb 12, 2014
View
1 .gitignore
@@ -30,3 +30,4 @@ nosetests.xml
.mr.developer.cfg
.project
.pydevproject
+.idea
View
23 .idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,23 @@
+<component name="InspectionProjectProfileManager">
+ <profile version="1.0" is_locked="false">
+ <option name="myName" value="Project Default" />
+ <option name="myLocal" value="false" />
+ <inspection_tool class="PyClassicStyleClassInspection" enabled="true" level="WARNING" enabled_by_default="true" />
+ <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoredPackages">
+ <value>
+ <list size="1">
+ <item index="0" class="java.lang.String" itemvalue="setuptools" />
+ </list>
+ </value>
+ </option>
+ </inspection_tool>
+ <inspection_tool class="PyPep8Inspection" enabled="true" level="WARNING" enabled_by_default="true">
+ <option name="ignoredErrors">
+ <list>
+ <option value="E123" />
+ </list>
+ </option>
+ </inspection_tool>
+ </profile>
+</component>
View
7 .idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,7 @@
+<component name="InspectionProjectProfileManager">
+ <settings>
+ <option name="PROJECT_PROFILE" value="Project Default" />
+ <option name="USE_PROJECT_PROFILE" value="true" />
+ <version value="1.0" />
+ </settings>
+</component>
View
2 setup.py
@@ -7,6 +7,8 @@
CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
requires = [
+ 'clld',
+ 'clldmpg',
'pyramid',
'SQLAlchemy',
'transaction',
View
2 wals3/__init__.py
@@ -291,7 +291,7 @@ def main(global_config, **settings):
('contributors', partial(menu_item, 'contributors')),
#('blog', lambda ctx, req: (req.blog.url('category/news/'), 'Newsblog')),
)
-
+ config.include('clldmpg')
config.include('wals3.maps')
config.include('wals3.datatables')
View
2 wals3/appconf.ini
@@ -3,4 +3,4 @@ menuitems_list = parameters contributions languages sources contributors
app_template = wals3.mako
[mako]
-directories_list = wals3:templates clld:web/templates
+directories_list = wals3:templates clldmpg:templates clld:web/templates
View
3 wals3/blog.py
@@ -21,9 +21,6 @@ def url(self, path=None):
def _set_category(self, **cat):
return self.wp.set_categories([cat]).values()[0]
- #
- # TODO: the whole blog implementation is wals specific and should be moved there!
- #
def post_url(self, obj, req, create=False):
res = self.url('%s/' % obj.wp_slug)
if create and not self.wp.get_post_id_from_path(res):
View
12 wals3/models.py
@@ -58,6 +58,18 @@ class Area(Base, IdNameDescriptionMixin):
dbpedia_url = Column(String)
+class LanguageMacroarea(Base):
+ __table_args__ = (UniqueConstraint('macroarea_pk', 'language_pk'),)
+
+ macroarea_pk = Column(Integer, ForeignKey('macroarea.pk'))
+ language_pk = Column(Integer, ForeignKey('language.pk'))
+
+
+class Macroarea(Base, IdNameDescriptionMixin):
+ languages = relationship(
+ Language, secondary=LanguageMacroarea.__table__, backref='macroareas')
+
+
#-----------------------------------------------------------------------------
# specialized common mapper classes
#-----------------------------------------------------------------------------
View
6 wals3/scripts/initializedb.py
@@ -17,7 +17,7 @@
from clld.db.util import compute_language_sources
from clld.scripts.util import initializedb, Data, gbs_func
from clld.lib.bibtex import EntryType
-from clld.lib.dsv import rows
+from clld.lib.dsv import reader
from clld.util import LGR_ABBRS
import wals3
@@ -358,7 +358,7 @@ def teaser(html):
def get_vs2008(args):
vs2008 = {}
- for row in rows(args.data_file('datapoints_2008.csv'), delimiter=','):
+ for row in reader(args.data_file('datapoints_2008.csv'), delimiter=','):
vs2008[(row[0], '%sA' % row[1])] = int(row[2])
return vs2008
@@ -795,7 +795,7 @@ def prime_cache(args):
value.updated = E2011
VersionedDBSession.flush()
- for row in rows(args.data_file('corrections_2013.tab'), namedtuples=True, newline='\r'):
+ for row in reader(args.data_file('corrections_2013.tab'), namedtuples=True, newline='\r'):
valueset = VersionedDBSession.query(common.ValueSet)\
.join(common.Language)\
.join(common.Parameter)\
View
451 wals3/static/project.css
@@ -1898,457 +1898,6 @@ table th[class*="span"],
.table-hover tbody tr.info:hover td {
background-color: #c4e3f3;
}
-[class^="icon-"],
-[class*=" icon-"] {
- display: inline-block;
- width: 14px;
- height: 14px;
- *margin-right: .3em;
- line-height: 14px;
- vertical-align: text-top;
- background-image: url("../img/glyphicons-halflings.png");
- background-position: 14px 14px;
- background-repeat: no-repeat;
- margin-top: 1px;
-}
-/* White icons with optional class, or on hover/active states of certain elements */
-.icon-white,
-.nav-pills > .active > a > [class^="icon-"],
-.nav-pills > .active > a > [class*=" icon-"],
-.nav-list > .active > a > [class^="icon-"],
-.nav-list > .active > a > [class*=" icon-"],
-.navbar-inverse .nav > .active > a > [class^="icon-"],
-.navbar-inverse .nav > .active > a > [class*=" icon-"],
-.dropdown-menu > li > a:hover > [class^="icon-"],
-.dropdown-menu > li > a:hover > [class*=" icon-"],
-.dropdown-menu > .active > a > [class^="icon-"],
-.dropdown-menu > .active > a > [class*=" icon-"],
-.dropdown-submenu:hover > a > [class^="icon-"],
-.dropdown-submenu:hover > a > [class*=" icon-"] {
- background-image: url("../img/glyphicons-halflings-white.png");
-}
-.icon-glass {
- background-position: 0 0;
-}
-.icon-music {
- background-position: -24px 0;
-}
-.icon-search {
- background-position: -48px 0;
-}
-.icon-envelope {
- background-position: -72px 0;
-}
-.icon-heart {
- background-position: -96px 0;
-}
-.icon-star {
- background-position: -120px 0;
-}
-.icon-star-empty {
- background-position: -144px 0;
-}
-.icon-user {
- background-position: -168px 0;
-}
-.icon-film {
- background-position: -192px 0;
-}
-.icon-th-large {
- background-position: -216px 0;
-}
-.icon-th {
- background-position: -240px 0;
-}
-.icon-th-list {
- background-position: -264px 0;
-}
-.icon-ok {
- background-position: -288px 0;
-}
-.icon-remove {
- background-position: -312px 0;
-}
-.icon-zoom-in {
- background-position: -336px 0;
-}
-.icon-zoom-out {
- background-position: -360px 0;
-}
-.icon-off {
- background-position: -384px 0;
-}
-.icon-signal {
- background-position: -408px 0;
-}
-.icon-cog {
- background-position: -432px 0;
-}
-.icon-trash {
- background-position: -456px 0;
-}
-.icon-home {
- background-position: 0 -24px;
-}
-.icon-file {
- background-position: -24px -24px;
-}
-.icon-time {
- background-position: -48px -24px;
-}
-.icon-road {
- background-position: -72px -24px;
-}
-.icon-download-alt {
- background-position: -96px -24px;
-}
-.icon-download {
- background-position: -120px -24px;
-}
-.icon-upload {
- background-position: -144px -24px;
-}
-.icon-inbox {
- background-position: -168px -24px;
-}
-.icon-play-circle {
- background-position: -192px -24px;
-}
-.icon-repeat {
- background-position: -216px -24px;
-}
-.icon-refresh {
- background-position: -240px -24px;
-}
-.icon-list-alt {
- background-position: -264px -24px;
-}
-.icon-lock {
- background-position: -287px -24px;
-}
-.icon-flag {
- background-position: -312px -24px;
-}
-.icon-headphones {
- background-position: -336px -24px;
-}
-.icon-volume-off {
- background-position: -360px -24px;
-}
-.icon-volume-down {
- background-position: -384px -24px;
-}
-.icon-volume-up {
- background-position: -408px -24px;
-}
-.icon-qrcode {
- background-position: -432px -24px;
-}
-.icon-barcode {
- background-position: -456px -24px;
-}
-.icon-tag {
- background-position: 0 -48px;
-}
-.icon-tags {
- background-position: -25px -48px;
-}
-.icon-book {
- background-position: -48px -48px;
-}
-.icon-bookmark {
- background-position: -72px -48px;
-}
-.icon-print {
- background-position: -96px -48px;
-}
-.icon-camera {
- background-position: -120px -48px;
-}
-.icon-font {
- background-position: -144px -48px;
-}
-.icon-bold {
- background-position: -167px -48px;
-}
-.icon-italic {
- background-position: -192px -48px;
-}
-.icon-text-height {
- background-position: -216px -48px;
-}
-.icon-text-width {
- background-position: -240px -48px;
-}
-.icon-align-left {
- background-position: -264px -48px;
-}
-.icon-align-center {
- background-position: -288px -48px;
-}
-.icon-align-right {
- background-position: -312px -48px;
-}
-.icon-align-justify {
- background-position: -336px -48px;
-}
-.icon-list {
- background-position: -360px -48px;
-}
-.icon-indent-left {
- background-position: -384px -48px;
-}
-.icon-indent-right {
- background-position: -408px -48px;
-}
-.icon-facetime-video {
- background-position: -432px -48px;
-}
-.icon-picture {
- background-position: -456px -48px;
-}
-.icon-pencil {
- background-position: 0 -72px;
-}
-.icon-map-marker {
- background-position: -24px -72px;
-}
-.icon-adjust {
- background-position: -48px -72px;
-}
-.icon-tint {
- background-position: -72px -72px;
-}
-.icon-edit {
- background-position: -96px -72px;
-}
-.icon-share {
- background-position: -120px -72px;
-}
-.icon-check {
- background-position: -144px -72px;
-}
-.icon-move {
- background-position: -168px -72px;
-}
-.icon-step-backward {
- background-position: -192px -72px;
-}
-.icon-fast-backward {
- background-position: -216px -72px;
-}
-.icon-backward {
- background-position: -240px -72px;
-}
-.icon-play {
- background-position: -264px -72px;
-}
-.icon-pause {
- background-position: -288px -72px;
-}
-.icon-stop {
- background-position: -312px -72px;
-}
-.icon-forward {
- background-position: -336px -72px;
-}
-.icon-fast-forward {
- background-position: -360px -72px;
-}
-.icon-step-forward {
- background-position: -384px -72px;
-}
-.icon-eject {
- background-position: -408px -72px;
-}
-.icon-chevron-left {
- background-position: -432px -72px;
-}
-.icon-chevron-right {
- background-position: -456px -72px;
-}
-.icon-plus-sign {
- background-position: 0 -96px;
-}
-.icon-minus-sign {
- background-position: -24px -96px;
-}
-.icon-remove-sign {
- background-position: -48px -96px;
-}
-.icon-ok-sign {
- background-position: -72px -96px;
-}
-.icon-question-sign {
- background-position: -96px -96px;
-}
-.icon-info-sign {
- background-position: -120px -96px;
-}
-.icon-screenshot {
- background-position: -144px -96px;
-}
-.icon-remove-circle {
- background-position: -168px -96px;
-}
-.icon-ok-circle {
- background-position: -192px -96px;
-}
-.icon-ban-circle {
- background-position: -216px -96px;
-}
-.icon-arrow-left {
- background-position: -240px -96px;
-}
-.icon-arrow-right {
- background-position: -264px -96px;
-}
-.icon-arrow-up {
- background-position: -289px -96px;
-}
-.icon-arrow-down {
- background-position: -312px -96px;
-}
-.icon-share-alt {
- background-position: -336px -96px;
-}
-.icon-resize-full {
- background-position: -360px -96px;
-}
-.icon-resize-small {
- background-position: -384px -96px;
-}
-.icon-plus {
- background-position: -408px -96px;
-}
-.icon-minus {
- background-position: -433px -96px;
-}
-.icon-asterisk {
- background-position: -456px -96px;
-}
-.icon-exclamation-sign {
- background-position: 0 -120px;
-}
-.icon-gift {
- background-position: -24px -120px;
-}
-.icon-leaf {
- background-position: -48px -120px;
-}
-.icon-fire {
- background-position: -72px -120px;
-}
-.icon-eye-open {
- background-position: -96px -120px;
-}
-.icon-eye-close {
- background-position: -120px -120px;
-}
-.icon-warning-sign {
- background-position: -144px -120px;
-}
-.icon-plane {
- background-position: -168px -120px;
-}
-.icon-calendar {
- background-position: -192px -120px;
-}
-.icon-random {
- background-position: -216px -120px;
- width: 16px;
-}
-.icon-comment {
- background-position: -240px -120px;
-}
-.icon-magnet {
- background-position: -264px -120px;
-}
-.icon-chevron-up {
- background-position: -288px -120px;
-}
-.icon-chevron-down {
- background-position: -313px -119px;
-}
-.icon-retweet {
- background-position: -336px -120px;
-}
-.icon-shopping-cart {
- background-position: -360px -120px;
-}
-.icon-folder-close {
- background-position: -384px -120px;
-}
-.icon-folder-open {
- background-position: -408px -120px;
- width: 16px;
-}
-.icon-resize-vertical {
- background-position: -432px -119px;
-}
-.icon-resize-horizontal {
- background-position: -456px -118px;
-}
-.icon-hdd {
- background-position: 0 -144px;
-}
-.icon-bullhorn {
- background-position: -24px -144px;
-}
-.icon-bell {
- background-position: -48px -144px;
-}
-.icon-certificate {
- background-position: -72px -144px;
-}
-.icon-thumbs-up {
- background-position: -96px -144px;
-}
-.icon-thumbs-down {
- background-position: -120px -144px;
-}
-.icon-hand-right {
- background-position: -144px -144px;
-}
-.icon-hand-left {
- background-position: -168px -144px;
-}
-.icon-hand-up {
- background-position: -192px -144px;
-}
-.icon-hand-down {
- background-position: -216px -144px;
-}
-.icon-circle-arrow-right {
- background-position: -240px -144px;
-}
-.icon-circle-arrow-left {
- background-position: -264px -144px;
-}
-.icon-circle-arrow-up {
- background-position: -288px -144px;
-}
-.icon-circle-arrow-down {
- background-position: -312px -144px;
-}
-.icon-globe {
- background-position: -336px -144px;
-}
-.icon-wrench {
- background-position: -360px -144px;
-}
-.icon-tasks {
- background-position: -384px -144px;
-}
-.icon-filter {
- background-position: -408px -144px;
-}
-.icon-briefcase {
- background-position: -432px -144px;
-}
-.icon-fullscreen {
- background-position: -456px -144px;
-}
.dropup,
.dropdown {
position: relative;
View
39 wals3/tests/test_functional.py
@@ -38,11 +38,13 @@ def test_resources(self):
# headers = {'x-requested-with': 'XMLHttpRequest'}
# _path = '/%ss?sEcho=1&iSortingCols=1&iSortCol_0=1&sSortDir_0=desc' % rsc
# self.app.get(_path, headers=headers, status=200)
+ self.app.get('/chapter/s4', status=302)
_path = '/values?sEcho=1&iSortingCols=1&iSortCol_0=1&sSortDir_0=desc'
self.app.get(_path, xhr=True, status=200)
def test_g(self):
+ self.app.get('/languoid')
self.app.get('/languoid/genus/berber')
self.app.get('/languoid/family/arawakan')
@@ -55,3 +57,40 @@ def test_g(self):
self.app.get('/languoids?id=gberber', status=404)
self.app.get('/languoids?id=x-berber', status=404)
self.app.get('/languoids?id=g-berberyyy', status=404)
+
+ def test_feature(self):
+ _path = '/feature?sEcho=1&iSortingCols=1&iSortCol_0='
+ self.app.get(_path + '0', xhr=True, status=200)
+ self.app.get(_path + '1', xhr=True, status=200)
+ for ext in 'geojson georss tab xml kml solr.json'.split():
+ self.app.get('/feature/2A.%s?domainelement=2A-1' % ext, status=200)
+
+ def test_misc(self):
+ self.app.get('/feature/12A.rdf', status=200)
+ self.app.get('/languoid/lect/wals_code_aab.rdf', status=200)
+ self.app.get('/chapter/12.rdf', status=200)
+ self.app.get('/feature/20', status=301)
+ self.app.get('/refdb/record/5', status=301)
+ self.app.get('/refdb/record/555555', status=404)
+ self.app.get('/refdb/record/Abega-1970', status=200)
+ self.app.get('/values?parameter=1A&sEcho=1', xhr=True, status=200)
+ self.app.get('/values?parameter=1A&v1=c000&sEcho=1', xhr=True, status=200)
+ self.app.get('/feature/20A.snippet.html?v1=c000', status=200)
+ self.app.get('/languoid/family/sepik?sepikhill=c000', status=200)
+
+ def test_redirects(self):
+ self.app.get('/feature/combined/1A/2A', status=301)
+ self.app.get('/datapoint/1/wals_code_aab', status=301)
+ #self.app.get('', status=301)
+
+ def test_olac(self):
+ p = '/refdb_oai?verb='
+ md = '&metadataPrefix=olac'
+ self.app.get(p+'GetRecord&identifier=oai:refdb.wals.info:1'+md, status=200)
+ self.app.get(p + 'ListRecords' + md, status=200)
+ self.app.get(p + 'Identify', status=200)
+ p = '/languoid/oai?verb='
+ md = '&metadataPrefix=olac'
+ self.app.get(p+'GetRecord&identifier=oai:wals.info:languoid:cea'+md, status=200)
+ self.app.get(p + 'ListRecords' + md, status=200)
+ self.app.get(p + 'Identify', status=200)
View
53 wals3/tests/test_unit.py
@@ -0,0 +1,53 @@
+from collections import defaultdict
+
+from path import path
+from mock import Mock, patch
+from pyramid.httpexceptions import HTTPFound
+
+from clld.tests.util import TestWithEnv
+from clld.interfaces import IBlog
+from clld.db.models.common import ValueSet
+
+import wals3
+
+
+class Tests(TestWithEnv):
+ __cfg__ = path(wals3.__file__).dirname().joinpath('..', 'development.ini').abspath()
+ __setup_db__ = False
+
+ def test_comment(self):
+ from wals3.views import comment
+
+ self.env['registry'].registerUtility(Mock(post_url=lambda *a, **kw: '/'), IBlog)
+ self.set_request_properties(matchdict=dict(fid='51A', lid='esm'))
+ self.assertIsInstance(comment(self.env['request']), HTTPFound)
+
+ def test_Blog(self):
+ from wals3.blog import Blog
+
+ vs = ValueSet.first()
+
+ class wp(object):
+ def __init__(self, cats=False):
+ if cats:
+ self.cats = [
+ dict(id=1, name='Languages'),
+ dict(id=2, name='Chapters'),
+ dict(id=3, name=vs.parameter.chapter.area.name),
+ ]
+ else:
+ self.cats = []
+
+ def Client(self, *args, **kw):
+ return Mock(
+ get_categories=lambda: self.cats,
+ set_categories=lambda c: dict(n=1),
+ get_post_id_from_path=lambda p: None)
+
+ with patch('wals3.blog.wordpress', wp()):
+ blog = Blog(defaultdict(lambda: ''))
+ blog.post_url(vs, self.env['request'], create=True)
+
+ with patch('wals3.blog.wordpress', wp(cats=True)):
+ blog = Blog(defaultdict(lambda: ''))
+ blog.post_url(vs, self.env['request'], create=True)
View
4 wals3/util.py
@@ -41,6 +41,10 @@ def icons(req, param):
class LanguoidSelect(MultiSelect):
+ """
+ >>> ls = LanguoidSelect(None, None, None)
+ >>> assert ls.get_options()
+ """
def format_result(self, l):
return dict(
id='%s-%s' % (l.mapper_name().lower()[0], l.id),

0 comments on commit f23db4f

Please sign in to comment.
Something went wrong with that request. Please try again.