Commit 4afdffa1 authored by Bruno Martin's avatar Bruno Martin
Browse files

remove django from change app name

parent 02fd921f
......@@ -77,7 +77,7 @@ Ready to contribute? Here's how to set up `django-courses-legacy` for local deve
5. When you're done making changes, check that your changes pass flake8 and the
tests, including testing other Python versions with tox::
$ flake8 django_courses_legacy tests
$ flake8 courses_legacy tests
$ python setup.py test
$ tox
......@@ -109,4 +109,4 @@ Tips
To run a subset of tests::
$ python -m unittest tests.test_django_courses_legacy
$ python -m unittest tests.test_courses_legacy
......@@ -3,4 +3,4 @@ include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
recursive-include django_courses_legacy *.html *.png *.gif *js *.css *jpg *jpeg *svg *py
recursive-include courses_legacy *.html *.png *.gif *js *.css *jpg *jpeg *svg *py
......@@ -28,7 +28,7 @@ clean-pyc: ## remove Python file artifacts
find . -name '*~' -exec rm -f {} +
lint: ## check style with flake8
flake8 django_courses_legacy tests
flake8 courses_legacy tests
test: ## run tests quickly with the default Python
python runtests.py tests
......@@ -37,7 +37,7 @@ test-all: ## run tests on every Python version with tox
tox
coverage: ## check code coverage quickly with the default Python
coverage run --source django_courses_legacy runtests.py tests
coverage run --source courses_legacy runtests.py tests
coverage report -m
coverage html
open htmlcov/index.html
......@@ -45,7 +45,7 @@ coverage: ## check code coverage quickly with the default Python
docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/django-courses-legacy.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ django_courses_legacy
sphinx-apidoc -o docs/ courses_legacy
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html
......
......@@ -31,7 +31,7 @@ Add it to your `INSTALLED_APPS`:
INSTALLED_APPS = (
...
'django_courses_legacy.apps.DjangoCoursesLegacyConfig',
'courses_legacy.apps.CoursesLegacyConfig',
...
)
......@@ -39,12 +39,12 @@ Add Django Courses Legacy's URL patterns:
.. code-block:: python
from django_courses_legacy import urls as django_courses_legacy_urls
from courses_legacy import urls as courses_legacy_urls
urlpatterns = [
...
url(r'^', include(django_courses_legacy_urls)),
url(r'^', include(courses_legacy_urls)),
...
]
......
......@@ -2,5 +2,5 @@
from django.apps import AppConfig
class DjangoCoursesLegacyConfig(AppConfig):
name = 'django_courses_legacy'
class CoursesLegacyConfig(AppConfig):
name = 'courses_legacy'
(function (angular) {
'use strict';
// Declare app level module which depends on filters, and services
angular.module('notes', [
'notes.controllers',
'notes.services',
'django',
'header',
'gettext',
'ui.bootstrap',
]);
})(angular);
(function (angular) {
'use strict';
/* Controllers */
angular.module('notes.controllers', []).
controller('NoteCtrl', ['$scope', '$window', '$location', 'LessonData', 'Note',
function ($scope, $window, $location, LessonData, Note) {
$scope.show_notes = false;
$scope.save_note = function() {
var promisse;
$scope.note.text = $scope.note_text;
if ($scope.note.id) {
promisse = $scope.note.$update({note_id: $scope.note.id});
} else {
promisse = $scope.note.$save();
}
promisse.then(function() {
$('.notes.message.success').show().delay(2000).fadeOut();
}).catch(function() {
$('.notes.message.failure').show().delay(2000).fadeOut();
});
};
function load_note() {
LessonData.then(function (lesson) {
$scope.currentUnit.$promise.then(function() {
var currentUnitId = $scope.currentUnit.id;
$scope.currentUnitPos = $scope.findUnitPos($scope.currentUnit);
Note.get({content_type: window.unit_content_type_id, object_id: currentUnitId}, function (notes) {
if (notes.length > 0){
$scope.note = notes[0];
} else {
$scope.note = new Note();
$scope.note.content_type = window.unit_content_type_id;
$scope.note.object_id = currentUnitId;
}
$scope.note_text = $scope.note.text;
});
});
});
}
var prevUnitPos = $scope.currentUnitPos;
$scope.$watch(function() {
return $location.path();
}, function(){
if (prevUnitPos != $scope.currentUnitPos) {
load_note();
prevUnitPos = $scope.currentUnitPos;
}
});
load_note();
$scope.$on('$locationChangeStart', function(event, newVal, oldVal) {
if ($scope.note && $scope.note.text != $scope.note_text)
$scope.save_note();
});
}]).
controller('CourseNotesCtrl', ['$scope', '$window', 'CourseUserNotes', 'Note',
function ($scope, $window, CourseUserNotes, Note) {
var course_slug = $window.location.pathname.split('/')[2];
CourseUserNotes.query({course_slug: course_slug}, function(lessons){
function compare(a,b) {
if (a.position < b.position)
return -1;
if (a.position > b.position)
return 1;
return 0;
}
lessons.sort(compare);
angular.forEach(lessons, function(lesson) {
lesson.units_notes.sort(compare);
});
$scope.lessons = lessons;
});
$scope.delele_note = function(course, lesson, unit, note) {
if(!confirm('Tem certeza que deseja remover esta anotação?')) return;
Note.remove({note_id: note.id}, function (){
var index;
if (lesson.units_notes.length > 1) {
index = lesson.units_notes.indexOf(unit);
lesson.units_notes.splice(index, 1);
} else {
index = $scope.lessons.indexOf(lesson);
$scope.lessons.splice(index, 1);
}
});
};
}]).
controller('UserNotesCtrl', ['$scope', '$window', 'UserNotes', 'Note',
function ($scope, $window, UserNotes, Note) {
function compare(a,b) {
if (a.position < b.position)
return -1;
if (a.position > b.position)
return 1;
return 0;
}
UserNotes.query({}, function(courses){
angular.forEach(courses, function(course) {
course.lessons_notes.sort(compare);
angular.forEach(course.lessons_notes, function(lesson) {
lesson.units_notes.sort(compare);
});
});
$scope.courses = courses;
});
$scope.delele_note = function(course, lesson, unit, note) {
if(!confirm('Tem certeza que deseja remover esta anotação?')) return;
Note.remove({note_id: note.id}, function (){
var index;
if (lesson.units_notes.length > 1) {
index = lesson.units_notes.indexOf(unit);
lesson.units_notes.splice(index, 1);
} else {
index = course.lessons_notes.indexOf(lesson);
course.lessons_notes.splice(index, 1);
}
course.course_notes_number -= 1;
});
};
}]);
})(angular);
(function (angular) {
'use strict';
/* Services */
angular.module('notes.services', ['ngResource']).
factory('Note', function($resource){
return $resource('/api/note/:note_id', {}, {
update: {method: 'PUT'},
get: {method: 'GET', isArray: true}
});
}).
factory('CourseUserNotes', function($resource){
return $resource('/api/user_notes/:course_slug', {}, {
});
}).
factory('UserNotes', function($resource){
return $resource('/api/user_notes/', {}, {
});
});
})(angular);
......@@ -5,7 +5,7 @@ from django.views.generic import TemplateView
from . import views
app_name = 'django_courses_legacy'
app_name = 'courses_legacy'
urlpatterns = [
url(r'', TemplateView.as_view(template_name="base.html")),
]
from django.conf import settings
from django.urls import reverse_lazy
from braces.views._access import AccessMixin
from django.shortcuts import redirect
class AcceptedTermsRequiredMixin(AccessMixin):
"""Verify that the current user has accepted Terms of Service."""
def dispatch(self, request, *args, **kwargs):
if not self.request.user.accepted_terms and settings.TERMS_ACCEPTANCE_REQUIRED:
return redirect(reverse_lazy('accept_terms'))
return super(AcceptedTermsRequiredMixin, self).dispatch(request, *args, **kwargs)
File moved
......@@ -22,7 +22,7 @@ cwd = os.getcwd()
parent = os.path.dirname(cwd)
sys.path.append(parent)
import django_courses_legacy
import courses_legacy
# -- General configuration -----------------------------------------------------
......@@ -54,9 +54,9 @@ copyright = u'2019, hacklab/'
# built documents.
#
# The short X.Y version.
version = django_courses_legacy.__version__
version = courses_legacy.__version__
# The full version, including alpha/beta/rc tags.
release = django_courses_legacy.__version__
release = courses_legacy.__version__
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -8,7 +8,7 @@ To use Django Courses Legacy in a project, add it to your `INSTALLED_APPS`:
INSTALLED_APPS = (
...
'django_courses_legacy.apps.DjangoCoursesLegacyConfig',
'courses_legacy.apps.CoursesLegacyConfig',
...
)
......@@ -16,11 +16,11 @@ Add Django Courses Legacy's URL patterns:
.. code-block:: python
from django_courses_legacy import urls as django_courses_legacy_urls
from courses_legacy import urls as courses_legacy_urls
urlpatterns = [
...
url(r'^', include(django_courses_legacy_urls)),
url(r'^', include(courses_legacy_urls)),
...
]
......@@ -5,7 +5,7 @@ tag = True
[bumpversion:file:setup.py]
[bumpversion:file:django_courses_legacy/__init__.py]
[bumpversion:file:courses_legacy/__init__.py]
[wheel]
universal = 1
......@@ -13,7 +13,7 @@ universal = 1
[flake8]
ignore = D203
exclude =
django_courses_legacy/migrations,
courses_legacy/migrations,
.git,
.tox,
docs/conf.py,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment