Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit 1b5bc1b

Browse files
author
Ptitloup
committed
Merge pull request #51 from SemmLille/dev
1.3
2 parents b1cb7af + cdc7ecd commit 1b5bc1b

File tree

82 files changed

+6276
-3353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+6276
-3353
lines changed

pod_project/core/admin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from ckeditor.widgets import CKEditorWidget
2727
from django.contrib.auth.admin import UserAdmin
2828
from django.contrib.auth.models import User
29-
from core.models import UserProfile, PagesMenuBas, EncodingType
29+
from core.models import UserProfile, PagesMenuBas, EncodingType, ContactUs
3030

3131

3232
class PageForm(FlatpageForm):
@@ -77,3 +77,7 @@ class EncodingTypeAdmin(admin.ModelAdmin):
7777
list_display = (
7878
'name', 'bitrate_audio', 'bitrate_video', 'output_height', 'mediatype')
7979
admin.site.register(EncodingType, EncodingTypeAdmin)
80+
81+
class ContactUsAdmin(admin.ModelAdmin):
82+
list_display = ('id', 'name', 'email', 'subject', 'message')
83+
admin.site.register(ContactUs, ContactUsAdmin)

pod_project/core/forms.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@
2020
voir http://www.gnu.org/licenses/
2121
"""
2222

23-
from django.forms import ModelForm
24-
from core.models import FileBrowse, UserProfile
23+
from django.forms import ModelForm, URLField
24+
from core.models import FileBrowse, UserProfile, ContactUs
25+
from captcha.fields import CaptchaField
26+
from django.utils.safestring import mark_safe
27+
from django.forms.widgets import HiddenInput
28+
from django.utils.translation import ugettext_lazy as _
2529

2630
class FileBrowseForm(ModelForm):
2731
class Meta:
2832
model = FileBrowse
2933
fields = '__all__'
3034

3135
class ProfileForm(ModelForm):
36+
3237
def __init__(self, *args, **kwargs):
3338
super(ProfileForm, self).__init__(*args, **kwargs)
3439
try :
@@ -45,4 +50,27 @@ def __init__(self, *args, **kwargs):
4550

4651
class Meta:
4752
model = UserProfile
48-
exclude = ('user','auth_type', 'commentaire', 'affiliation' )
53+
exclude = ('user','auth_type', 'commentaire', 'affiliation' )
54+
55+
class ContactUsModelForm(ModelForm):
56+
captcha = CaptchaField(label=_(u'Please indicate the result of the following operation hereunder '))
57+
url_referrer = URLField(required=False, widget=HiddenInput())
58+
def __init__(self, request, *args, **kwargs):
59+
super(ContactUsModelForm, self).__init__(*args, **kwargs)
60+
61+
if request.user and request.user.is_authenticated():
62+
self.fields['name'].widget = HiddenInput()
63+
self.fields['email'].widget = HiddenInput()
64+
del self.fields['captcha']
65+
66+
for myField in self.fields:
67+
if self.fields[myField].label != None:
68+
self.fields[myField].widget.attrs['placeholder'] = self.fields[myField].label
69+
if self.fields[myField].required:
70+
self.fields[myField].widget.attrs['class'] = 'required'
71+
label_unicode = u'%s' %self.fields[myField].label
72+
self.fields[myField].label = mark_safe("%s <span class=\"special_class\">*</span> : " %label_unicode)
73+
74+
class Meta:
75+
model = ContactUs
76+
fields = '__all__'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import models, migrations
5+
import filer.fields.image
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('core', '0001_initial'),
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='ContactUs',
17+
fields=[
18+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
19+
('name', models.CharField(max_length=250, verbose_name='Name')),
20+
('email', models.EmailField(max_length=250, verbose_name='Email')),
21+
('subject', models.CharField(max_length=250, verbose_name='Subject')),
22+
('message', models.TextField(verbose_name='Message')),
23+
],
24+
options={
25+
'verbose_name': 'Contact',
26+
'verbose_name_plural': 'Contacts',
27+
},
28+
bases=(models.Model,),
29+
),
30+
migrations.AlterModelOptions(
31+
name='encodingtype',
32+
options={'verbose_name': 'encoding type', 'verbose_name_plural': 'encoding types'},
33+
),
34+
migrations.AlterField(
35+
model_name='userprofile',
36+
name='description',
37+
field=models.TextField(help_text='This field allows you to write a few words about yourself. The text will be displayed with your videos.', max_length=100, verbose_name='Description', blank=True),
38+
preserve_default=True,
39+
),
40+
migrations.AlterField(
41+
model_name='userprofile',
42+
name='image',
43+
field=filer.fields.image.FilerImageField(blank=True, to='filer.Image', help_text='This field allows you to add a photo ID. The picture will be displayed with your videos.', null=True, verbose_name='Avatar'),
44+
preserve_default=True,
45+
),
46+
]

pod_project/core/models.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
de la licence GNU Public Licence telle que publiée
77
par la Free Software Foundation, soit dans la
88
version 3 de la licence, ou (selon votre choix)
9-
toute version ultérieure.
9+
toute version ultérieure.
1010
Ce programme est distribué avec l'espoir
1111
qu'il sera utile, mais SANS AUCUNE
1212
GARANTIE : sans même les garanties
@@ -84,9 +84,9 @@ def __str__(self):
8484
class UserProfile(models.Model):
8585
user = models.OneToOneField(User)
8686
image = FilerImageField(null=True, blank=True, verbose_name=_('Avatar'),
87-
help_text=_('This field allows you to add a photo ID. The picture will be displayed with yours videos.'))
87+
help_text=_('This field allows you to add a photo ID. The picture will be displayed with your videos.'))
8888
description = models.TextField(_('Description'), max_length=100, blank=True,
89-
help_text=_('This field allows you to write a few words about yourself. The text will be displayed with yours videos.'))
89+
help_text=_('This field allows you to write a few words about yourself. The text will be displayed with your videos.'))
9090
url = models.URLField(_('Web link'), blank=True,
9191
help_text=_('This field allows you to add an url.'))
9292

@@ -114,8 +114,8 @@ def create_user_profile(sender, instance, created, **kwargs):
114114
# creation du profil
115115
try:
116116
UserProfile.objects.create(user=instance)
117-
except Exception as e:
118-
msg = u'\n Create user profile ***** Unexpected error :%r' % e
117+
except Exception as e:
118+
msg = u'\n Create user profile ***** Error:%r' % e
119119
msg += '\n%s' % traceback.format_exc()
120120
logger.error(msg)
121121
print msg
@@ -125,8 +125,8 @@ def create_user_profile(sender, instance, created, **kwargs):
125125
if not instance.groups.filter(name='can delete file').exists():
126126
g = Group.objects.get(name='can delete file')
127127
g.user_set.add(instance)
128-
except Exception as e:
129-
msg = u'\n Create folder and add group to user ***** Unexpected error :%r' % e
128+
except Exception as e:
129+
msg = u'\n Create folder and add group to user ***** Error:%r' % e
130130
msg += '\n%s' % traceback.format_exc()
131131
logger.error(msg)
132132
print msg
@@ -162,9 +162,11 @@ class Video(models.Model):
162162
description = RichTextField(
163163
_('Description'), config_name='complete', blank=True)
164164

165-
view_count = models.PositiveIntegerField(default=0, editable=False)
165+
view_count = models.PositiveIntegerField(
166+
_('View count'), default=0, editable=False)
166167

167-
encoding_in_progress = models.BooleanField(default=False, editable=False)
168+
encoding_in_progress = models.BooleanField(
169+
_('Encoding in progress'), default=False, editable=False)
168170
encoding_status = models.CharField(
169171
_('Encoding status'), max_length=250, editable=False, blank=True, null=True)
170172

@@ -242,8 +244,29 @@ class EncodingType(models.Model):
242244
mediatype = models.CharField(
243245
_('mediatype'), max_length=5, choices=TYPE_CHOICES, default="video")
244246

247+
class Meta:
248+
verbose_name = _("encoding type")
249+
verbose_name_plural = _("encoding types")
250+
245251
def __str__(self):
246252
return "%s %s %s" % (self.mediatype, self.name, self.output_height)
247253

248254
def __unicode__(self):
249255
return "%s %s %s" % (self.mediatype, self.name, self.output_height)
256+
257+
@python_2_unicode_compatible
258+
class ContactUs(models.Model):
259+
name = models.CharField(_('Name'), max_length=250)
260+
email = models.EmailField(_('Email'), max_length=250)
261+
subject = models.CharField(_('Subject'), max_length=250)
262+
message = models.TextField(_('Message'))
263+
264+
class Meta:
265+
verbose_name = _("Contact")
266+
verbose_name_plural = _("Contacts")
267+
268+
def __str__(self):
269+
return "%s %s %s" % (self.name, self.email, self.subject)
270+
271+
def __unicode__(self):
272+
return "%s %s %s" % (self.name, self.email, self.subject)

pod_project/core/static/JS/navigation.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,22 @@ $(document).ready(function() {
158158

159159
});
160160

161+
/*** DON'T TOUCH THIS ****/
162+
function csrfSafeMethod(method) {
163+
// These HTTP methods do not require CSRF protection
164+
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
165+
}
166+
167+
$.ajaxSetup({
168+
crossDomain: false, // Obviates need for sameOrigin test
169+
beforeSend: function(xhr, settings) {
170+
if (!csrfSafeMethod(settings.type)) {
171+
xhr.setRequestHeader('X-CSRFToken', csrftoken);
172+
}
173+
}
174+
});
175+
var csrftoken = getCookie('csrftoken');
176+
161177
/** EVTS PERMANENT **/
162178
/** video list **/
163179
$(document).on('click', "#pagination .paginator a", function () {

pod_project/core/static/JS/player.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -379,21 +379,6 @@ function changeDisplay(disp, duration) {
379379
}
380380
}
381381

382-
function csrfSafeMethod(method) {
383-
// These HTTP methods do not require CSRF protection
384-
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
385-
}
386-
387-
$.ajaxSetup({
388-
crossDomain: false, // Obviates need for sameOrigin test
389-
beforeSend: function(xhr, settings) {
390-
if (!csrfSafeMethod(settings.type)) {
391-
xhr.setRequestHeader('X-CSRFToken', csrftoken);
392-
}
393-
}
394-
});
395-
var csrftoken = getCookie('csrftoken');
396-
397382
$(document).on(
398383
'click',
399384
'button#button_video_note',

pod_project/core/templates/404.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
de la licence GNU Public Licence telle que publiée
77
par la Free Software Foundation, soit dans la
88
version 3 de la licence, ou (selon votre choix)
9-
toute version ultérieure.
9+
toute version ultérieure.
1010
Ce programme est distribué avec l'espoir
1111
qu'il sera utile, mais SANS AUCUNE
1212
GARANTIE : sans même les garanties
@@ -21,7 +21,7 @@
2121
{%endcomment%}
2222
{% load i18n %}
2323

24-
{% block bootstrap3_title %}{{ block.super }}{% trans "Page not found" %}{% endblock %}
24+
{% block bootstrap3_title %}{{ block.super }}{% trans "Page not found." %}{% endblock %}
2525

2626
{% block bootstrap3_extra_head %}
2727
<style>
@@ -31,7 +31,7 @@
3131

3232

3333
{% block breadcrumbs %}
34-
{{ block.super }} <li class="active">{% trans "Page not found" %}</li>
34+
{{ block.super }} <li class="active">{% trans "Page not found." %}</li>
3535
{%endblock%}
3636

3737
{% block mainToolbar %}
@@ -41,13 +41,13 @@
4141
{% endblock stats %}
4242

4343
{% block article_title %}
44-
{% trans "Page not found" %}&nbsp;&nbsp;<span frown>:(</span>
44+
{% trans "Page not found." %}&nbsp;&nbsp;<span frown>:(</span>
4545
{% endblock %}
4646

4747
{% block article %}
4848
{% block article_content %}
4949
<div>
50-
<p>{% trans "The requested address was not found on this server" %}</p>
50+
<p>{% trans "The requested address was not found on this server." %}</p>
5151
<p><a href="/" id="home">[ {% trans "Home" %} ]</a></p>
5252
</div>
5353
{% endblock article_content %}
@@ -60,7 +60,7 @@
6060
<aside class="col-sm-3">
6161
{% block box_info %}
6262
{% endblock box_info %}
63-
63+
6464
{% block box_discipline %}{{ block.super }}{% endblock box_discipline %}
6565
{% block box_tags %}{{ block.super }}{% endblock box_tags %}
6666
{% block box_note %} {% endblock box_note %}

0 commit comments

Comments
 (0)