From: yomguy Date: Wed, 4 Apr 2012 16:08:12 +0000 (+0200) Subject: smoother tw style, add tags and a good messaging thx to postman X-Git-Tag: 0.2~79 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ef1737a50fcd2f763e813d50f92f12e92bd47c4b;p=teleforma.git smoother tw style, add tags and a good messaging thx to postman --- diff --git a/doc/teleforma-all.dot b/doc/teleforma-all.dot index 12c40155..46b8625b 100644 --- a/doc/teleforma-all.dot +++ b/doc/teleforma-all.dot @@ -161,31 +161,6 @@ digraph name { >] - django_contrib_auth_models_Message [label=< - - - - - - - - - - - -
Message
idAutoField
messageTextField
- >] - @@ -304,6 +279,9 @@ digraph name { + + + django_contrib_admin_models_LogEntry [label=< -
- >] - - telemeta_models_media_MediaResource [label=< - - - - -
MediaResource
<ModelCore>
>] @@ -503,6 +470,17 @@ digraph name { > + + >] + + telemeta_models_media_MediaResource [label=< + + + + +
MediaResource
<ModelCore>
>] @@ -2790,6 +2768,38 @@ digraph name { > + + >] + + teleforma_models_CourseType [label=< + + + + + + + + + + + + + +
CourseType
idAutoField
nameCharField
descriptionCharField
>] @@ -2822,10 +2832,10 @@ digraph name { > public_idcode CharFieldCharField @@ -3108,6 +3118,13 @@ digraph name { >AutoField + code + CharField + name @@ -3115,6 +3132,20 @@ digraph name { >CharField + synthesis_note + BooleanField + + obligation + BooleanField + >] @@ -3140,6 +3171,13 @@ digraph name { >CharField + code + CharField + >] @@ -3165,15 +3203,22 @@ digraph name { >CharField + code + CharField + >] - teleforma_models_Student [label=< + teleforma_models_Oral [label=< + >Oral + + +
Student
oral_1name CharField
oral_2code CharFieldCharField
+ >] + + teleforma_models_Student [label=< + + + + + + @@ -3308,6 +3371,132 @@ digraph name { + + + + + postman_models_Message [label=< +
Student
idAutoField
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Message
idAutoField
subjectCharField
bodyTextField
emailEmailField
sent_atDateTimeField
read_atDateTimeField
replied_atDateTimeField
sender_archivedBooleanField
recipient_archivedBooleanField
sender_deleted_atDateTimeField
recipient_deleted_atDateTimeField
moderation_statusCharField
moderation_dateDateTimeField
moderation_reasonCharField
+ >] + + postman_models_PendingMessage [label=< + + + + + +
PendingMessage
+ >] + + + django_contrib_auth_models_Permission -> django_contrib_contenttypes_models_ContentType @@ -3330,12 +3519,6 @@ digraph name { [label="user_permissions (user)"] [arrowhead=dot arrowtail=dot, dir=both]; - - - django_contrib_auth_models_Message -> django_contrib_auth_models_User - [label="user (_message_set)"] [arrowhead=none, arrowtail=dot]; - - @@ -3347,6 +3530,7 @@ digraph name { + django_contrib_admin_models_LogEntry -> django_contrib_auth_models_User @@ -3703,6 +3887,8 @@ digraph name { + + teleforma_models_Course -> teleforma_models_Department [label="department (course)"] [arrowhead=none, arrowtail=dot]; @@ -3711,6 +3897,10 @@ digraph name { teleforma_models_Course -> teleforma_models_Category [label="category (course)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Course -> teleforma_models_CourseType + [label="type (course)"] [arrowhead=none, arrowtail=dot]; + @@ -3747,9 +3937,17 @@ digraph name { teleforma_models_Document -> teleforma_models_Course [label="course (document)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Document -> teleforma_models_Conference + [label="conference (document)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Media -> teleforma_models_Course + [label="course (media)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Media -> teleforma_models_Conference [label="conference (media)"] [arrowhead=none, arrowtail=dot]; @@ -3771,6 +3969,8 @@ digraph name { + + teleforma_models_Student -> django_contrib_auth_models_User [label="user (student)"] [arrowhead=none, arrowtail=dot]; @@ -3799,6 +3999,14 @@ digraph name { teleforma_models_Student -> teleforma_models_Speciality [label="written_speciality (student_written_spe)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Student -> teleforma_models_Oral + [label="oral_1 (oral_1)"] [arrowhead=none, arrowtail=dot]; + + + teleforma_models_Student -> teleforma_models_Oral + [label="oral_2 (oral_2)"] [arrowhead=none, arrowtail=dot]; + @@ -3810,4 +4018,30 @@ digraph name { + + + + + postman_models_Message -> django_contrib_auth_models_User + [label="sender (sent_messages)"] [arrowhead=none, arrowtail=dot]; + + + postman_models_Message -> django_contrib_auth_models_User + [label="recipient (received_messages)"] [arrowhead=none, arrowtail=dot]; + + + postman_models_Message -> postman_models_Message + [label="parent (next_messages)"] [arrowhead=none, arrowtail=dot]; + + + postman_models_Message -> postman_models_Message + [label="thread (child_messages)"] [arrowhead=none, arrowtail=dot]; + + + postman_models_Message -> django_contrib_auth_models_User + [label="moderation_by (moderated_messages)"] [arrowhead=none, arrowtail=dot]; + + + + } diff --git a/doc/teleforma-all.pdf b/doc/teleforma-all.pdf index 02ae4db6..c028ffed 100644 Binary files a/doc/teleforma-all.pdf and b/doc/teleforma-all.pdf differ diff --git a/doc/teleforma.dot b/doc/teleforma.dot index 8234bf21..59a0f8a5 100644 --- a/doc/teleforma.dot +++ b/doc/teleforma.dot @@ -148,6 +148,38 @@ digraph name { > + + >] + + teleforma_models_CourseType [label=< + + + + + + + + + + + + + +
CourseType
idAutoField
nameCharField
descriptionCharField
>] @@ -180,10 +212,10 @@ digraph name { > public_idcode CharFieldCharField @@ -466,6 +498,13 @@ digraph name { >AutoField + code + CharField + name @@ -473,6 +512,20 @@ digraph name { >CharField + synthesis_note + BooleanField + + obligation + BooleanField + >] @@ -498,6 +551,13 @@ digraph name { >CharField + code + CharField + >] @@ -523,15 +583,22 @@ digraph name { >CharField + code + CharField + >] - teleforma_models_Student [label=< + teleforma_models_Oral [label=< + >Oral + + +
Student
oral_1name CharField
oral_2code CharFieldCharField
+ >] + + teleforma_models_Student [label=< + + + + + + @@ -648,6 +733,8 @@ digraph name { + + teleforma_models_Course -> teleforma_models_Department [label="department (course)"] [arrowhead=none, arrowtail=dot]; @@ -656,6 +743,10 @@ digraph name { teleforma_models_Course -> teleforma_models_Category [label="category (course)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Course -> teleforma_models_CourseType + [label="type (course)"] [arrowhead=none, arrowtail=dot]; + @@ -700,9 +791,17 @@ digraph name { teleforma_models_Document -> teleforma_models_Course [label="course (document)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Document -> teleforma_models_Conference + [label="conference (document)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Media -> teleforma_models_Course + [label="course (media)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Media -> teleforma_models_Conference [label="conference (media)"] [arrowhead=none, arrowtail=dot]; @@ -732,6 +831,8 @@ digraph name { + + django_contrib_auth_models_User [label=<
Student
idAutoField
@@ -768,6 +869,14 @@ digraph name { teleforma_models_Student -> teleforma_models_Speciality [label="written_speciality (student_written_spe)"] [arrowhead=none, arrowtail=dot]; + + teleforma_models_Student -> teleforma_models_Oral + [label="oral_1 (oral_1)"] [arrowhead=none, arrowtail=dot]; + + + teleforma_models_Student -> teleforma_models_Oral + [label="oral_2 (oral_2)"] [arrowhead=none, arrowtail=dot]; + diff --git a/doc/teleforma.pdf b/doc/teleforma.pdf index b8303e5b..368f810e 100644 Binary files a/doc/teleforma.pdf and b/doc/teleforma.pdf differ diff --git a/example/settings.py b/example/settings.py index a94f047d..4c38b4d4 100644 --- a/example/settings.py +++ b/example/settings.py @@ -3,6 +3,7 @@ import os import sys +from django.core.urlresolvers import reverse_lazy sys.dont_write_bytecode = True @@ -17,10 +18,10 @@ MANAGERS = ADMINS DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': 'sandbox.sql', # Or path to database file if using sqlite3. - 'USER': '', # Not used with sqlite3. - 'PASSWORD': '', # Not used with sqlite3. + 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': 'teleforma', # Or path to database file if using sqlite3. + 'USER': 'teleforma', # Not used with sqlite3. + 'PASSWORD': 'HMYsrZLEtYeBrvER', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } @@ -140,6 +141,7 @@ INSTALLED_APPS = ( TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.request', 'django.contrib.auth.context_processors.auth', + 'postman.context_processors.inbox', ) TELEMETA_ORGANIZATION = 'Parisson' @@ -154,13 +156,14 @@ TELEMETA_DOWNLOAD_ENABLED = True TELEMETA_STREAMING_FORMATS = ('mp3', 'webm') TELEMETA_DOWNLOAD_FORMATS = ('wav', 'mp3', 'webm') TELEMETA_PUBLIC_ACCESS_PERIOD = 51 + AUTH_PROFILE_MODULE = 'telemeta.userprofile' +LOGIN_URL = '/login/' +LOGIN_REDIRECT_URL = reverse_lazy('teleforma-courses') SESSION_EXPIRE_AT_BROWSER_CLOSE = False -LOGIN_URL = '/login' -LOGIN_REDIRECT_URL = '/desk/courses' - EMAIL_HOST = 'localhost' DEFAULT_FROM_EMAIL = 'webmaster@parisson.com' POSTMAN_AUTO_MODERATE_AS=True + diff --git a/setup.py b/setup.py index c0a1fedf..e9c06a92 100644 --- a/setup.py +++ b/setup.py @@ -3,13 +3,13 @@ from setuptools import setup, find_packages import os import teleforma -CLASSIFIERS = ['Environment :: Web Environment', 'Framework :: Django', 'Intended Audience :: Science/Research', 'Intended Audience :: Education', 'Programming Language :: Python', 'Programming Language :: JavaScript', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Internet :: WWW/HTTP :: WSGI :: Application', 'Topic :: Multimedia :: Sound/Audio', 'Topic :: Multimedia :: Sound/Audio :: Analysis', 'Topic :: Multimedia :: Sound/Audio :: Players', 'Topic :: Scientific/Engineering :: Information Analysis', 'Topic :: System :: Archiving', ] +CLASSIFIERS = ['Environment :: Web Environment', 'Framework :: Django', 'Intended Audience :: Education', 'Programming Language :: Python', 'Programming Language :: JavaScript', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Internet :: WWW/HTTP :: WSGI :: Application', 'Topic :: Multimedia :: Sound/Audio', 'Topic :: Multimedia :: Sound/Audio :: Analysis', 'Topic :: Multimedia :: Sound/Audio :: Players', 'Topic :: Scientific/Engineering :: Information Analysis', 'Topic :: System :: Archiving', ] README = os.path.join(os.path.dirname(__file__), 'README.rst') setup( name = "TeleForma", - url = "http://parisson.com/products/teleforma", + url = "http://parisson.com", description = "open multimedia e-leaning system", long_description = open(README).read(), author = "Guillaume Pellerin", diff --git a/teleforma/admin.py b/teleforma/admin.py index 6dd8bba5..ee190aaa 100644 --- a/teleforma/admin.py +++ b/teleforma/admin.py @@ -29,6 +29,10 @@ class TrainingAdmin(admin.ModelAdmin): class CourseAdmin(admin.ModelAdmin): model = Course +class ProfessorAdmin(admin.ModelAdmin): + model = Professor + filter_horizontal = ['courses'] + admin.site.register(Organization) admin.site.register(Department) admin.site.register(Category) @@ -43,6 +47,8 @@ admin.site.register(Training, TrainingAdmin) admin.site.register(Procedure) admin.site.register(Speciality) admin.site.register(CourseType) +admin.site.register(Oral) +admin.site.register(Professor, ProfessorAdmin) diff --git a/teleforma/context_processors.py b/teleforma/context_processors.py new file mode 100644 index 00000000..bbb960ca --- /dev/null +++ b/teleforma/context_processors.py @@ -0,0 +1,7 @@ +from django.contrib.sites.models import Site + +def main(request): + return {'site': Site.objects.get_current()} + + + diff --git a/teleforma/htdocs/css/teleforma_black.css b/teleforma/htdocs/css/teleforma_black.css index a3529943..a1fc7e39 100644 --- a/teleforma/htdocs/css/teleforma_black.css +++ b/teleforma/htdocs/css/teleforma_black.css @@ -58,16 +58,12 @@ a img { border: none; } #content { /*margin-top: 1em;*/ - margin-bottom: 0em; -} - -#content { position: relative; - margin-left: 2em; + margin-left: 10%; margin-right: 2em; + margin-bottom: 0em; } - #content ul, #content ul ul, #content ol { list-style: square; padding: .7em; @@ -147,9 +143,9 @@ a img { border: none; } float: right; border: 1px solid #999; background-color: #eee; - -moz-border-radius: 8px 8px 8px 8px; - -webkit-border-radius: 8px 8px 8px 8px; - border-radius: 8px 8px 8px 8px; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; } #rightcol .analyzer, #rightcol .exporter, .markers { @@ -299,9 +295,9 @@ label.disabled { color: #d7d7d7 } left: 35%; background-color: #000000; padding: 0.3em 0em 0.3em 0.3em; - -moz-border-radius: 8px 8px 8px 8px; - -webkit-border-radius: 8px 8px 8px 8px; - border-radius: 8px 8px 8px 8px; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; } #quick_search form { float: left; @@ -346,9 +342,9 @@ label.disabled { color: #d7d7d7 } font-size: 0.9em; background-color: #000000; padding: 1em; - -moz-border-radius: 8px 8px 8px 8px; - -webkit-border-radius: 8px 8px 8px 8px; - border-radius: 8px 8px 8px 8px; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; } #auth_info a { @@ -395,9 +391,9 @@ form.login .submit { border: none; border: 1px solid #000000; margin-bottom: 1em; - -moz-border-radius: 8px 8px 8px 8px; - -webkit-border-radius: 8px 8px 8px 8px; - border-radius: 8px 8px 8px 8px; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; } #searchform p { background-color: transparent; @@ -437,9 +433,12 @@ form.login .submit { /* Main navigation bar (borrowed from Trac) */ #menu { background-color: #000000 ; + background:no-repeat url(http://si0.twimg.com/a/1333470865/t1/img/twitter_web_sprite_bgs.png) 0 0; + background-color:#ebebeb; + background-repeat:repeat; font: normal verdana,'Bitstream Vera Sans',helvetica,arial,sans-serif; - border-top: .25em solid #000000; - padding-left:200px; + border-top: 1px solid #333; + padding-left:15%; } #menu a, #menu a:visited{ @@ -448,7 +447,7 @@ form.login .submit { text-decoration:none; border-bottom-width:.5em; border-bottom-style: solid; - background-color: #000000; + background-color: transparent; -webkit-border-top-left-radius:5px 5px; moz-border-radius-topleft: 5px 5px; border-top-left-radius: 5px 5px; @@ -473,7 +472,7 @@ form.login .submit { #menu .black { border-bottom-color: #000000; } #menu .red { border-bottom-color: #DD0000; } #menu .violet { border-bottom-color: #A00020; } -#menu .origin { border-bottom-color: #000000; } +#menu .origin { border-bottom-color: transparent; } * html #menu :link, * html #menu :visited { background-position: 1px 0 } @@ -516,10 +515,10 @@ color:#FFF; margin:0 0 0 -2px; padding:0; list-style: none outside none; - border-left:2px solid #000000; - border-right:2px solid #000000; - border-bottom:2px solid #000000; - background-color: #000000; + border-left:3px solid #333; + border-right:3px solid #333; + border-bottom:3px solid #333; + background-color: #333; color: #FFF; width:100%; } @@ -528,6 +527,9 @@ color:#FFF; width: 100%; float:left; border-bottom:0px solid #fff; + background:no-repeat url(http://si0.twimg.com/a/1333470865/t1/img/twitter_web_sprite_bgs.png) 0 0; + background-color:#ebebeb; + background-repeat:repeat; } /* display block will make the link fill the whole area of LI */ @@ -561,12 +563,15 @@ color:#FFF; /* Footer (borrowed from Trac) */ #footer { background: #000000; + background:no-repeat url(http://si0.twimg.com/a/1333470865/t1/img/twitter_web_sprite_bgs.png) 0 0; + background-color:#ebebeb; + background-repeat:repeat; clear: both; color: #FFF; font-size: 10px; border-top: 1px solid; height: 31px; - padding: 0.5em 0.5em 1.1em 0.5em; + padding: 0em 0.5em 0.9em 0.5em; margin-top: 2.5em; } #footer :link, #footer :visited { color: #FFF; } @@ -799,7 +804,7 @@ table.instruments tbody td { table.listing { border-spacing: 0; - padding: 0em 1em 1em 2em; + padding: 0em 1em 1em 1em; } .fullpage table.listing { @@ -920,9 +925,9 @@ img.align-left { background-image: url(../images/grid_bg_2.png); padding: 0.3em 0.4em 0.4em 0.4em; margin: 3.5em 0em 1.5em 1.5em; - -moz-border-radius: 8px 8px 8px 8px; - -webkit-border-radius: 8px 8px 8px 8px; - border-radius: 8px 8px 8px 8px; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; } #module-set .module h3 { @@ -948,7 +953,7 @@ a.image-link { } .home-description { - padding-right: 33%; + padding-right: 15%; display: block; } @@ -1015,9 +1020,9 @@ a.image-link { /*padding: 0.3em 0.8em 0.8em 0.8em; margin: 0 0 1.5em 1.5em;*/ - -moz-border-radius: 8px 8px 8px 8px; - -webkit-border-radius: 8px 8px 8px 8px; - border-radius: 8px 8px 8px 8px; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; } .roundBorder10{ /*padding: 0.3em 0.8em 0.8em 0.8em; @@ -1278,7 +1283,7 @@ input,textarea{ #module-set-left { float: left; clear: left; - padding: 1.3em 0.8em 0.8em 0em; + padding: 0em 0.8em 0.8em 0em; } #module-set-left .module { @@ -1286,9 +1291,9 @@ input,textarea{ background-image: url(../images/grid_bg_2.png); padding: 0.3em 0.4em 0.4em 0.4em; margin: 0em 0em 1.5em 0em; - -moz-border-radius: 8px 8px 8px 8px; - -webkit-border-radius: 8px 8px 8px 8px; - border-radius: 8px 8px 8px 8px; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; } #module-set-left .module h3 { @@ -1309,39 +1314,51 @@ input,textarea{ display:inline-block; } + .desk_center { - float: right; - width:68%; + float: left; + width:60%; + padding: 0em 0em 0em 1em; } .course { margin: 0em 0em 2em 0em; background-color: #FFF; - -moz-border-radius: 8px 8px 8px 8px; - -webkit-border-radius: 8px 8px 8px 8px; - border-radius: 8px 8px 8px 8px; - - } + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; + background:no-repeat url(../images/bg_yt.png) 0 0; + background-color:#ebebeb; + background-repeat:repeat + } .course_title { - color:#FFFFFF; - background-image: url(../images/grid_bg_2.png); - -moz-border-radius: 8px 8px 0px 0px; - -webkit-border-radius: 8px 8px 0px 0px; - border-radius: 8px 8px 0px 0px; - padding: 0.3em 0.8em 0.3em 0.8em; + color: #000; + -moz-border-radius: 8px 0px 0px 0px; + -webkit-border-radius: 8px 0px 0px 0px; + border-radius: 8px 0px 0px 0px; + padding: 0em 0.8em 0em 0em; font-weight: bold; font-size: 1.2em; } +.course_content { + /*max-height: 200px; + overflow-y: scroll;*/ + background-color: #FFF; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; + +} + .course_media { background-color: transparent; - background-image: url(../images/grid_bg_2.png); margin: 0em 0em 2em 0em; - -moz-border-radius: 8px 8px 8px 8px; - -webkit-border-radius: 8px 8px 8px 8px; - border-radius: 8px 8px 8px 8px; + -moz-border-radius: 8px 0px 8px 8px; + -webkit-border-radius: 8px 0px 8px 8px; + border-radius: 8px 0px 8px 8px; /* border: 2px solid #CCC; */ } @@ -1352,16 +1369,31 @@ input,textarea{ .video { background-color: transparent; - margin-left: auto; - margin-right: auto; - width: 360px; - padding: 1em 1em 1em 1em; + padding: 0.8em 1em 1em 0em; } .audio { - padding: 1em 1em 1em 1em; + padding: 0.8em 1em 1em 0em; background-color: transparent; - margin-left: auto; - margin-right: auto; - width: 550px; + } + +/* POSTMAN */ + +.pm_header { + font-weight: bold; + } + +.pm_body { + padding: 0em 0em 0em 1em; + } + +#pm_messages td { + font-weight: normal; + font-size: 1em; + } + +#pm_write { + text-align: center; + margin: 0em 0em 3em 0em; +} \ No newline at end of file diff --git a/teleforma/htdocs/images/1pixelout-player-colour-scheme.png b/teleforma/htdocs/images/1pixelout-player-colour-scheme.png new file mode 100755 index 00000000..7f00141e Binary files /dev/null and b/teleforma/htdocs/images/1pixelout-player-colour-scheme.png differ diff --git a/teleforma/htdocs/images/twitter_web_sprite_bgs.png b/teleforma/htdocs/images/twitter_web_sprite_bgs.png new file mode 100644 index 00000000..4ad9e479 Binary files /dev/null and b/teleforma/htdocs/images/twitter_web_sprite_bgs.png differ diff --git a/teleforma/locale/fr/LC_MESSAGES/django.po b/teleforma/locale/fr/LC_MESSAGES/django.po index b6e1d6ee..a60ffd0f 100644 --- a/teleforma/locale/fr/LC_MESSAGES/django.po +++ b/teleforma/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-04-02 17:51+0200\n" +"POT-Creation-Date: 2012-04-04 13:32+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,25 +18,25 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1)\n" -#: models.py:61 models.py:73 models.py:87 models.py:100 models.py:145 -#: models.py:261 models.py:276 models.py:293 models.py:306 models.py:319 +#: models.py:61 models.py:73 models.py:87 models.py:100 models.py:144 +#: models.py:257 models.py:272 models.py:289 models.py:302 models.py:315 msgid "name" msgstr "nom" -#: models.py:62 models.py:74 models.py:88 models.py:101 models.py:115 -#: models.py:146 models.py:203 models.py:262 +#: models.py:62 models.py:74 models.py:88 models.py:101 models.py:114 +#: models.py:145 models.py:202 models.py:258 msgid "description" msgstr "description" -#: models.py:69 models.py:75 models.py:144 +#: models.py:69 models.py:75 models.py:143 msgid "organization" msgstr "organisation" -#: models.py:82 models.py:113 +#: models.py:82 models.py:112 msgid "department" msgstr "département" -#: models.py:95 models.py:116 models.py:333 +#: models.py:95 models.py:115 models.py:329 msgid "category" msgstr "catégorie" @@ -44,173 +44,174 @@ msgstr "catégorie" msgid "categories" msgstr "catégories" -#: models.py:108 models.py:117 -msgid "course type" -msgstr "type de matière" - -#: models.py:109 -msgid "course types" -msgstr "types de matières" +#: models.py:108 +#, fuzzy +msgid "type" +msgstr "type mime" -#: models.py:114 models.py:202 +#: models.py:113 models.py:201 msgid "title" msgstr "titre" -#: models.py:118 models.py:204 models.py:275 models.py:294 models.py:307 -#: models.py:320 +#: models.py:116 +msgid "course type" +msgstr "type de matière" + +#: models.py:117 models.py:203 models.py:271 models.py:290 models.py:303 +#: models.py:316 msgid "code" msgstr "cote" -#: models.py:125 models.py:158 +#: models.py:124 models.py:157 msgid "course" msgstr "matière" -#: models.py:130 models.py:332 models.py:359 +#: models.py:129 models.py:328 models.py:355 msgid "user" msgstr "utilisateur" -#: models.py:131 models.py:277 +#: models.py:130 models.py:273 msgid "courses" msgstr "matières" -#: models.py:139 models.py:159 +#: models.py:138 models.py:158 msgid "professor" msgstr "professeur" -#: models.py:153 models.py:162 +#: models.py:152 models.py:161 msgid "room" msgstr "salle" -#: models.py:160 +#: models.py:159 msgid "session" msgstr "session" -#: models.py:164 +#: models.py:163 msgid "comment" msgstr "" -#: models.py:165 +#: models.py:164 msgid "begin date" msgstr "date de début" -#: models.py:166 +#: models.py:165 msgid "end date" msgstr "date de fin" -#: models.py:179 models.py:206 models.py:240 +#: models.py:178 models.py:205 models.py:236 msgid "conference" msgstr "conférence" -#: models.py:185 +#: models.py:184 msgid "credits" msgstr "crédits" -#: models.py:186 +#: models.py:185 msgid "published" msgstr "publié" -#: models.py:187 +#: models.py:186 msgid "date added" msgstr "date d'ajout" -#: models.py:188 +#: models.py:187 msgid "date modified" msgstr "date de modification" -#: models.py:208 +#: models.py:207 msgid "annal" msgstr "annale" -#: models.py:209 +#: models.py:208 msgid "file" msgstr "fichier" -#: models.py:244 +#: models.py:240 msgid "is live" msgstr "en direct" -#: models.py:269 models.py:270 +#: models.py:265 models.py:266 msgid "IEJ" msgstr "IEJ" -#: models.py:279 +#: models.py:275 msgid "synthesis note" msgstr "" -#: models.py:280 +#: models.py:276 #, fuzzy msgid "obligation" msgstr "organisation" -#: models.py:288 models.py:336 +#: models.py:284 models.py:332 msgid "training" msgstr "formation" -#: models.py:301 models.py:338 +#: models.py:297 models.py:334 msgid "procedure" msgstr "procédure" -#: models.py:314 +#: models.py:310 msgid "speciality" msgstr "spécialité" -#: models.py:327 +#: models.py:323 msgid "oral" msgstr "" -#: models.py:334 +#: models.py:330 msgid "iej" msgstr "iej" -#: models.py:340 +#: models.py:336 msgid "oral speciality" msgstr "spécialité orale" -#: models.py:342 +#: models.py:338 msgid "written speciality" msgstr "spécialité écrit" -#: models.py:344 models.py:346 +#: models.py:340 models.py:342 msgid "oral 1" msgstr "" -#: models.py:353 +#: models.py:349 msgid "student" msgstr "étudiant" -#: models.py:360 +#: models.py:356 msgid "Address" msgstr "" -#: models.py:361 +#: models.py:357 msgid "Postal code" msgstr "Code postal" -#: models.py:362 +#: models.py:358 msgid "City" msgstr "Ville" -#: models.py:363 +#: models.py:359 msgid "Country" msgstr "Pays" -#: models.py:364 +#: models.py:360 msgid "Language" msgstr "Langue" -#: models.py:365 +#: models.py:361 msgid "Telephone" msgstr "Téléphone" -#: models.py:366 +#: models.py:362 msgid "Expiration_date" msgstr "Date d'expiration" -#: models.py:367 +#: models.py:363 msgid "Password initialization" msgstr "" -#: models.py:371 +#: models.py:367 msgid "profile" msgstr "profil" @@ -225,28 +226,28 @@ msgid "" "long term storage." msgstr "" -#: templates/postman/base.html:6 templates/telemeta/base.html:70 +#: templates/postman/base.html:7 templates/telemeta/base.html:71 msgid "Messages" msgstr "Messages" -#: templates/postman/base.html:14 +#: templates/postman/base.html:15 msgid "Inbox" msgstr "" -#: templates/postman/base.html:15 templates/postman/sent.html:3 +#: templates/postman/base.html:16 templates/postman/sent.html:3 #, fuzzy msgid "Sent Messages" msgstr "Messages" -#: templates/postman/base.html:16 templates/postman/write.html:3 +#: templates/postman/base.html:17 templates/postman/write.html:3 msgid "Write" msgstr "" -#: templates/postman/base.html:17 templates/telemeta/base.html:78 +#: templates/postman/base.html:18 templates/telemeta/base.html:79 msgid "Archives" msgstr "" -#: templates/postman/base.html:18 +#: templates/postman/base.html:19 msgid "Trash" msgstr "" @@ -287,11 +288,11 @@ msgstr "" msgid "g:i A,M j,n/j/y" msgstr "" -#: templates/postman/base_folder.html:52 templates/postman/view.html:25 +#: templates/postman/base_folder.html:52 templates/postman/view.html:28 msgid "Delete" msgstr "" -#: templates/postman/base_folder.html:53 templates/postman/view.html:26 +#: templates/postman/base_folder.html:53 templates/postman/view.html:29 msgid "Archive" msgstr "" @@ -344,15 +345,19 @@ msgstr "" msgid "You have received a message from the user '%(sender)s'." msgstr "" -#: templates/postman/email_user.txt:16 templates/postman/email_visitor.txt:14 +#: templates/postman/email_user.txt:17 templates/postman/email_visitor.txt:14 msgid "Thank you again for your interest in our services." msgstr "" -#: templates/postman/email_user.txt:17 templates/postman/email_visitor.txt:16 +#: templates/postman/email_user.txt:18 templates/postman/email_visitor.txt:16 msgid "The site administrator" msgstr "" -#: templates/postman/email_user.txt:19 templates/postman/email_visitor.txt:18 +#: templates/postman/email_user.txt:18 +msgid "of" +msgstr "de" + +#: templates/postman/email_user.txt:20 templates/postman/email_visitor.txt:18 msgid "" "Note: This message is issued by an automated system.\n" "Do not reply, this would not be taken into account." @@ -389,8 +394,8 @@ msgstr "Messages" msgid "Received" msgstr "" -#: templates/postman/reply.html:3 templates/postman/view.html:28 -#: templates/postman/view.html.py:31 templates/postman/view.html:34 +#: templates/postman/reply.html:3 templates/postman/view.html:31 +#: templates/postman/view.html.py:34 templates/postman/view.html:37 msgid "Reply" msgstr "" @@ -409,24 +414,24 @@ msgid "" "storage, use instead the archive folder." msgstr "" -#: templates/postman/view.html:5 +#: templates/postman/view.html:8 msgid "Conversation" msgstr "" -#: templates/postman/view.html:5 +#: templates/postman/view.html:8 #, fuzzy msgid "Message" msgstr "Messages" -#: templates/postman/view.html:14 +#: templates/postman/view.html:17 msgid "Rejected" msgstr "" -#: templates/postman/view.html:14 +#: templates/postman/view.html:17 msgid ":" msgstr "" -#: templates/postman/view.html:23 +#: templates/postman/view.html:26 msgid "Back" msgstr "" @@ -493,78 +498,78 @@ msgstr "" msgid "My courses" msgstr "Mes matières" -#: templates/telemeta/base.html:62 +#: templates/telemeta/base.html:63 msgid "Desk" msgstr "" -#: templates/telemeta/base.html:65 +#: templates/telemeta/base.html:66 msgid "Home" msgstr "" -#: templates/telemeta/base.html:66 +#: templates/telemeta/base.html:67 msgid "Sign in" msgstr "" -#: templates/telemeta/base.html:72 +#: templates/telemeta/base.html:73 msgid "Users" msgstr "" -#: templates/telemeta/base.html:74 +#: templates/telemeta/base.html:75 msgid "Advanced search" msgstr "" -#: templates/telemeta/base.html:80 +#: templates/telemeta/base.html:81 msgid "Fonds" msgstr "" -#: templates/telemeta/base.html:81 +#: templates/telemeta/base.html:82 msgid "Corpus" msgstr "" -#: templates/telemeta/base.html:82 +#: templates/telemeta/base.html:83 msgid "Collections" msgstr "" -#: templates/telemeta/base.html:83 +#: templates/telemeta/base.html:84 msgid "Items" msgstr "" -#: templates/telemeta/base.html:87 +#: templates/telemeta/base.html:88 msgid "Admin" msgstr "" -#: templates/telemeta/base.html:89 -msgid "Generale" +#: templates/telemeta/base.html:90 +msgid "General" msgstr "" -#: templates/telemeta/base.html:101 +#: templates/telemeta/base.html:102 #, fuzzy msgid "Profile" msgstr "profil" -#: templates/telemeta/base.html:102 +#: templates/telemeta/base.html:103 msgid "Help" msgstr "" -#: templates/telemeta/base.html:103 +#: templates/telemeta/base.html:104 msgid "Sign out" msgstr "" -#: templates/telemeta/base.html:143 +#: templates/telemeta/base.html:144 msgid "Powered by" msgstr "" -#: templates/telemeta/base.html:144 +#: templates/telemeta/base.html:145 msgid "By" msgstr "" -#: templates/telemeta/base.html:149 +#: templates/telemeta/base.html:150 msgid "" "Usage of the archives in the respect of cultural heritage of the original " "communities." msgstr "" -#: templates/telemeta/base.html:155 +#: templates/telemeta/base.html:156 msgid "Legal notices" msgstr "" @@ -572,6 +577,9 @@ msgstr "" msgid "Musical selection" msgstr "" +#~ msgid "course types" +#~ msgstr "types de matières" + #~ msgid "Courses" #~ msgstr "Matières" @@ -580,6 +588,3 @@ msgstr "" #~ msgid "written specialities" #~ msgstr "spécialités écrites" - -#~ msgid "mime type" -#~ msgstr "type mime" diff --git a/teleforma/models.py b/teleforma/models.py index a4891ce0..7ca8f2dc 100755 --- a/teleforma/models.py +++ b/teleforma/models.py @@ -105,8 +105,7 @@ class CourseType(Model): class Meta: db_table = app_label + '_' + 'course_type' - verbose_name = _('course type') - verbose_name_plural = _('course types') + verbose_name = _('type') class Course(Model): @@ -118,7 +117,7 @@ class Course(Model): code = CharField(_('code'), max_length=255) def __unicode__(self): - return self.department.name + ' - ' + self.category.name + ' - ' + self.title + return ' - '.join([self.department.name, self.category.name, self.title, self.type.name]) class Meta: db_table = app_label + '_' + 'course' @@ -167,9 +166,9 @@ class Conference(Model): @property def description(self): - return self.course.department.name + ' - ' + self.course.title + ' - ' + \ - self.professor.user.first_name + ' - ' + \ - self.professor.user.last_name + ' - ' + str(self.date_begin) + return ' - '.join([self.course.department.name, self.course.title, self.course.type.name, + self.session, self.professor.user.first_name, self.professor.user.last_name, + str(self.date_begin)]) def __unicode__(self): return self.description @@ -222,10 +221,7 @@ class Document(MediaBase): self.mime_type = mimetypes.guess_type(self.file.path)[0] def __unicode__(self): - if self.title and not re.match('^ *N *$', self.title): - return self.title - else: - return unicode(self.title) + return ' - '.join([self.title, unicode(self.course)]) class Meta: db_table = app_label + '_' + 'document' diff --git a/teleforma/templates/postman/base.html b/teleforma/templates/postman/base.html index 5213340e..2019a9d5 100644 --- a/teleforma/templates/postman/base.html +++ b/teleforma/templates/postman/base.html @@ -1,20 +1,29 @@ -{% extends "telemeta/base.html" %} -{% load i18n %}{% load postman_tags %} +{% extends "teleforma/base.html" %} +{% load i18n %} +{% load postman_tags %} -{% block title %} -item -{% trans "Messages"%} -{% endblock %} +{% block postman_menu %} +
+ + + + +{% endblock postman_menu %} \ No newline at end of file diff --git a/teleforma/templates/postman/base_folder.html b/teleforma/templates/postman/base_folder.html index b481c1eb..4597105d 100644 --- a/teleforma/templates/postman/base_folder.html +++ b/teleforma/templates/postman/base_folder.html @@ -3,7 +3,7 @@ {% block content %} -
+

{% block pm_folder_title %}{% endblock %}

{% autopaginate pm_messages %} {% if invalid_page %} diff --git a/teleforma/templates/postman/base_write.html b/teleforma/templates/postman/base_write.html index d454e9e1..f89d5749 100644 --- a/teleforma/templates/postman/base_write.html +++ b/teleforma/templates/postman/base_write.html @@ -10,7 +10,7 @@ {% endif %} {% endblock %} {% block content %} -
+

{% block pm_write_title %}{% endblock %}

{% csrf_token %}
diff --git a/teleforma/templates/postman/email_user.txt b/teleforma/templates/postman/email_user.txt index c62111bb..c9da23b0 100644 --- a/teleforma/templates/postman/email_user.txt +++ b/teleforma/templates/postman/email_user.txt @@ -1,4 +1,4 @@ -{% load i18n %}{% autoescape off %}{% trans "Dear user," %} +{% load i18n %}{% load telemeta_utils %}{% load teleforma_tags %}{% autoescape off %}{% trans "Dear user," %} {% if action == 'rejection' %} {% blocktrans with object.sent_at|date:"DATETIME_FORMAT" as date and object.obfuscated_recipient as recipient %}On {{ date }}, you asked to send a message to the user '{{ recipient }}'.{% endblocktrans %} @@ -11,10 +11,11 @@ {% else %}{% blocktrans with object.obfuscated_sender as sender %}You have received a copy of a response from the user '{{ sender }}'.{% endblocktrans %} {% endif %} {% else %}{% blocktrans with object.obfuscated_sender as sender %}You have received a message from the user '{{ sender }}'.{% endblocktrans %} -{% endif %} -{% endif %}{# 'acceptance' #} +{% endif %}{% endif %}{# 'acceptance' #}{% trans "You can read and respond to this message from your online desk" %}: +http://{{ site.name }}/messages/inbox/ + {% trans "Thank you again for your interest in our services." %} -{% trans "The site administrator" %} +{% trans "The site administrator" %} {% trans "of" %} {% organization %} {% blocktrans %}Note: This message is issued by an automated system. Do not reply, this would not be taken into account.{% endblocktrans %}{% endautoescape %} \ No newline at end of file diff --git a/teleforma/templates/postman/view.html b/teleforma/templates/postman/view.html index 23c7264c..d7fb2321 100644 --- a/teleforma/templates/postman/view.html +++ b/teleforma/templates/postman/view.html @@ -1,5 +1,8 @@ {% extends "postman/base.html" %} -{% load i18n %}{% load postman_tags %} +{% load i18n %} +{% load teleforma_tags %} +{% load postman_tags %} + {% block content %}

{% if pm_messages|length > 1 %}{% trans "Conversation" %}{% else %}{% trans "Message" %}{% endif %}

diff --git a/teleforma/templates/teleforma/course_media.html b/teleforma/templates/teleforma/course_media.html new file mode 100644 index 00000000..2ff34b49 --- /dev/null +++ b/teleforma/templates/teleforma/course_media.html @@ -0,0 +1,59 @@ +{% extends "teleforma/course_detail.html" %} +{% load telemeta_utils %} +{% load i18n %} + + +{% block extra_javascript %} +{% if "video" in mime_type %} + + +{% endif %} +{% endblock extra_javascript %} + +{% block course %} + +
+ +
{{ course.title }}{% if course.description %} - {{ course.description }}{% endif %} +
+ +
+ +{% if "video" in mime_type %} +
+ +
+ + +{% elif "audio" in mime_type %} + +
+ +
+ +{% endif %} + +
+ +
+ +{% block general_info %} +
+{% dl_field item "title" placeholder %} +
{% field_label item "collection" %}
+
{{ item.collection }}
+
{% trans "Recording date" %}
+ +
{% if item.recorded_from_date %}{{ item.recorded_from_date }}{% endif %}{% if item.recorded_from_date and item.recorded_to_date%} - {% endif %}{% if item.recorded_to_date %}{{ item.recorded_to_date}}{% endif %}
+ +
+{% endblock general_info %} + +
+ + +
+{% endblock course %} diff --git a/teleforma/templates/teleforma/courses.html b/teleforma/templates/teleforma/courses.html index 0673747c..59abe8cc 100644 --- a/teleforma/templates/teleforma/courses.html +++ b/teleforma/templates/teleforma/courses.html @@ -6,19 +6,8 @@ {% block content %} -
- {% block module_all_revisions %} - {% with revisions as revisions and "All last changes" as title %} - {% include "telemeta/inc/module_revisions.html" %} - {% endwith %} - {% endblock %} -
-

playlists {% trans "Bureau" %}

-
- -

playlists{% trans "My courses" %}

@@ -60,6 +49,7 @@ {% include "teleforma/inc/conference_list.html" %} {% endwith %} {% endblock %} +
{% endfor %} diff --git a/teleforma/templates/teleforma/inc/conference_list.html b/teleforma/templates/teleforma/inc/conference_list.html index 74963237..5af6bbe1 100644 --- a/teleforma/templates/teleforma/inc/conference_list.html +++ b/teleforma/templates/teleforma/inc/conference_list.html @@ -1,5 +1,6 @@ {% load i18n %} +

{% trans "Conferences"%}

@@ -19,3 +20,4 @@ {% endfor %}
+ \ No newline at end of file diff --git a/teleforma/templates/teleforma/inc/document_list.html b/teleforma/templates/teleforma/inc/document_list.html index 5c72ccd1..f5d010d8 100644 --- a/teleforma/templates/teleforma/inc/document_list.html +++ b/teleforma/templates/teleforma/inc/document_list.html @@ -1,5 +1,6 @@ {% load i18n %} +

{% trans "Documents"%}

@@ -12,10 +13,11 @@ {% for document in course.document.all %} - + {% endfor %}
{{ document.title }}{{ document.title }} {{ document.description }} {{ document.date_added }}
+
\ No newline at end of file diff --git a/teleforma/templates/teleforma/inc/media_list.html b/teleforma/templates/teleforma/inc/media_list.html index 92c59582..7c55cd78 100644 --- a/teleforma/templates/teleforma/inc/media_list.html +++ b/teleforma/templates/teleforma/inc/media_list.html @@ -1,6 +1,6 @@ {% load i18n %} - +

{% trans "Medias"%}

@@ -20,3 +20,4 @@ {% endfor %}
+
\ No newline at end of file diff --git a/teleforma/templates/telemeta/base.html b/teleforma/templates/telemeta/base.html index bd40dbf4..931af9f3 100644 --- a/teleforma/templates/telemeta/base.html +++ b/teleforma/templates/telemeta/base.html @@ -1,6 +1,7 @@ - + {% load i18n %} {% load telemeta_utils %} + {% get_current_language as LANGUAGE_CODE %} {% get_available_languages as LANGUAGES %} @@ -63,11 +64,11 @@ alt="Telemeta Powered"/>--> {% else %}
  • {% trans "Home" %}
  • -
  • {% trans "Sign in" %}
  • +
  • {% trans "Sign in" %}
  • {% endif %} {% if user.is_authenticated %} -
  • {% trans "Messages" %}
  • +
  • {% trans "Messages" %}{% if postman_unread_count %} ({{ postman_unread_count }}){% endif %}
  • {% trans "Users" %}
  • @@ -86,7 +87,7 @@ alt="Telemeta Powered"/>-->
  • {% trans "Admin" %}
  • {% endif %} @@ -115,14 +116,15 @@ alt="Telemeta Powered"/>--> {% endblock header %} -{% block postman_menu %} -{% endblock postman_menu %} -

    {% block title %}{% endblock %}

    {% block title_buttons %}{% endblock %}
    + +{% block postman_menu %} +{% endblock postman_menu %} + {% block content %}{% endblock %}
    {% block delete %}{% endblock %} diff --git a/teleforma/templates/telemeta/inc/user_list.html b/teleforma/templates/telemeta/inc/user_list.html new file mode 100644 index 00000000..db336020 --- /dev/null +++ b/teleforma/templates/telemeta/inc/user_list.html @@ -0,0 +1,24 @@ +{% load i18n %} +{% load telemeta_utils %} +{% load teleforma_tags %} + + + + + + + + + + + {% for user in users %} + + + + + + + + {% endfor %} + +
    {% trans "User"%}{% trans "First Name"%}{% trans "Last Name"%}{% trans "Messages"%}{% trans "Training"%}
    {{user.username}}{{ user.first_name }}{{ user.last_name }}Write{% for training in user__student.training %}{{ training }} {% endfor %}
    \ No newline at end of file diff --git a/teleforma/templatetags/__init__.py b/teleforma/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/teleforma/templatetags/teleforma_tags.py b/teleforma/templatetags/teleforma_tags.py new file mode 100644 index 00000000..322d8c7c --- /dev/null +++ b/teleforma/templatetags/teleforma_tags.py @@ -0,0 +1,51 @@ + +from django import template +from django.utils.http import urlquote +from teleforma.models import * +from django.core.urlresolvers import reverse +from django.utils import html +from django import template +from django.utils.text import capfirst +from django.utils.translation import ungettext +from docutils.core import publish_parts +from django.utils.encoding import smart_str, force_unicode +from django.utils.safestring import mark_safe +from django import db +import re +import os +import datetime +from django.conf import settings +from django.template.defaultfilters import stringfilter + +register = template.Library() + +@register.filter +def parse_urls(text): + output = '' + for block in text.split(' '): + if 'http://' in block: + output += '' + block + '' + else: + output += block + return output + + +@register.tag +def value_from_settings(parser, token): + try: + # split_contents() knows not to split quoted strings. + tag_name, var = token.split_contents() + except ValueError: + raise template.TemplateSyntaxError, "%r tag requires a single argument" % token.contents.split()[0] + return ValueFromSettings(var) + +class ValueFromSettings(template.Node): + def __init__(self, var): + self.arg = template.Variable(var) + def render(self, context): + return settings.__getattr__(str(self.arg)) + +@register.simple_tag +def trainings(user): + student = user.student.get() + return training.student.all() diff --git a/teleforma/urls.py b/teleforma/urls.py index 4b5418df..8094631a 100644 --- a/teleforma/urls.py +++ b/teleforma/urls.py @@ -47,6 +47,8 @@ urlpatterns = patterns('', url(r'^desk/courses/$', CoursesView.as_view(), name="teleforma-courses"), url(r'^desk/courses/(?P.*)$', CourseView.as_view(), name="teleforma-course-detail"), url(r'^desk/medias/(?P.*)$', MediaView.as_view(), name="teleforma-media-detail"), + url(r'^desk/documents/(?P.*)/download/', document_download, name="teleforma-document-download"), + url(r'^desk/documents/(?P.*)/view/', document_view, name="teleforma-document-view"), # CSS+Images (FIXME: for developement only) url(r'^teleforma/css/(?P.*)$', 'django.views.static.serve', diff --git a/teleforma/views.py b/teleforma/views.py index f0413890..eb0c2f97 100755 --- a/teleforma/views.py +++ b/teleforma/views.py @@ -1,5 +1,7 @@ # Create your views here. +import mimetypes + from jsonrpc import jsonrpc_method from django.utils.decorators import method_decorator @@ -32,6 +34,47 @@ def render(request, template, data = None, mimetype = None): return render_to_response(template, data, context_instance=RequestContext(request), mimetype=mimetype) +def get_courses(user): + professor = user.professor.all() + student = user.student.all() + if professor: + courses = user.professor.get().courses.all() + elif student: + courses = user.student.get().training.courses.all() + elif user.is_staff: + courses = Course.objects.all() + else: + courses = None + return courses + +def stream_from_file(__file): + chunk_size = 0x10000 + f = open(__file, 'r') + while True: + __chunk = f.read(chunk_size) + if not len(__chunk): + f.close() + break + yield __chunk + +def document_download(request, pk): + document = Document.objects.get(id=pk) + fsock = open(document.file.path, 'r') + mimetype = mimetypes.guess_type(document.file.path)[0] + extension = mimetypes.guess_extension(mimetype) + response = HttpResponse(fsock, mimetype=mimetype) + response['Content-Disposition'] = "attachment; filename=%s%s" % \ + (unicode(document), extension) + return response + +def document_view(request, pk): + document = Document.objects.get(id=pk) + fsock = open(document.file.path, 'r') + mimetype = mimetypes.guess_type(document.file.path)[0] + extension = mimetypes.guess_extension(mimetype) + response = HttpResponse(fsock, mimetype=mimetype) + return response + class CourseView(DetailView): @@ -39,7 +82,7 @@ class CourseView(DetailView): def get_context_data(self, **kwargs): context = super(CourseView, self).get_context_data(**kwargs) - context['courses'] = Course.objects.all() + context['courses'] = get_courses(self.request.user) return context class CoursesView(ListView): @@ -49,7 +92,7 @@ class CoursesView(ListView): def get_context_data(self, **kwargs): context = super(CoursesView, self).get_context_data(**kwargs) - context['courses'] = Course.objects.all() + context['object_list'] = get_courses(self.request.user) return context class MediaView(DetailView): @@ -59,10 +102,13 @@ class MediaView(DetailView): def get_context_data(self, **kwargs): context = super(MediaView, self).get_context_data(**kwargs) - context['courses'] = Course.objects.all() + context['courses'] = get_courses(self.request.user) media = self.get_object() view = ItemView() + print media.item.file + print view.item_analyze(media.item) context['mime_type'] = view.item_analyze(media.item) context['course'] = media.course context['item'] = media.item return context +