Skip to content

Commit

Permalink
Merge pull request #60 from al-indigo/tmprefactor
Browse files Browse the repository at this point in the history
0.81 release
  • Loading branch information
al-indigo committed Sep 22, 2015
2 parents 33a1fe6 + 1cfced7 commit 56e0d90
Show file tree
Hide file tree
Showing 29 changed files with 563 additions and 108 deletions.
2 changes: 1 addition & 1 deletion lingvodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def configure_routes(config):
config.add_route('users', '/users')

# web-view
config.add_route(name='new_dictionary', pattern='/dashboard/create_dictionary')
config.add_route(name='new_dictionary', pattern='/create_dictionary')

# web-view
config.add_route(name='edit_dictionary_properties', pattern='/dictionary/{client_id}/{object_id}/edit')
Expand Down
4 changes: 2 additions & 2 deletions lingvodoc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ class UserBlobs(Base, TableNameMixin, CompositeIdMixin):

def acl_by_groups(object_id, client_id, subject):
acls = [] #TODO DANGER if acls do not work -- incomment string below
# acls += [(Allow, Authenticated, ALL_PERMISSIONS)]
acls += [(Allow, Authenticated, ALL_PERMISSIONS)]
groups = DBSession.query(Group).filter_by(subject_override=True).join(BaseGroup).filter_by(subject=subject).all()

groups += DBSession.query(Group).filter_by(subject_client_id=client_id, subject_object_id=object_id).\
Expand All @@ -590,7 +590,7 @@ def acl_by_groups(object_id, client_id, subject):

def acl_by_groups_single_id(object_id, subject):
acls = [] #TODO DANGER if acls do not work -- incomment string below
# acls += [(Allow, Authenticated, ALL_PERMISSIONS)]
acls += [(Allow, Authenticated, ALL_PERMISSIONS)]
groups = DBSession.query(Group).filter_by(subject_override=True).join(BaseGroup).filter_by(subject=subject).all()
groups += DBSession.query(Group).filter_by(subject_client_id=None, subject_object_id=object_id).\
join(BaseGroup).filter_by(subject=subject).all()
Expand Down
301 changes: 256 additions & 45 deletions lingvodoc/scripts/initializedb.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lingvodoc/static/js/create-dictionary.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lingvodoc/static/js/dashboard.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lingvodoc/static/js/edit-dictionary.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lingvodoc/static/js/home.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lingvodoc/static/js/lingvodoc.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lingvodoc/static/js/user-upload.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lingvodoc/templates/create_dictionary.pt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="">Dictionaries</a></li>
<li class="active"><a href="${request.route_url('dashboard')}">Dictionaries</a></li>
<li><a href="${request.route_url('languages')}">Languages</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
Expand Down Expand Up @@ -118,7 +118,7 @@


<div ng-if="wizard.mode == 'import'">
<label for="selectFile">Select uploaded file</label>
<label for="selectFile">Select uploaded file</label> (<a href="${request.route_url('blob_upload')}">Upload dictionary</a>)
<select id="selectFile" class="form-control" ng-model="wizard.importedDictionaryId" ng-options="d.id as d.data.name for d in uploadedDictionaries track by d.id">

</select>
Expand Down Expand Up @@ -188,7 +188,7 @@
<option value="image" ng-if="field.data_type != 'image'">Image</option>
<option value="sound" ng-if="field.data_type == 'sound'" selected>Audio</option>
<option value="sound" ng-if="field.data_type != 'sound'">Audio</option>
<option value="grouping_tag" ng-if="field.data_type == 'grouping_tag'" selected>Groupping
<option value="grouping_tag" ng-if="field.data_type == 'grouping_tag'" selected>Grouping
tag
</option>
<option value="grouping_tag" ng-if="field.data_type != 'grouping_tag'">Groupping tag
Expand Down Expand Up @@ -271,7 +271,7 @@
<!--?Next <span class="glyphicon glyphicon-circle-arrow-right"></span>-->
<!--?</a>-->

<a class="btn btn-block btn-warning" ng-click="saveDictionary()">
<a class="btn btn-block btn-warning" ng-click="createPerspective()">
Complete <span class="glyphicon glyphicon-ok-sign"></span>
</a>

Expand Down
6 changes: 3 additions & 3 deletions lingvodoc/templates/dashboard.pt
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@
</td>

<td>
<a class="btn btn-primary" href="{{ getActionDictionaryLink(dictionary, 'view') }}"><span class="glyphicon glyphicon-list"></span> View</a>
<a class="btn btn-primary" ng-href="{{ getActionDictionaryLink(dictionary, 'edit'); }}"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a class="btn btn-primary" ng-href="{{ getActionDictionaryLink(dictionary, 'publish'); }}"><span class="glyphicon glyphicon-print"></span> Publish</a>
<a class="btn btn-primary" href="#" ng-click="follow(getActionDictionaryLink(dictionary, 'view'))"><span class="glyphicon glyphicon-list"></span> View</a>
<a class="btn btn-primary" href="#" ng-click="follow(getActionDictionaryLink(dictionary, 'edit'))"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a class="btn btn-primary" href="#" ng-click="follow(getActionDictionaryLink(dictionary, 'publish'))"><span class="glyphicon glyphicon-print"></span> Publish</a>
</td>


Expand Down
41 changes: 39 additions & 2 deletions lingvodoc/templates/home.pt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@

</head>

<body class="body-dashboard" ng-app="DashboardModule">
<body class="body-dashboard" ng-app="HomeModule">


<div id="clientId" data-lingvodoc="${client_id}"></div>
<div id="dictionariesUrl" data-lingvodoc="${request.route_url('dictionaries')}"></div>
<div id="languagesUrl" data-lingvodoc="${request.route_url('get_languages')}"></div>

<nav class="lingvodoc-navbar">
<div class="container">
Expand Down Expand Up @@ -64,13 +69,35 @@
</nav>


<div class="container">
<div class="container" ng-controller="HomeController" ng-cloak>

<blockquote>Проект выполняется при финансовой поддержке грантов Президента РФ МД-6198.2013.6 (рук. Ю.В.Норманская) и
Программы ОИФН Типологическое и историческое изучение языковых явлений в их соотношении с культурной эволюцией,
реконструкция культуры по данным языка (рук. А.В.Дыбо)
</blockquote>


<h2>Опубликованные словари</h2>

<div ng-repeat="group in groupDictionaries">
<h3>{{ group.name }}</h3>

<ul class="entries_list">
<li ng-repeat="dictionary in group.dicts">
{{ dictionary.name }}

<ul class="entries_list">
<li ng-repeat="p in dictionary.links">
<a href="{{ p.link }}">{{ p.name }}</a>
</li>
</ul>

</li>
</ul>

</div>


<h1>О проекте</h1>

<div>
Expand Down Expand Up @@ -153,6 +180,16 @@

<p>
</div>










</div>

</body>
Expand Down
4 changes: 2 additions & 2 deletions lingvodoc/templates/publish_dictionary.pt
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@
<div ng-if="field.isGroup">
<div ng-if="field.isGroup">
<button type="button" class="btn btn-default btn-sm"
ng-click="viewGroup(lexicalEntry, field, fieldValues)">
ng-click="viewGroup(lexicalEntry, field, fieldValues)" ng-if="fieldValues.length > 0">
<span class="glyphicon glyphicon-list">View</span>
</button>
</div>
</div>

<div ng-if="field.data_type == 'grouping_tag'">
<button type="button" class="btn btn-default btn-sm"
ng-click="viewGroupingTag(lexicalEntry.client_id, lexicalEntry.object_id, field, fieldValues)">
ng-click="viewGroupingTag(lexicalEntry.client_id, lexicalEntry.object_id, field, fieldValues)" ng-if="fieldValues.length > 0">
<span class="glyphicon glyphicon-list">View</span>
</button>
</div>
Expand Down
6 changes: 6 additions & 0 deletions lingvodoc/templates/user_upload.pt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@

<tbody>





<tr ng-repeat="file in files">
<td>
{{ file.name }}
Expand All @@ -109,6 +113,8 @@

</table>

<p class="bg-warning" ng-if="uploadMsg">Upload started. You will be redirected automatically.</p>


<span class="btn btn-default btn-file">
Upload <input type="file" on-read-file="upload($file)"></span>
Expand Down
4 changes: 2 additions & 2 deletions lingvodoc/templates/view_dictionary.pt
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@
<div ng-if="field.isGroup">
<div ng-if="field.isGroup">
<button type="button" class="btn btn-default btn-sm"
ng-click="viewGroup(lexicalEntry, field, fieldValues)">
ng-click="viewGroup(lexicalEntry, field, fieldValues)" ng-if="fieldValues.length > 0">
<span class="glyphicon glyphicon-list">View</span>
</button>
</div>
</div>

<div ng-if="field.data_type == 'grouping_tag'">
<button type="button" class="btn btn-default btn-sm"
ng-click="viewGroupingTag(lexicalEntry.client_id, lexicalEntry.object_id, field, fieldValues)">
ng-click="viewGroupingTag(lexicalEntry.client_id, lexicalEntry.object_id, field, fieldValues)" ng-if="fieldValues.length > 0">
<span class="glyphicon glyphicon-list">View</span>
</button>
</div>
Expand Down
16 changes: 8 additions & 8 deletions lingvodoc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,10 +1030,10 @@ def dictionaries_list(request):
languages = req['languages']
dicts = DBSession.query(Dictionary)
if published:
if published == 'true':
dicts = dicts.filter(Dictionary).filter_by(state='published')
if published == 'false':
dicts = dicts.filter(Dictionary).filter(Dictionary.state != 'published')
if published:
dicts = dicts.filter_by(state='Published')
# else:
# dicts = dicts.filter_by(state!='Published')
if user_created:
clients = DBSession.query(Client).filter(Client.user_id.in_(user_created)).all()
cli = [o.id for o in clients]
Expand Down Expand Up @@ -2304,7 +2304,7 @@ def login_get(request):

@view_config(route_name='login', request_method='POST')
def login_post(request):
next = request.params.get('next') or request.route_url('dashboard')
next = request.params.get('next') or request.route_url('home')
login = request.POST.get('login', '')
password = request.POST.get('password', '')
print(login)
Expand Down Expand Up @@ -2368,9 +2368,9 @@ def signup_post(request):
email = request.POST.getone('email')
password = request.POST.getone('password')

day = request.POST.getone('day')
month = request.POST.getone('month')
year = request.POST.getone('year')
day = request.POST.get('day', "1")
month = request.POST.get('month', "1")
year = request.POST.get('year', "1970")
birthday = datetime.datetime.strptime(day + month + year, "%d%m%Y").date()

if DBSession.query(User).filter_by(login=login).first():
Expand Down
3 changes: 2 additions & 1 deletion webui/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ module.exports = function(grunt) {
'bower_components/angular/angular.js',
'bower_components/bootstrap-sass/assets/javascripts/bootstrap.js',
'bower_components/angular-bootstrap/ui-bootstrap.js',
'bower_components/angular-bootstrap/ui-bootstrap-tpls.js'
'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
'src/js/home.js'
],
dest: '../lingvodoc/static/js/home.js'
},
Expand Down
16 changes: 2 additions & 14 deletions webui/src/js/create_dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ app.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/create/step1');
});

app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$interval', '$state', '$log', function ($scope, $http, $modal, $interval, $state, $log) {
app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$interval', '$state', '$location', '$log', function ($scope, $http, $modal, $interval, $state, $location, $log) {

var clientId = $('#clientId').data('lingvodoc');
var userId = $('#userId').data('lingvodoc');
Expand Down Expand Up @@ -131,16 +131,9 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int
for (var i = 0; i < $scope.languages.length; i++) {
if ($scope.languages[i].client_id == ids[0] && $scope.languages[i].object_id == ids[1])

$log.info($scope.languages[i]);

return $scope.languages[i];
}


$log.info('no found!');
}

$log.info('no found id!');
};


Expand Down Expand Up @@ -183,7 +176,6 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int
alert('Failed to save language!');
});
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};

Expand Down Expand Up @@ -216,13 +208,11 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int

var language = getLanguageById($scope.dictionaryData.languageId);
if ((!$scope.dictionaryData.name && $scope.wizard.mode == 'create') || (typeof $scope.wizard.importedDictionaryId != 'string' && $scope.wizard.mode == 'import') || !language) {

return;
}

if ($scope.wizard.mode == 'create') {


var dictionaryObj = {
'parent_client_id': language.client_id,
'parent_object_id': language.object_id,
Expand Down Expand Up @@ -290,7 +280,7 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int
var setFieldsUrl = '/dictionary/' + encodeURIComponent($scope.dictionaryData.dictionary_client_id) + '/' + encodeURIComponent($scope.dictionaryData.dictionary_object_id) + '/perspective/' + encodeURIComponent($scope.dictionaryData.perspective_client_id) + '/' + encodeURIComponent($scope.dictionaryData.perspective_object_id) + '/fields';

$http.post(setFieldsUrl, exportPerpective($scope.perspective)).success(function(data, status, headers, config) {
$state.go('create.step3');
window.location = '/dashboard';
}).error(function(data, status, headers, config) {
alert('Failed to create perspective!');
});
Expand Down Expand Up @@ -388,8 +378,6 @@ app.controller('CreateDictionaryController', ['$scope', '$http', '$modal', '$int
}
}

$log.info($scope.uploadedDictionaries);


}).error(function (data, status, headers, config) {
});
Expand Down
11 changes: 7 additions & 4 deletions webui/src/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ app.controller('DashboardController', ['$scope', '$http', '$interval', '$log', f
}
};


$scope.test = function () {
console.log($scope.dictionaries);
$scope.follow = function(link) {
if (!link) {
alert('Please, select perspective first.');
return;
}
window.location = link;
};

$scope.getCompositeKey = function (object) {
Expand All @@ -60,7 +63,7 @@ app.controller('DashboardController', ['$scope', '$http', '$interval', '$log', f
$http.get(getPerspectivesUrl).success((function (index) {
return function (data, status, headers, config) {
$scope.dictionaries[index]['perspectives'] = data.perspectives;
$scope.dictionaries[index]['selectedPerspectiveId'] = -1;
$scope.dictionaries[index]['selectedPerspectiveId'] = -1;
};
})(i)).error(function (data, status, headers, config) {
// error handling
Expand Down
23 changes: 22 additions & 1 deletion webui/src/js/edit_dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,28 @@ app.controller('editGroupingTagController', ['$scope', '$http', '$modalInstance'
};

$scope.linkEntry = function(index) {
$scope.connectedEntries.push($scope.suggestedEntries[index]);

//{entity_type: <entity_type>, content: <tag>, connections: [{object_id: <obj_id>, client_id: <cl_id>}


var linkObject = {
'entity_type': 'Etymology',
'connections': [{
'client_id': groupParams.clientId,
'object_id': groupParams.objectId
},
{
'client_id': $scope.suggestedEntries[index].clientId,
'object_id': $scope.suggestedEntries[index].objectId
}]};


var url = '/group_entity';
$http.post(url, linkObject).success(function(data, status, headers, config) {
$scope.connectedEntries.push($scope.suggestedEntries[index]);
}).error(function(data, status, headers, config) {

});
};


Expand Down
Loading

0 comments on commit 56e0d90

Please sign in to comment.