diff --git a/accounting/templates/accounting/journal_details.jinja b/accounting/templates/accounting/journal_details.jinja
index aa203eaa..aa3d1f19 100644
--- a/accounting/templates/accounting/journal_details.jinja
+++ b/accounting/templates/accounting/journal_details.jinja
@@ -53,7 +53,7 @@
{% endif %}
{{ o.remark }} |
{% if o.invoice %}
- {{ o.invoice.name }} |
+ {{ o.invoice.name }} |
{% else %}
- |
{% endif %}
diff --git a/accounting/views.py b/accounting/views.py
index 149bd861..8a80992e 100644
--- a/accounting/views.py
+++ b/accounting/views.py
@@ -4,10 +4,9 @@ from django.shortcuts import render
from django.core.urlresolvers import reverse_lazy
from django.forms.models import modelform_factory
from django.forms import HiddenInput
-from django.forms.extras.widgets import SelectDateWidget
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin
-from core.views.forms import SelectFile
+from core.views.forms import SelectFile, SelectDate
from accounting.models import BankAccount, ClubAccount, GeneralJournal, Operation, AccountingType, Company
# Accounting types
@@ -168,7 +167,7 @@ class OperationCreateView(CanCreateMixin, CreateView):
form_class = modelform_factory(Operation,
fields=['amount', 'label', 'remark', 'journal', 'target_type', 'target_id', 'target_label', 'date', 'mode',
'cheque_number', 'invoice', 'accounting_type', 'done'],
- widgets={'journal': HiddenInput, 'date': SelectDateWidget})
+ widgets={'journal': HiddenInput, 'date': SelectDate})
template_name = 'core/create.jinja'
def get_initial(self):
@@ -188,7 +187,7 @@ class OperationEditView(CanEditMixin, UpdateView):
form_class = modelform_factory(Operation,
fields = ['amount', 'label', 'remark', 'target_type', 'target_id', 'target_label', 'date', 'mode', 'cheque_number',
'invoice', 'accounting_type', 'done'],
- widgets={'date': SelectDateWidget, 'invoice': SelectFile})
+ widgets={'date': SelectDate, 'invoice': SelectFile})
template_name = 'core/edit.jinja'
# Company views
diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py
index bccdc451..e82f56b2 100644
--- a/core/management/commands/populate.py
+++ b/core/management/commands/populate.py
@@ -38,6 +38,7 @@ class Command(BaseCommand):
is_superuser=True, is_staff=True)
root.set_password("plop")
root.save()
+ SithFile(parent=None, name="profiles", is_folder=True, owner=root).save()
home_root = SithFile(parent=None, name="users", is_folder=True, owner=root)
home_root.save()
club_root = SithFile(parent=None, name="clubs", is_folder=True, owner=root)
diff --git a/core/migrations/0003_auto_20160810_1949.py b/core/migrations/0003_auto_20160810_1949.py
new file mode 100644
index 00000000..10c42712
--- /dev/null
+++ b/core/migrations/0003_auto_20160810_1949.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('core', '0002_user_home'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='user',
+ name='avatar_pict',
+ field=models.OneToOneField(related_name='avatar_of', verbose_name='avatar', to='core.SithFile', null=True, blank=True),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='profile_pict',
+ field=models.OneToOneField(related_name='profile_of', verbose_name='profile', to='core.SithFile', null=True, blank=True),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='scrub_pict',
+ field=models.OneToOneField(related_name='scrub_of', verbose_name='scrub', to='core.SithFile', null=True, blank=True),
+ ),
+ ]
diff --git a/core/migrations/0004_auto_20160811_0206.py b/core/migrations/0004_auto_20160811_0206.py
new file mode 100644
index 00000000..a0646a2f
--- /dev/null
+++ b/core/migrations/0004_auto_20160811_0206.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('core', '0003_auto_20160810_1949'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='user',
+ name='nick_name',
+ field=models.CharField(verbose_name='nick name', max_length=30, blank=True),
+ ),
+ ]
diff --git a/core/migrations/0005_auto_20160811_0319.py b/core/migrations/0005_auto_20160811_0319.py
new file mode 100644
index 00000000..13c5bab3
--- /dev/null
+++ b/core/migrations/0005_auto_20160811_0319.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import core.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('core', '0004_auto_20160811_0206'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='user',
+ name='department',
+ field=models.CharField(max_length=15, choices=[('TC', 'TC'), ('IMSI', 'IMSI'), ('IMAP', 'IMAP'), ('INFO', 'INFO'), ('GI', 'GI'), ('E', 'E'), ('EE', 'EE'), ('GESC', 'GESC'), ('GMC', 'GMC'), ('MC', 'MC'), ('EDIM', 'EDIM'), ('HUMAN', 'Humanities'), ('NA', 'N/A')], default='NA', verbose_name='department'),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='dpt_option',
+ field=models.CharField(max_length=32, default='', verbose_name='dpt option'),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='forum_signature',
+ field=models.TextField(max_length=256, default='', verbose_name='forum signature'),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='promo',
+ field=models.IntegerField(blank=True, null=True, validators=[core.models.validate_promo], verbose_name='promo'),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='quote',
+ field=models.CharField(max_length=64, default='', verbose_name='quote'),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='role',
+ field=models.CharField(max_length=15, choices=[('STUDENT', 'Student'), ('ADMINISTRATIVE', 'Administrative agent'), ('TEACHER', 'Teacher'), ('AGENT', 'Agent'), ('DOCTOR', 'Doctor'), ('FORMER STUDENT', 'Former student'), ('SERVICE', 'Service')], default='STUDENT', verbose_name='role'),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='school',
+ field=models.CharField(max_length=32, default='', verbose_name='school'),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='semester',
+ field=models.CharField(max_length=5, default='', verbose_name='semester'),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='sex',
+ field=models.CharField(max_length=10, choices=[('MAN', 'Man'), ('WOMAN', 'Woman')], default='MAN', verbose_name='sex'),
+ ),
+ migrations.AddField(
+ model_name='user',
+ name='tshirt_size',
+ field=models.CharField(max_length=5, choices=[('-', '-'), ('XS', 'XS'), ('S', 'S'), ('M', 'M'), ('L', 'L'), ('XL', 'XL'), ('XXL', 'XXL'), ('XXXL', 'XXXL')], default='M', verbose_name='tshirt size'),
+ ),
+ ]
diff --git a/core/models.py b/core/models.py
index ad414f78..554ba3fd 100644
--- a/core/models.py
+++ b/core/models.py
@@ -7,7 +7,7 @@ from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.conf import settings
from django.db import transaction
-from datetime import datetime, timedelta
+from datetime import datetime, timedelta, date
import unicodedata
@@ -46,6 +46,15 @@ class RealGroup(Group):
class Meta:
proxy = True
+def validate_promo(value):
+ start_year = settings.SITH_SCHOOL_START_YEAR
+ delta = (date.today()+timedelta(days=180)).year - start_year
+ if value < 0 or delta < value:
+ raise ValidationError(
+ _('%(value)s is not a valid promo (between 0 and %(end)s)'),
+ params={'value': value, 'end': delta},
+ )
+
class User(AbstractBaseUser):
"""
Defines the base user class, useable in every app
@@ -77,7 +86,7 @@ class User(AbstractBaseUser):
last_name = models.CharField(_('last name'), max_length=30)
email = models.EmailField(_('email address'), unique=True)
date_of_birth = models.DateField(_('date of birth'), blank=True, null=True)
- nick_name = models.CharField(max_length=30, blank=True)
+ nick_name = models.CharField(_('nick name'), max_length=30, blank=True)
is_staff = models.BooleanField(
_('staff status'),
default=False,
@@ -101,6 +110,51 @@ class User(AbstractBaseUser):
)
groups = models.ManyToManyField(RealGroup, related_name='users', blank=True)
home = models.OneToOneField('SithFile', related_name='home_of', verbose_name=_("home"), null=True, blank=True)
+ profile_pict = models.OneToOneField('SithFile', related_name='profile_of', verbose_name=_("profile"), null=True, blank=True)
+ avatar_pict = models.OneToOneField('SithFile', related_name='avatar_of', verbose_name=_("avatar"), null=True, blank=True)
+ scrub_pict = models.OneToOneField('SithFile', related_name='scrub_of', verbose_name=_("scrub"), null=True, blank=True)
+ sex = models.CharField(_("sex"), max_length=10, choices=[("MAN", _("Man")), ("WOMAN", _("Woman"))], default="MAN")
+ tshirt_size = models.CharField(_("tshirt size"), max_length=5, choices=[
+ ("-", _("-")),
+ ("XS", _("XS")),
+ ("S", _("S")),
+ ("M", _("M")),
+ ("L", _("L")),
+ ("XL", _("XL")),
+ ("XXL", _("XXL")),
+ ("XXXL", _("XXXL")),
+ ], default="M")
+ role = models.CharField(_("role"), max_length=15, choices=[
+ ("STUDENT", _("Student")),
+ ("ADMINISTRATIVE", _("Administrative agent")),
+ ("TEACHER", _("Teacher")),
+ ("AGENT", _("Agent")),
+ ("DOCTOR", _("Doctor")),
+ ("FORMER STUDENT", _("Former student")),
+ ("SERVICE", _("Service")),
+ ], default="STUDENT")
+ department = models.CharField(_("department"), max_length=15, choices=[
+ ("TC", _("TC")),
+ ("IMSI", _("IMSI")),
+ ("IMAP", _("IMAP")),
+ ("INFO", _("INFO")),
+ ("GI", _("GI")),
+ ("E", _("E")),
+ ("EE", _("EE")),
+ ("GESC", _("GESC")),
+ ("GMC", _("GMC")),
+ ("MC", _("MC")),
+ ("EDIM", _("EDIM")),
+ ("HUMAN", _("Humanities")),
+ ("NA", _("N/A")),
+ ], default="NA")
+ dpt_option = models.CharField(_("dpt option"), max_length=32, default="")
+ semester = models.CharField(_("semester"), max_length=5, default="")
+ quote = models.CharField(_("quote"), max_length=64, default="")
+ school = models.CharField(_("school"), max_length=32, default="")
+ promo = models.IntegerField(_("promo"), validators=[validate_promo], null=True, blank=True)
+ forum_signature = models.TextField(_("forum signature"), max_length=256, default="")
+ # TODO: add phone numbers with https://github.com/stefanfoulis/django-phonenumber-field
objects = UserManager()
@@ -341,6 +395,15 @@ class SithFile(models.Model):
def is_owned_by(self, user):
return user.id == self.owner.id
+ def can_be_viewed_by(self, user):
+ if hasattr(self, 'profile_of'):
+ return user.can_view(self.profile_of)
+ if hasattr(self, 'avatar_of'):
+ return user.can_view(self.avatar_of)
+ if hasattr(self, 'scrub_of'):
+ return user.can_view(self.scrub_of)
+ return False
+
def delete(self):
for c in self.children.all():
c.delete()
@@ -422,6 +485,9 @@ class SithFile(models.Model):
def get_display_name(self):
return self.name
+ def get_download_url(self):
+ return reverse('core:download', kwargs={'file_id': self.id})
+
class LockError(Exception):
"""There was a lock error on the object"""
pass
diff --git a/core/static/core/form.css b/core/static/core/form.css
index 9dbe2777..ff65340e 100644
--- a/core/static/core/form.css
+++ b/core/static/core/form.css
@@ -2,6 +2,11 @@
Super Form Reset
----------------------------------------------------------------------------------------------------*/
+form {
+ margin: 0px auto;
+ width: 60%;
+}
+
input,
label,
select,
@@ -22,6 +27,10 @@ textarea
font-family: Arial;
}
+label {
+ min-width: 50%;
+}
+
/* Remove the stupid outer glow in Webkit */
input:focus
{
@@ -70,7 +79,8 @@ input[type=tel],
input[type=text],
input[type=time],
input[type=url],
-input[type=week]
+input[type=week],
+textarea
{
background-color: white;
border: 1px solid black;
diff --git a/core/static/core/img/promo_01.png b/core/static/core/img/promo_01.png
new file mode 100644
index 00000000..ba1e5a96
Binary files /dev/null and b/core/static/core/img/promo_01.png differ
diff --git a/core/static/core/img/promo_02.png b/core/static/core/img/promo_02.png
new file mode 100644
index 00000000..29593a17
Binary files /dev/null and b/core/static/core/img/promo_02.png differ
diff --git a/core/static/core/img/promo_03.png b/core/static/core/img/promo_03.png
new file mode 100644
index 00000000..2d1ce707
Binary files /dev/null and b/core/static/core/img/promo_03.png differ
diff --git a/core/static/core/img/promo_04.png b/core/static/core/img/promo_04.png
new file mode 100644
index 00000000..1011a729
Binary files /dev/null and b/core/static/core/img/promo_04.png differ
diff --git a/core/static/core/img/promo_05.png b/core/static/core/img/promo_05.png
new file mode 100644
index 00000000..394ba362
Binary files /dev/null and b/core/static/core/img/promo_05.png differ
diff --git a/core/static/core/img/promo_06.png b/core/static/core/img/promo_06.png
new file mode 100644
index 00000000..c837dadf
Binary files /dev/null and b/core/static/core/img/promo_06.png differ
diff --git a/core/static/core/img/promo_07.png b/core/static/core/img/promo_07.png
new file mode 100644
index 00000000..ae3bafb0
Binary files /dev/null and b/core/static/core/img/promo_07.png differ
diff --git a/core/static/core/img/promo_08.png b/core/static/core/img/promo_08.png
new file mode 100644
index 00000000..6897270c
Binary files /dev/null and b/core/static/core/img/promo_08.png differ
diff --git a/core/static/core/img/promo_09.png b/core/static/core/img/promo_09.png
new file mode 100644
index 00000000..fea3671d
Binary files /dev/null and b/core/static/core/img/promo_09.png differ
diff --git a/core/static/core/img/promo_10.png b/core/static/core/img/promo_10.png
new file mode 100644
index 00000000..7d553e20
Binary files /dev/null and b/core/static/core/img/promo_10.png differ
diff --git a/core/static/core/img/promo_11.png b/core/static/core/img/promo_11.png
new file mode 100644
index 00000000..ca8487fb
Binary files /dev/null and b/core/static/core/img/promo_11.png differ
diff --git a/core/static/core/img/promo_12.png b/core/static/core/img/promo_12.png
new file mode 100644
index 00000000..8afefc16
Binary files /dev/null and b/core/static/core/img/promo_12.png differ
diff --git a/core/static/core/img/promo_13.png b/core/static/core/img/promo_13.png
new file mode 100644
index 00000000..8affbc10
Binary files /dev/null and b/core/static/core/img/promo_13.png differ
diff --git a/core/static/core/img/promo_14.png b/core/static/core/img/promo_14.png
new file mode 100644
index 00000000..7085991c
Binary files /dev/null and b/core/static/core/img/promo_14.png differ
diff --git a/core/static/core/img/promo_15.png b/core/static/core/img/promo_15.png
new file mode 100644
index 00000000..dcfa5e8f
Binary files /dev/null and b/core/static/core/img/promo_15.png differ
diff --git a/core/static/core/img/promo_16.png b/core/static/core/img/promo_16.png
new file mode 100644
index 00000000..be96e7ba
Binary files /dev/null and b/core/static/core/img/promo_16.png differ
diff --git a/core/static/core/js/script.js b/core/static/core/js/script.js
index d889750f..9cf2944e 100644
--- a/core/static/core/js/script.js
+++ b/core/static/core/js/script.js
@@ -1,11 +1,29 @@
console.log('Guy');
$( function() {
- dialog = $( ".choose_file_widget" ).dialog({
+ buttons = $(".choose_file_button");
+ popups = $(".choose_file_widget");
+ popups.dialog({
autoOpen: false,
modal: true,
+ width: "80%",
+ minHeight: "300",
+ buttons: {
+ "Choose": function() {
+ console.log($("#file_id"));
+ $("input[name="+$(this).attr('name')+"]").attr('value', $("#file_id").attr('value'));
+ $( this ).dialog( "close" );
+ }
+ }
+ });
+ $('.select_date').datepicker({
+ changeMonth: true,
+ changeYear: true
});
$( ".choose_file_button" ).button().on( "click", function() {
- dialog.dialog( "open" );
+ popup = popups.filter("[name="+$(this).attr('name')+"]");
+ console.log(popup);
+ popup.html('');
+ popup.dialog({title: $(this).attr('name')}).dialog( "open" );
});
} );
diff --git a/core/static/core/style.css b/core/static/core/style.css
index fe517c12..1f9244cd 100644
--- a/core/static/core/style.css
+++ b/core/static/core/style.css
@@ -118,12 +118,16 @@ ul, ol {
}
table {
width: 100%;
+ font-size: 0.90em;
}
td {
padding: 4px;
border: solid 1px black;
border-collapse: collapse;
vertical-align: top;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ max-width: 0;
}
td>ul {
margin-top: 0px;
@@ -152,7 +156,27 @@ tbody>tr:hover {
}
/*-----------------------------USER PROFILE----------------------------*/
-.user_profile {
+#user_profile {
+ width: 80%;
+ margin: 0px auto;
+ padding: 10px;
+ overflow: auto;
+}
+#user_profile h4 { border-bottom: 1px solid grey; max-width: 60%; }
+#user_profile #pictures {
+ width: 30%;
+ float: right;
+ font-style: italic;
+}
+#user_profile #nickname {
+ font-style: italic;
+}
+#user_profile #pictures img {
+ max-width: 96%;
+ max-height: 96%;
+}
+#user_profile .promo_pict {
+ height: 45px;
}
/*---------------------------------PAGE--------------------------------*/
.page_content {
diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja
index eaf51cf4..815e60a0 100644
--- a/core/templates/core/base.jinja
+++ b/core/templates/core/base.jinja
@@ -60,23 +60,25 @@
{{ tests }}
{% endblock %}
-->
+ {% block script %}
+ {% endblock %}