diff --git a/com/models.py b/com/models.py index c3061ed0..c61fe7b4 100644 --- a/com/models.py +++ b/com/models.py @@ -36,6 +36,7 @@ from django.core.exceptions import ValidationError from django.utils import timezone +from core import utils from core.models import User, Preferences, RealGroup, Notification, SithFile from club.models import Club @@ -46,6 +47,7 @@ class Sith(models.Model): alert_msg = models.TextField(_("alert message"), default="", blank=True) info_msg = models.TextField(_("info message"), default="", blank=True) weekmail_destinations = models.TextField(_("weekmail destinations"), default="") + version = utils.get_git_revision_short_hash() def is_owned_by(self, user): return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) diff --git a/com/tests.py b/com/tests.py index e0ebfc69..a18c9819 100644 --- a/com/tests.py +++ b/com/tests.py @@ -82,7 +82,7 @@ class ComTest(TestCase): self.assertContains( r, """
-

ALERTE!

+

ALERTE!

Caaaataaaapuuuulte!!!!

""", ) @@ -100,7 +100,7 @@ class ComTest(TestCase): self.assertContains( r, """
-

INFO: Caaaataaaapuuuulte!!!!

""", +

INFO: Caaaataaaapuuuulte!!!!

""", ) def test_birthday_non_subscribed_user(self): diff --git a/core/migrations/0019_preferences_receive_weekmail.py b/core/migrations/0019_preferences_receive_weekmail.py index 951488aa..5bfe0d97 100644 --- a/core/migrations/0019_preferences_receive_weekmail.py +++ b/core/migrations/0019_preferences_receive_weekmail.py @@ -13,7 +13,7 @@ class Migration(migrations.Migration): model_name="preferences", name="receive_weekmail", field=models.BooleanField( - default=False, verbose_name="do you want to receive the weekmail" + default=False, verbose_name="receive the weekmail" ), ) ] diff --git a/core/models.py b/core/models.py index e904603f..dff97cf0 100644 --- a/core/models.py +++ b/core/models.py @@ -783,9 +783,7 @@ class Preferences(models.Model): user = models.OneToOneField( User, related_name="_preferences", on_delete=models.CASCADE ) - receive_weekmail = models.BooleanField( - _("do you want to receive the weekmail"), default=False - ) + receive_weekmail = models.BooleanField(_("receive the Weekmail"), default=False) show_my_stats = models.BooleanField(_("show your stats to others"), default=False) notify_on_click = models.BooleanField( _("get a notification for every click"), default=False diff --git a/core/static/core/header.scss b/core/static/core/header.scss new file mode 100644 index 00000000..d1b9581f --- /dev/null +++ b/core/static/core/header.scss @@ -0,0 +1,408 @@ +.header { + box-sizing: border-box; + background-color: #354a5f; + box-shadow: 3px 3px 3px 0 #dfdfdf; + border-radius: 0; + width: 100%; + display: flex; + flex-direction: row; + flex-wrap: wrap; + padding: 10px; + gap: 10px; + + @media (max-width: 700px) { + height: auto; + } + + @media (max-width: 580px) { + justify-content: space-between; + } + + &-logo { + display: flex; + flex-direction: row; + gap: 10px; + + &:hover > a { + color: #1a78b3; + } + + @media (max-width: 607px) { + width: 100%; + justify-content: center; + } + + &-picture { + height: 100%; + width: 65px; + display: flex; + + background-position: center center; + background-size: contain; + background-repeat: no-repeat; + + @media (max-width: 580px) { + height: auto; + } + } + + &-text { + color: white; + display: flex; + flex-direction: column; + justify-content: center; + align-items: flex-start; + + > span:first-child { + font-size: 1.43em; + } + + > span:last-child { + font-size: .7em; + } + } + + } + + &-lang { + box-sizing: border-box; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + gap: 3px; + + @media (max-width: 580px) { + flex-direction: row; + } + + > form { + margin: 0; + box-sizing: border-box; + position: relative; + + > input[type=submit] { + border-radius: 0; + margin: 0; + box-sizing: border-box; + background-color: #354a5f; + width: 45px; + height: 25px; + padding: 0; + color: white; + font-weight: normal; + line-height: 1.3em; + + &:hover { + background-color: #283747; + } + } + } + } + + &-disconnected { + box-sizing: border-box; + flex: 1; + display: flex; + justify-content: flex-end; + align-items: center; + + @media (max-width: 607px) { + justify-content: center; + } + + > .button { + box-sizing: border-box; + height: 35px; + background-color: transparent; + font-weight: normal; + padding: 5px 20px; + display: flex; + justify-content: center; + align-items: center; + text-transform: uppercase; + text-decoration: none; + color: white; + margin: 0; + font-size: .9em; + width: 120px; + + &:hover { + background-color: #283747; + } + } + } + + &-disconnected ~ &-lang { + @media (max-width: 662px) { + flex-direction: row; + width: 100%; + } + } + + &-connected { + box-sizing: border-box; + flex: 1; + display: flex; + flex-direction: row; + + @media (min-width: 400px) and (max-width: 1200px) { + flex-direction: column; + min-width: 100%; + justify-content: center; + align-items: center; + gap: 10px; + } + + @media (max-width: 400px) { + flex-direction: column; + width: 100%; + gap: 10px; + padding: 0 10px; + } + + > .right, + > .left { + box-sizing: border-box; + display: flex; + flex-direction: row; + align-items: center; + + @media (min-width: 400px) and (max-width: 1200px) { + width: 100%; + justify-content: space-between; + padding: 0 20px; + } + } + + > .right { + flex: 1; + justify-content: flex-end; + + > .user { + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + gap: 15px; + + @media (max-width: 1200px) { + width: 100%; + flex-direction: row-reverse; + } + + > a > img { + width: 40px; + height: 40px; + border-radius: 50%; + } + + > .options { + width: 100%; + display: flex; + justify-content: flex-end; + flex-direction: column; + gap: 5px; + + @media (max-width: 1200px) { + justify-content: flex-start; + flex-direction: row; + gap: 15px; + } + + > a { + text-align: right; + color: white; + + &:hover { + color: #1a78b3; + } + + &:last-child { + color: #eb2f06; + + &:hover { + color: #cc2804; + } + } + } + } + } + + > .notification { + height: 100%; + width: 55px; + display: flex; + justify-content: center; + align-items: center; + position: relative; + + > a { + color: white; + position: relative; + font-size: 25px; + + &:hover { + color: #1a78b3; + } + + > span { + color: white; + font-size: 14px; + display: flex; + justify-content: center; + align-items: center; + width: 10px; + height: 10px; + padding: 5px; + background-color: #eb2f06; + border-radius: 50%; + position: absolute; + top: -50%; + right: -50%; + } + } + + > #header_notif { + box-sizing: border-box; + display: none; + position: absolute; + margin: 0; + background-color: whitesmoke; + top: calc(100% + 10px); + right: calc(50% - 30px); + width: 400px; + max-width: calc(100vw - 30px); + padding: 10px; + z-index: 100; + border-radius: 10px; + box-shadow: 3px 3px 3px 0 #767676; + + > ul { + list-style-type: none; + margin: 0; + display: flex; + flex-direction: column; + gap: 10px; + max-height: 120px; + overflow-y: auto; + + > li { + > a { + .datetime { + display: flex; + justify-content: flex-start; + gap: 10px; + font-style: italic; + font-size: .8em; + } + } + + &.empty-notification { + text-align: center; + font-style: italic; + } + } + } + + .options { + width: 100%; + display: flex; + justify-content: space-between; + margin-top: 10px; + + > a { + color: black; + padding: 5px; + width: 50%; + display: flex; + justify-content: center; + text-align: center; + align-items: center; + border-radius: 5px; + + &:hover { + background-color: rgba(0, 0, 0, .2); + } + } + } + } + } + } + + > .left { + gap: 10px; + display: flex; + + @media (max-width: 1200px) { + flex-direction: row-reverse; + } + + @media (max-width: 550px) { + flex-direction: column-reverse; + } + + > form { + margin: 0; + width: 200px; + + @media (max-width: 550px) { + width: 100%; + } + + > input[type=text] { + box-sizing: border-box; + max-width: 100%; + width: 100%; + height: 35px; + border-radius: 5px; + font-size: .9em; + margin: 0; + background-color: #283747; + padding: 0 10px; + color: white; + } + } + } + } + + &-connected ~ &-lang { + @media (max-width: 1200px) { + flex-direction: row; + width: 100%; + } + } +} + +.bars { + list-style-type: none; + min-width: 120px; + margin: 0; + padding: 0; + + @media(max-width: 1200px) { + display: flex; + flex-direction: row; + gap: 20px; + } + + > li > a { + display: flex; + color: white; + + &:hover { + color: #1a78b3; + } + + > span { + margin-left: 10px; + } + + > i { + width: 16px; + display: flex; + justify-content: center; + align-items: center; + } + } +} \ No newline at end of file diff --git a/core/static/core/img/logo_no_text.png b/core/static/core/img/logo_no_text.png new file mode 100644 index 00000000..73e95257 Binary files /dev/null and b/core/static/core/img/logo_no_text.png differ diff --git a/core/static/core/js/script.js b/core/static/core/js/script.js index 671785fe..1ab7887e 100644 --- a/core/static/core/js/script.js +++ b/core/static/core/js/script.js @@ -1,5 +1,3 @@ -console.log('Guy'); - $( function() { buttons = $(".choose_file_button"); popups = $(".choose_file_widget"); diff --git a/core/static/core/navbar.scss b/core/static/core/navbar.scss new file mode 100644 index 00000000..2eede6c0 --- /dev/null +++ b/core/static/core/navbar.scss @@ -0,0 +1,110 @@ +nav.navbar { + display: flex; + flex-direction: row; + flex-wrap: wrap; + align-items: center; + justify-content: center; + background-color: hsl(203, 75%, 40%); + margin: 1em; + color: white; + border-radius: 0.6em; + + @media (max-width: 500px) { + position: relative; + flex-direction: column; + align-items: flex-start; + gap: 0; + margin: .2em; + } + + > .menu, + > .link { + box-sizing: border-box; + width: 130px; + height: 52px; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + + @media (max-width: 500px) { + width: 100%; + height: auto; + justify-content: flex-start; + + &:first-child { + border-radius: .6em .6em 0 0; + } + + &:last-child { + border-radius: 0 0 .6em .6em; + + > .content { + box-shadow: 3px 3px 3px 0 #dfdfdf; + } + } + } + } + + > .menu > .head, + > .link { + color: white; + padding: 10px 20px; + box-sizing: border-box; + + @media (max-width: 500px) { + padding: 10px; + } + } + + .link:hover, + .menu:hover { + background-color: rgba(0, 0, 0, .2); + } + + > .menu:hover > .content, + > .menu > .head:hover + .content, + > .menu > .content:hover { + display: flex; + } + + > .menu { + display: flex; + position: relative; + + > .content { + z-index: 10; + display: none; + position: absolute; + top: 100%; + background-color: white; + margin: 0; + list-style-type: none; + width: 130px; + box-shadow: 3px 3px 3px 0 #dfdfdf; + flex-direction: column; + + @media (max-width: 500px) { + position: absolute; + flex-direction: row; + flex-wrap: wrap; + width: 100%; + box-shadow: inset 3px 3px 3px 0 #dfdfdf; + } + + > li > a { + display: flex; + padding: 15px 20px; + + @media (max-width: 500px) { + padding: 10px; + } + + &:hover { + color: hsl(203, 75%, 40%); + background-color: rgba(0, 0, 0, .05); + } + } + } + } +} \ No newline at end of file diff --git a/core/static/core/style.scss b/core/static/core/style.scss index f4840082..9068e8c5 100644 --- a/core/static/core/style.scss +++ b/core/static/core/style.scss @@ -76,6 +76,7 @@ button:not(:disabled), input[type="button"]:not(:disabled), input[type="submit"]:not(:disabled), input[type="reset"]:not(:disabled), +input[type="checkbox"]:not(:disabled), input[type="file"]:not(:disabled) { cursor: pointer; } @@ -99,6 +100,7 @@ textarea { padding: 7px; font-size: 1.2em; border-radius: 5px; + font-family: sans-serif; } select { border: none; @@ -181,166 +183,6 @@ a { /*--------------------------------HEADER-------------------------------*/ -#header_language_chooser { - position: absolute; - top: 2em; - left: 0.5em; - width: 3%; - min-width: 2.2em; - text-align: center; - input { - display: block; - width: 100%; - padding: 4px; - margin: 0px; - } - form { - display: block; - margin: 0.2em 0em; - width: 100%; - } -} - -header { - width: 90%; - margin: 0 auto; - display: flex; - box-shadow: $shadow-color 0 0 15px; - border-top: none; - background-color: $primary-neutral-dark-color; - border-radius: 0px 0px 10px 10px; - - #header_logo { - background-color: $white-color; - padding: 0.2em; - border-radius: 0 0 0 9px; - - a { - display: flex; - align-items: center; - margin: 0px; - width: 100%; - height: 100%; - - img { - max-width: 70%; - max-height: 100%; - margin: auto; - display: block; - } - } - } - - #header_connect_links { - margin: 0.6em 0.6em 0 auto; - padding: 0.2em; - color: $white-color; - form { - display: inline; - width: 100%; - label { - display: inline; - } - } - } - - #header_bar { - display: flex; - flex: auto; - flex-wrap: wrap; - align-items: center; - width: 80%; - - a { - text-decoration: none; - margin: 0 1em; - font-weight: bold; - color: $white-color; - &:hover { - color: $secondary-color; - text-decoration: underline; - } - } - - #header_bars_infos { - flex: initial; - list-style-type: none; - margin: 0.2em 0.2em; - } - - #header_search { - display: inline-block; - flex: auto; - margin: 0.8em 0; - input { - width: 14ch; - } - } - - #header_user_links { - display: flex; - flex: initial; - flex-wrap: wrap; - text-align: right; - margin: 0; - div { - display: inline; - padding: 1.2em 0; - &:first-child { - flex: auto; - } - } - .white { - background: $white-color; - a { - color: $black-color; - } - } - #header_notif { - display: none; - position: absolute; - max-height: 20em; - width: 22em; - overflow: auto; - list-style-type: none; - box-shadow: grey 1px 1px 5px; - background: white; - text-align: left; - font-size: 80%; - margin: 1.5em 0 0em -14em; - .header_notif_date { - font-weight: bold; - } - .header_notif_time { - color: grey; - } - a { - margin: 0; - color: $black-color; - &:hover { - color: $primary-dark-color; - } - } - li { - padding: 0.2em; - &:hover { - background: hsl(180, 14%, 77%); - } - } - li:last-child { - text-align: center; - a { - color: $primary-dark-color; - &:hover { - color: $primary-light-color; - } - } - } - } - } - } -} - #popupheader { width: 88%; margin: 0 auto; @@ -350,8 +192,13 @@ header { #info_boxes { display: flex; flex-wrap: wrap; - width: 90%; - margin: 1em auto; + margin: 1em; + + @media (max-width: 500px) { + margin: 0; + width: 100%; + } + #alert_box, #info_box { flex: 49%; @@ -388,75 +235,6 @@ header { width: 90%; margin: 20px auto 0; /*---------------------------------NAV---------------------------------*/ - nav { - display: flex; - flex-wrap: wrap; - background-color: $primary-dark-color; - color: $white-color; - border-radius: 6px 6px 0 0; - box-shadow: $shadow-color 0 0 15px; - align-items: center; - - a { - flex: auto; - text-align: center; - padding: 1.5em; - color: $white-color; - font-style: normal; - font-weight: bolder; - text-decoration: none; - - &:hover { - background: $secondary-neutral-color; - color: $white-color; - &:first-of-type { - border-radius: 6px 0 0 0; - } - &:last-of-type { - border-radius: 0 6px 0 0; - } - } - } - - .dropdown { - flex: auto; - text-align: center; - position: relative; - } - - .dropbtn { - all: unset; - padding: 20px; - font-weight: bolder; - } - - .dropdown-content { - display: none; - position: absolute; - overflow: auto; - width: 100%; - background-color: #f9f9f9; - box-shadow: 3px 3px 3px 0 $shadow-color; - z-index: 1; - } - - .dropdown-content a { - float: none; - color: black; - padding: 12px 16px; - display: block; - text-align: center; - &:hover { - border-radius: unset; - color: white; - background: $secondary-neutral-color; - } - } - - .dropdown:hover .dropdown-content { - display: block; - } - } .btn { font-size: 15px; @@ -1120,32 +898,26 @@ h6 { h1 { font-size: 160%; - margin-left: 0; } h2 { font-size: 150%; - margin-left: 10px; } h3 { font-size: 140%; - margin-left: 20px; } h4 { font-size: 130%; - margin-left: 30px; } h5 { font-size: 120%; - margin-left: 40px; } h6 { font-size: 110%; - margin-left: 50px; } p, @@ -1328,88 +1100,6 @@ u, /*-----------------------------USER PROFILE----------------------------*/ -#user_profile_page { - #user_profile { - display: flex; - justify-content: center; - margin-top: 2em; - margin-bottom: 4em; - #user_profile_infos { - flex-basis: 30%; - border-right: solid 1px grey; - div { - margin: 0.5em; - } - #user_profile_infos_items { - margin-top: 3em; - } - .user_profile_infos_item, - .user_profile_infos_item_value { - vertical-align: top; - display: inline-block; - width: 49%; - } - .user_profile_infos_item { - color: grey; - } - #user_profile_infos_promo { - display: flex; - align-items: center; - img { - width: 5em; - margin: 0.5em; - } - } - #user_profile_infos_quote { - text-align: right; - color: grey; - font-style: italic; - &:after, - &:before { - content: "\201C"; - vertical-align: middle; - } - } - } - #user_profile_pictures { - height: 20em; - flex-basis: 30%; - display: flex; - justify-content: flex-end; - #user_profile_pictures_bigone { - flex-grow: 9; - flex-basis: 20em; - display: flex; - justify-content: center; - align-items: center; - img { - max-width: 100%; - max-height: 100%; - object-fit: contain; - } - } - #user_profile_pictures_thumbnails { - flex-grow: 1; - flex-basis: 50px; - display: flex; - justify-content: center; - align-items: center; - flex-direction: column; - img { - margin: 0.1em; - width: 50px; - } - } - } - @media screen and (max-width: $small-devices) { - #user_profile_infos, - #user_profile_pictures { - flex-basis: 50%; - } - } - } -} - .user_mini_profile { height: 100%; width: 100%; @@ -1691,47 +1381,6 @@ textarea { } } -/*------------------------------SAS------------------------------------*/ - -.album { - display: inline-block; - border: solid 1px $black-color; - text-align: center; - padding: 5px; - width: 200px; - height: 140px; - background: hsl(0, 0%, 93%); - box-shadow: black 2px 2px 10px; - margin: 10px; - vertical-align: top; - img { - max-height: 100px; - } -} - -.picture { - display: inline-block; - border: solid 1px $black-color; - width: 150px; - height: 100px; - margin: 5px; - background: #eeeeee; - box-shadow: grey 2px 2px 5px; - padding: 2px; - vertical-align: middle; - img { - max-width: 100%; - max-height: 100px; - display: block; - margin: auto; - } -} - -.not_moderated { - border: solid 1px red; - box-shadow: red 2px 2px 10px; -} - /*--------------------------------FOOTER-------------------------------*/ footer { @@ -1747,6 +1396,7 @@ footer { border-radius: 5px; display: flex; flex-wrap: wrap; + align-items: center; background-color: $primary-neutral-dark-color; box-shadow: $shadow-color 0 0 15px; a { @@ -1759,6 +1409,11 @@ footer { } } } + + > .version { + margin-top: 3px; + color: rgba(0, 0, 0, .3) + } } /*---------------------------------FORMS-------------------------------*/ diff --git a/core/static/counter/activity.scss b/core/static/counter/activity.scss new file mode 100644 index 00000000..1ffb1111 --- /dev/null +++ b/core/static/counter/activity.scss @@ -0,0 +1,24 @@ +.activity-description { + display: flex; + flex-direction: column; + gap: 5px; + width: 100%; + margin-top: 10px; + + > div { + display: flex; + flex-direction: row; + gap: 10px; + + > span { + text-align: left; + } + + > i { + width: 16px; + display: flex; + justify-content: center; + align-items: center; + } + } +} \ No newline at end of file diff --git a/core/static/sas/album.scss b/core/static/sas/album.scss new file mode 100644 index 00000000..fbbba94b --- /dev/null +++ b/core/static/sas/album.scss @@ -0,0 +1,249 @@ +main { + box-sizing: border-box; + padding: 10px; +} + +.navbar { + margin-top: 10px; + display: flex; + flex-direction: row; + flex-wrap: wrap; + gap: 10px; + justify-content: space-between; +} + +.toolbar { + display: flex; + align-items: flex-end; + flex-wrap: wrap; + gap: 5px; + + > a, + > input { + padding: 0.4em; + margin: 0.1em; + font-size: 1.2em; + line-height: 1.2em; + color: black; + background-color: #f2f2f2; + border-radius: 5px; + font-weight: bold; + + &:hover { + background-color: #d4d4d4; + } + + &:disabled { + background-color: #f2f2f2; + color: #d4d4d4; + } + } +} + +.add-files { + display: flex; + flex-direction: column; + + > .inputs { + align-items: flex-end; + display: flex; + flex-direction: row; + flex-wrap: wrap; + gap: 10px; + + > p { + box-sizing: border-box; + max-width: 300px; + width: 100%; + + @media (max-width: 500px) { + max-width: 100%; + } + + > input { + box-sizing: border-box; + max-width: 100%; + width: 100%; + height: 40px; + line-height: normal; + font-size: 16px; + } + } + + > div > input, + > input { + box-sizing: border-box; + height: 40px; + width: 100%; + max-width: 300px; + + @media (max-width: 500px) { + max-width: 100%; + } + } + + > div { + width: 100%; + max-width: 300px; + } + + > input[type=submit]:hover { + background-color: #287fb8; + color: white; + } + } + +} + +.clipboard { + margin-top: 10px; + padding: 10px; + background-color: rgba(0,0,0,.1); + border-radius: 10px; +} + +.paginator { + display: flex; + justify-content: center; + gap: 10px; + width: -moz-fit-content; + width: fit-content; + background-color: rgba(0,0,0,.1); + border-radius: 10px; + padding: 10px; + margin: 10px 0 10px auto; +} + +.photos, +.albums { + box-sizing: border-box; + display: flex; + flex-direction: row; + flex-wrap: wrap; + gap: 5px; + + > div { + background: rgba(0, 0, 0, .5); + cursor: not-allowed; + } + + > div, + > a { + box-sizing: border-box; + position: relative; + height: 128px; + + @media (max-width: 500px) { + width: calc(50% - 5px); + height: 108px; + } + + @media (max-width: 300px) { + width: 100%; + } + + &:hover { + background: rgba(0, 0, 0, .5); + } + + > input[type=checkbox] { + position: absolute; + top: 0; + right: 0; + height: 15px; + width: 15px; + margin: 5px; + + cursor: pointer; + } + + > .photo, + > .album { + box-sizing: border-box; + background-size: cover; + background-repeat: no-repeat; + background-position: center center; + + width: calc(16 / 9 * 128px); + height: 128px; + + margin: 0; + padding: 0; + box-shadow: none; + + border: 1px solid rgba(0, 0, 0, .3); + + @media (max-width: 500px) { + width: 100%; + height: 100%; + } + + &:hover > .text { + background-color: rgba(0, 0, 0, .5); + } + + &:hover > .overlay { + -webkit-backdrop-filter: blur(2px); + backdrop-filter: blur(2px); + + ~ .text { + background-color: transparent; + } + } + + > .text { + position: absolute; + box-sizing: border-box; + top: 0; + left: 0; + width: 100%; + height: 100%; + + display: flex; + flex-direction: column; + justify-content: flex-end; + align-items: flex-start; + + padding: 10px; + color: white; + } + + > .overlay { + position: absolute; + width: 100%; + height: 100%; + top: 0; + left: 0; + + &::before { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + content: '⚠️'; + color: white; + display: flex; + justify-content: center; + align-items: center; + + background: rgba(0, 0, 0, .5); + -webkit-backdrop-filter: blur(5px); + backdrop-filter: blur(5px); + } + } + } + + > .album > div { + background: rgba(0, 0, 0, .5); + background: linear-gradient(0deg, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, 0) 100%); + text-align: left; + word-break: break-word; + } + + > .photo > .text { + align-items: center; + padding-bottom: 30px; + } + } +} \ No newline at end of file diff --git a/core/static/sas/picture.scss b/core/static/sas/picture.scss new file mode 100644 index 00000000..f5c895fe --- /dev/null +++ b/core/static/sas/picture.scss @@ -0,0 +1,309 @@ +#content { + padding: 10px !important; +} + +.title { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; +} + +.container { + display: flex; + flex-direction: row; + gap: 10px; + + @media (max-width: 1000px) { + flex-direction: column; + } +} + +.main { + display: flex; + flex-direction: column; + width: calc(75% - 5px); + gap: 10px; + + @media (max-width: 1000px) { + width: 100%; + } + + > .photo { + box-sizing: border-box; + height: 500px; + display: flex; + justify-content: center; + background-color: #333333; + padding: 5px; + + @media (max-width: 1000px) { + width: 100%; + height: auto; + } + + > img { + height: 100%; + max-width: 100%; + object-fit: contain; + } + } +} + +.subsection { + width: calc(25% - 5px); + + @media (max-width: 1000px) { + width: 100%; + } + + > .navigation { + display: flex; + flex-direction: row; + gap: 10px; + + @media (max-width: 1000px) { + width: 100%; + } + + > #prev, + > #next { + width: calc(50% - 5px); + aspect-ratio: 16/9; + background: #aaa; + + > a { + display: flex; + position: relative; + width: 100%; + height: 100%; + + > div { + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + font-size: 30px; + color: white; + + background-repeat: no-repeat; + background-position: center center; + background-size: cover; + + &::before { + position: absolute; + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + background-color: rgba(0, 0, 0, .3); + } + } + } + } + + > #prev > a > div::before { + content: '←'; + } + > #next > a > div::before { + content: '→'; + } + } + + > .tags { + @media (min-width: 1001px) { + margin-right: 5px; + } + + > ul { + list-style-type: none; + margin: 0; + display: flex; + flex-direction: column; + gap: 5px; + + @media (max-width: 1000px) { + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + gap: 10px; + margin-right: 5px; + } + + > li { + box-sizing: border-box; + display: flex; + flex-direction: row; + align-items: center; + width: 100%; + justify-content: space-between; + + @media (max-width: 1000px) { + max-width: calc(50% - 5px); + } + + > a { + display: flex; + flex-direction: row; + align-items: center; + gap: 10px; + + &.user { + width: 100%; + background-color: #eee; + padding: 5px 10px 5px 5px; + border-radius: 5px; + color: black; + max-width: calc(100% - 40px); + min-height: 30px; + + &:hover { + background-color: #aaa; + } + + > span { + width: 100%; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + } + } + + &.delete { + margin-left: 10px; + } + + > img { + width: 25px; + max-height: 25px; + object-fit: contain; + border-radius: 50%; + } + } + } + } + + > form { + > p { + box-sizing: border-box; + + > input { + width: 100%; + max-width: 100%; + box-sizing: border-box; + } + } + + > .results_on_deck > div { + position: relative; + display: flex; + align-items: center; + word-break: break-word; + + > span { + position: absolute; + top: 0; + right: 0; + } + } + + > input { + width: 100%; + max-width: 100%; + box-sizing: border-box; + } + } + } +} + +.general { + display: flex; + flex-direction: row; + gap: 20px; + + @media (max-width: 1000px) { + flex-direction: column; + } + + > .infos { + display: flex; + flex-direction: column; + + > div > div { + display: flex; + flex-direction: row; + justify-content: space-between; + + > *:first-child { + min-width: 150px; + + @media (max-width: 1000px) { + min-width: auto; + } + } + } + } + + > .tools { + display: flex; + flex-direction: column; + width: 100%; + + > div { + display: flex; + flex-direction: row; + justify-content: space-between; + + > div { + > a.button { + box-sizing: border-box; + background-color: #f2f2f2; + display: flex; + justify-content: center; + align-items: center; + padding: 10px; + color: black; + border-radius: 5px; + width: 40px; + height: 40px; + + &:hover { + background-color: #aaa; + } + } + + > a.text.danger { + color: red; + + &:hover { + color: darkred; + } + } + + &.buttons { + display: flex; + gap: 5px; + } + } + } + } +} + +.moderation { + box-sizing: border-box; + width: 100%; + border: 2px solid coral; + border-radius: 2px; + padding: 10px; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + + > div:last-child { + display: flex; + gap: 20px; + } +} diff --git a/core/static/user/login.scss b/core/static/user/login.scss new file mode 100644 index 00000000..fb4a5768 --- /dev/null +++ b/core/static/user/login.scss @@ -0,0 +1,108 @@ +html, +body { + box-sizing: border-box; + height: 100%; +} + +body { + display: flex; + flex-direction: column; +} + +#page { + flex: 1; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + + #content { + display: flex; + flex-direction: column; + padding: 10px; + box-shadow: none; + background-color: white; + margin: 0; + + > .title { + text-align: center; + margin: 0; + } + + > div, + > form { + box-sizing: border-box; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 10px; + width: 100%; + max-width: 500px; + margin-top: 20px; + + > p, + > div { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + margin: 0; + + > label { + width: 100%; + + @media (min-width: 500px) { + width: 300px; + } + } + } + + > input, + > p > input, + > div > input { + box-sizing: border-box; + width: 100%; + max-width: 500px; + + @media (min-width: 500px) { + max-width: 300px; + } + } + + > .errorlist { + color: red; + text-align: center; + margin: 10px 0 0 0; + list-style-type: none; + } + + > .required > .helptext { + text-align: center; + font-style: italic; + } + + > .required:last-of-type { + box-sizing: border-box; + max-width: 300px; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-between; + + > label { + width: 100%; + } + + > img { + width: 70px; + object-fit: contain; + } + + > input { + width: 200px; + } + } + } + } +} \ No newline at end of file diff --git a/core/static/user/user_detail.scss b/core/static/user/user_detail.scss new file mode 100644 index 00000000..6ac5065a --- /dev/null +++ b/core/static/user/user_detail.scss @@ -0,0 +1,200 @@ +main { + box-sizing: border-box; + display: flex; + margin-bottom: 4em; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 10px; + width: 100%; + + > .user_profile > .user_profile_infos { + @media (max-width: 960px) { + border-right-color: transparent; + } + } +} + +.user-name { + display: flex; + flex-direction: column; + align-items: flex-start; + width: 100%; + max-width: 1080px; + margin: 0 auto; +} + +.infos-and-picture { + display: flex; + flex-direction: row; + justify-content: center; + width: 100%; + max-width: 1080px; + margin: 0 auto; + + @media (max-width: 960px) { + flex-direction: column-reverse; + gap: 20px; + } + + > .user_profile_infos { + width: 50%; + border-right: solid 1px grey; + + @media (max-width: 960px) { + width: 100%; + } + + @media (min-width: 960px) { + padding-right: 20px; + } + + > .user_profile_infos_promo { + display: flex; + flex-direction: row; + gap: 10px; + align-items: center; + justify-content: center; + width: 100%; + + > img { + width: 5em; + margin: 0.5em; + } + } + + > .user_profile_infos_items { + margin-top: 30px; + display: flex; + flex-direction: column; + gap: 5px; + + > div { + box-sizing: border-box; + display: flex; + + > .user_profile_infos_item, + > .user_profile_infos_item_value { + vertical-align: top; + display: block; + width: 50%; + } + + > .user_profile_infos_item { + color: gray; + } + } + } + + > #user_profile_infos_quote { + text-align: right; + color: grey; + font-style: italic; + + @media (max-width: 960px) { + text-align: center; + } + + &:after, + &:before { + vertical-align: middle; + } + + &:before { + content: "\201C"; + } + + &:after { + content: "\201D"; + } + } + } + + > .user_profile_pictures { + height: 20em; + width: 50%; + display: flex; + flex-direction: row; + justify-content: flex-end; + + @media (max-width: 960px) { + width: 100%; + height: 100%; + flex-direction: column; + } + + @media (min-width: 960px) { + padding-left: 20px; + } + + > .user_profile_pictures_bigone { + flex-grow: 9; + flex-basis: 20em; + display: flex; + justify-content: center; + align-items: center; + + > img { + max-height: 100%; + max-width: 100%; + object-fit: contain; + + @media (max-width: 960px) { + max-width: 300px; + width: 100%; + object-fit: contain; + } + } + } + + > .user_profile_pictures_thumbnails { + padding: 20px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + gap: 20px; + flex-grow: 1; + + @media (max-width: 960px) { + flex-direction: row; + height: 50%; + } + + > img { + max-height: calc(100% / 3); + width: 100%; + object-fit: contain; + + @media (max-width: 960px) { + max-height: 100%; + max-width: calc(100% / 3) !important; + height: auto; + } + } + } + } +} + +.form-gifts { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; + gap: 10px; + + @media (max-width: 960px) { + flex-direction: column; + } + + >select, + >input { + min-width: 300px; + max-width: 100%; + height: 40px; + + @media (max-width: 960px) { + width: 100%; + } + } +} \ No newline at end of file diff --git a/core/static/user/user_edit.scss b/core/static/user/user_edit.scss new file mode 100644 index 00000000..fdba806e --- /dev/null +++ b/core/static/user/user_edit.scss @@ -0,0 +1,193 @@ + +@media (max-width: 750px) { + .title { + text-align: center; + } +} + +.field-error { + height: auto !important; + + > ul { + list-style-type: none; + margin: 0; + color: indianred; + + > li { + text-align: left !important; + line-height: normal; + margin-top: 5px; + } + } +} + +.profile { + &-visible { + display: flex; + justify-content: center; + align-items: center; + gap: 5px; + padding-top: 10px; + } + + &-pictures { + box-sizing: border-box; + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + gap: 40px; + align-items: stretch; + + @media (max-width: 750px) { + flex-direction: column; + gap: 10px + } + } + + &-picture { + box-sizing: border-box; + display: flex; + justify-content: space-between; + flex-direction: column; + align-items: center; + flex-wrap: wrap; + gap: 20px; + width: 100%; + height: 100%; + max-width: 300px; + + @media (max-width: 750px) { + max-width: 100%; + padding: 10px 10px 0; + } + + &-display { + display: flex; + flex-direction: column; + justify-content: center; + height: 300px; + gap: 10px; + + @media (max-width: 750px) { + height: auto; + } + + >img { + width: 100% !important; + object-fit: contain; + height: auto; + } + + >p { + text-align: left !important; + width: 100% !important; + } + } + + &-edit { + display: flex; + flex-direction: column-reverse; + align-items: center; + justify-content: center; + width: 100%; + + > a { + margin-bottom: 15px; + } + + > input { + font-size: .8em; + font-weight: normal; + cursor: pointer; + } + + > p { + margin-bottom: 0; + text-align: left !important; + min-height: 50px; + } + } + } + + &-fields { + padding: 10px 10px 0; + display: flex; + flex-direction: row; + flex-wrap: wrap; + gap: 10px; + justify-content: center; + } + + &-field { + display: flex; + flex-direction: row; + align-items: center; + flex-wrap: wrap; + justify-content: center; + gap: 10px; + width: 100%; + max-width: 330px; + min-width: 300px; + + @media (max-width: 750px) { + gap: 4px; + max-width: 100%; + } + + >* { + width: 100%; + max-width: 300px; + + @media (max-width: 750px) { + max-width: 100%; + } + } + + &-label { + text-align: left !important; + } + + &-content { + + >* { + box-sizing: border-box; + text-align: left !important; + line-height: 40px; + max-width: 100%; + width: 100%; + height: 40px; + margin: 0; + + >* { + text-align: left !important; + } + } + + + >textarea { + height: 120px; + min-height: 40px; + min-width: 300px; + max-width: 300px; + line-height: initial; + + @media (max-width: 750px) { + max-width: 100%; + } + } + + >input[type="file"] { + font-size: small; + line-height: 30px; + } + + >input[type="checkbox"] { + width: 20px; + height: 20px; + margin: 0; + float: left; + } + } + } +} \ No newline at end of file diff --git a/core/static/user/user_godfathers.scss b/core/static/user/user_godfathers.scss new file mode 100644 index 00000000..e600ec1b --- /dev/null +++ b/core/static/user/user_godfathers.scss @@ -0,0 +1,113 @@ +.container { + display: flex; + flex-direction: column; + gap: 10px; + padding: 10px; + box-sizing: border-box; + + > form { + margin: 0; + } +} + +.users { + display: flex; + flex-direction: row; + flex-wrap: wrap; + list-style-type: none; + margin: 0; + gap: 10px +} + +.users-card { + display: flex; + flex-direction: column; + gap: 10px; + width: 150px; + padding: 10px; + background-color: rgba(0, 0, 0, .05); + border-radius: 10px; + + @media (max-width: 375px) { + width: 100%; + } + + // Django moment + > div.mini_profile_link { + position: relative; + + > a { + &.mini_profile_link { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + gap: 10px; + + @media (max-width: 375px) { + flex-direction: row; + justify-content: flex-start; + align-items: flex-start; + max-height: 65px; + } + + > span { + height: 150px; + width: 100%; + + @media (max-width: 375px) { + height: 80px; + width: 80px; + } + + > img { + width: 100%; + max-width: 100%; + max-height: 100%; + height: auto; + object-fit: contain; + + @media (max-width: 375px) { + max-width: 100%; + max-height: 80px; + } + } + } + + > em { + box-sizing: border-box; + padding: 0 5px; + text-align: center; + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; + + @media (max-width: 375px) { + margin-top: 10px; + text-align: left; + max-width: none; + width: 100%; + } + } + } + + &:last-of-type { + margin-top: 10px; + display: block; + text-align: center; + color: orangered; + + @media (max-width: 375px) { + position: absolute; + bottom: 0%; + right: 0; + } + } + } + } + + // Django moment + > a.mini_profile_link { + display: none; + } +} \ No newline at end of file diff --git a/core/static/user/user_group.scss b/core/static/user/user_group.scss new file mode 100644 index 00000000..5c110c4b --- /dev/null +++ b/core/static/user/user_group.scss @@ -0,0 +1,12 @@ +#id_groups { + margin: 0; + + >li { + list-style-type: none; + padding-left: 20px; + + >label { + cursor: pointer; + } + } +} \ No newline at end of file diff --git a/core/static/user/user_preferences.scss b/core/static/user/user_preferences.scss new file mode 100644 index 00000000..c61142d0 --- /dev/null +++ b/core/static/user/user_preferences.scss @@ -0,0 +1,58 @@ +.form { + display: flex; + flex-direction: column; + margin: 10px 0; + gap: 5px; + + &-general { + > p { + display: flex; + flex-direction: row-reverse; + justify-content: left; + align-items: center; + gap: 5px; + margin: 0; + + > label { + cursor: pointer; + margin: 0; + } + } + } + + &-cards, + &-trombi { + >p { + display: flex; + flex-direction: column; + align-items: flex-start; + text-align: justify; + gap: 5px; + margin: 0; + + >input, + >select { + min-width: 300px; + } + } + } + + &-submit-btn { + margin-top: 10px !important; + max-width: 100px; + } +} + +.justify { + text-align: justify; +} + +.main { + padding: 10px; +} + +.no-cards, +.student-cards { + margin-top: 10px; + display: block; +} diff --git a/core/static/user/user_stats.scss b/core/static/user/user_stats.scss new file mode 100644 index 00000000..62edec5c --- /dev/null +++ b/core/static/user/user_stats.scss @@ -0,0 +1,48 @@ +.container { + padding: 10px; + display: flex; + flex-direction: column; + gap: 10px; +} + +.row { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: flex-start; + align-items: center; + margin-bottom: 10px; + gap: 30px; + + @media (max-width: 535px) { + gap: 20px; + + >div, + >div>.flexed { + width: 100%; + align-items: stretch; + } + } +} + + +.flexed { + display: flex; + flex-direction: column; + gap: 2px; + align-items: self-start; + + >div { + display: flex; + justify-content: space-between; + + >b, + >span { + width: 120px; + + &:last-child { + text-align: right; + } + } + } +} \ No newline at end of file diff --git a/core/static/user/user_tools.scss b/core/static/user/user_tools.scss new file mode 100644 index 00000000..fb10c042 --- /dev/null +++ b/core/static/user/user_tools.scss @@ -0,0 +1,41 @@ +main { + box-sizing: border-box; + padding: 10px; +} + +.container { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + gap: 10px; + + > div { + border-radius: 10px; + background-color: rgba(0, 0, 0, .05); + width: 210px; + + >h4 { + text-align: center; + } + + >ul { + list-style-type: none; + margin: 20px 10px; + display: flex; + flex-direction: column; + gap: 10px; + } + } + + @media (max-width: 550px) { + >div { + width: 100%; + background-color: transparent; + + >h4 { + text-align: left; + } + } + } +} \ No newline at end of file diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index e343f2a1..51e2d5da 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -2,27 +2,32 @@ {% block head %} - {% block title %}{% trans %}Welcome!{% endtrans %}{% endblock %} - Association des Étudiants UTBM - - - - - - - {% block jquery_css %} - {# Thile file is quite heavy (around 250kb), so declaring it in a block allows easy removal #} - - {% endblock %} - - - + {% block title %}{% trans %}Welcome!{% endtrans %}{% endblock %} - Association des Étudiants UTBM + + + + + + + + - - - - - {% block additional_css %}{% endblock %} - {% block additional_js %}{% endblock %} + {% block jquery_css %} + {# Thile file is quite heavy (around 250kb), so declaring it in a block allows easy removal #} + + {% endblock %} + + + + + + + + + + + {% block additional_css %}{% endblock %} + {% block additional_js %}{% endblock %} {% endblock %} @@ -33,197 +38,210 @@ {% csrf_token %} {% block header %} - {% if not popup %} -
-
- {% for language in LANGUAGES %} -
{% csrf_token %} - - - -
- {% endfor %} -
- - {% if not user.is_authenticated %} - + {% if not popup %} +
+ + {% if not user.is_authenticated %} + + {% else %} +
+
+ + +
+ +
+ {% endif %} +
+ {% for language in LANGUAGES %} +
+ {% csrf_token %} + + + +
+ {% endfor %} +
+
+ + {% block info_boxes %} +
+ {% set sith = get_sith() %} + {% if sith.alert_msg %} +
+ {{ sith.alert_msg|markdown }} +
+ {% endif %} + {% if sith.info_msg %} +
+ {{ sith.info_msg|markdown }} +
+ {% endif %} +
+ {% endblock %} + {% else %} -
- - {% endcache %} - - -
+
{{ user.get_display_name() }}
{% endif %} -
- -
- {% block info_boxes %} - {% set sith = get_sith() %} - {% if sith.alert_msg %} -
- {{ sith.alert_msg|markdown }} -
- {% endif %} - {% if sith.info_msg %} -
- {{ sith.info_msg|markdown }} -
- {% endif %} - {% endblock %} -
- - {% else %}{# if not popup #} -
{{ user.get_display_name() }}
- {% endif %} - {% endblock %} + {% block nav %} + {% if not popup %} + + {% endif %} + {% endblock %} +
- {% block nav %} - {% if not popup %} - - {% endif %} - {% endblock %}
    {% for n in quick_notifs %} @@ -232,20 +250,15 @@
- {% if list_of_tabs %} -
-
{{ tabs_title }}
-
- {% for t in list_of_tabs -%} - {{ t.name }} - {%- endfor %} -
-
- {% endif %} + {% if list_of_tabs %} +
+
+ {% for t in list_of_tabs -%} + {{ t.name }} + {%- endfor %} +
+
+ {% endif %} {% if error %} {{ error }} @@ -256,18 +269,24 @@
{% if not popup %} - + {% endif %} -
-

{{ profile.get_full_name() }}

+
+

{{ profile.get_full_name() }}

{% if profile.nick_name %} -
« {{ profile.nick_name }} »
+ {% endif %} +
- - - {% if profile.quote %} -
+
+ {% else %} - {% trans %}No gift given yet{% endtrans %} + {% trans %}No gift given yet{% endtrans %} {% endif %}
{% endif %} @@ -228,33 +237,33 @@ {% block script %} {{ super() }} -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/core/templates/core/user_edit.jinja b/core/templates/core/user_edit.jinja index 5bd692e9..35295226 100644 --- a/core/templates/core/user_edit.jinja +++ b/core/templates/core/user_edit.jinja @@ -1,86 +1,184 @@ -{% extends "core/base.jinja" %} +{%- extends "core/base.jinja" -%} -{% block title %} -{% trans %}Edit user{% endtrans %} -{% endblock %} +{%- block title -%} +{%- trans -%}Edit user{%- endtrans -%} +{%- endblock -%} -{% block content %} -

{% trans %}Edit user profile{% endtrans %}

+{%- block additional_css -%} + +{%- endblock -%} + +{%- block content -%} +

{%- trans -%}Edit user profile{%- endtrans -%}

- {% csrf_token %} + + {%- csrf_token -%} {{ form.non_field_errors() }} - {% for field in form %} -

{{ field.errors }}

-
- {% trans %}Take picture{% endtrans %} + + {# User Pictures #} +
+
+
+ + {%- if form.instance.profile_pict -%} + {%- trans -%}Profile{%- endtrans -%} + {%- else -%} + {%- trans -%}Profile{%- endtrans -%} + {%- endif -%} +
+
+

{{ form["profile_pict"].label }}

+ {{ form["profile_pict"] }} + {%- if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) and form.instance.profile_pict.id -%} + + {%- trans -%}Delete{%- endtrans -%} + + {%- endif -%} +
+
+
+
+ {%- if form.instance.avatar_pict -%} + {%- trans -%}Profile{%- endtrans -%} + {%- else -%} + {%- trans -%}Profile{%- endtrans -%} + {%- endif -%} +
+
+

{{ form["avatar_pict"].label }}

+ {{ form["avatar_pict"] }} + {%- if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) and form.instance.avatar_pict.id -%} + + {%- trans -%}Delete{%- endtrans -%} + + {%- endif -%} +
+
+
+
+ {%- if form.instance.scrub_pict -%} + {%- trans -%}Profile{%- endtrans -%} + {%- else -%} + {%- trans -%}Profile{%- endtrans -%} + {%- endif -%} +
+
+

{{ form["scrub_pict"].label }}

+ {{ form["scrub_pict"] }} + {%- if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) and form.instance.scrub_pict.id -%} + + {%- trans -%}Delete{%-endtrans -%} + + {%- endif -%} +
+
+ + + {# All fields #} +
+ {%- for field in form -%} + {%- + if field.name in ["quote","profile_pict","avatar_pict","scrub_pict","is_subscriber_viewable","forum_signature"] + -%} + {%- continue -%} + {%- endif -%} + +
+
{{ field.label }}
+
+ {{ field }} + {%- if field.errors -%} +
{{ field.errors }}
+ {%- endif -%} +
+
+ {%- endfor -%} +
+ + {# Textareas #} +
+ {%- for field in [form["quote"], form["forum_signature"]] -%} +
+
{{ field.label }}
+
+ {{ field }} + {%- if field.errors -%} +
{{ field.errors }}
+ {%- endif -%} +
+
+ {%- endfor -%} +
+ + {# Checkboxes #} +
+ {{ form["is_subscriber_viewable"] }} + {{ form["is_subscriber_viewable"].label }} +
+ + {%- if form.instance == user -%}

- {% endif %}
- {%- elif field.name == "avatar_pict" and form.instance.avatar_pict -%} -
{% trans %}Current avatar: {% endtrans %} -
- {%- elif field.name == "scrub_pict" and form.instance.scrub_pict -%} -
{% trans %}Current scrub: {% endtrans %} -
- {%- endif %} {{ field }}

- {% endfor %} -

-

{% trans %}Username: {% endtrans %}{{ form.instance.username }}

- {% if form.instance.customer %} -

{% trans %}Account number: {% endtrans %}{{ form.instance.customer.account_id }}

- {% endif %} - {% if form.instance == user %} -

{% trans %}Change my password{% endtrans %}

- {% elif user.is_root %} -

{% trans %}Change user password{% endtrans %}

- {% endif %} + {%- trans -%}Change my password{%- endtrans -%} +

+ {%- elif user.is_root -%} +

+ {%- trans -%}Change user password{%- + endtrans -%} +

+ {%- endif -%} + +

+ +

-{% endblock %} - -{% block script %} - {{ super() }} - {% if not form.instance.profile_pict %} - - - {% endif %} -{% endblock %} +

+ {%- trans -%}Username: {%- endtrans -%} {{ form.instance.username }} +
+ {%- if form.instance.customer -%} + {%- trans -%}Account number: {%- endtrans -%} {{ form.instance.customer.account_id }} + {%- endif -%} +

+{%- endblock -%} +{%- block script -%} +{{ super() }} +{%- if not form.instance.profile_pict -%} + + +{%- endif -%} +{%- endblock -%} \ No newline at end of file diff --git a/core/templates/core/user_godfathers.jinja b/core/templates/core/user_godfathers.jinja index 9a01be43..c5f48dfd 100644 --- a/core/templates/core/user_godfathers.jinja +++ b/core/templates/core/user_godfathers.jinja @@ -1,45 +1,67 @@ {% extends "core/base.jinja" %} {% from "core/macros.jinja" import user_link_with_pict, delete_godfather %} +{%- block additional_css -%} + +{%- endblock -%} + {% block title %} {% trans user_name=profile.get_display_name() %}{{ user_name }}'s family{% endtrans %} {% endblock %} {% block content %} -

- {% trans %}Show family picture{% endtrans %}

+
+ + {% trans %}Show family picture{% endtrans %} + + +

{% trans %}Godfathers / Godmothers{% endtrans %}

{% if profile.godfathers.exists() %} -

{% trans %}Godfathers / Godmothers{% endtrans %}

-
{% endblock %} diff --git a/core/templates/core/user_group.jinja b/core/templates/core/user_group.jinja index b062cafb..3becceb8 100644 --- a/core/templates/core/user_group.jinja +++ b/core/templates/core/user_group.jinja @@ -1,14 +1,16 @@ {% extends "core/base.jinja" %} +{%- block additional_css -%} + +{%- endblock -%} + {% block content %} -

{% trans user_name=profile.get_full_name() %}Edit user groups for {{ user_name }}{% endtrans %}

-
- {% csrf_token %} - {{ form.as_p() }} -

-
-{% endblock %} - - - - +
+

{% trans user_name=profile.get_full_name() %}Edit user groups for {{ user_name }}{% endtrans %}

+
+ {% csrf_token %} + {{ form.as_p() }} +

+
+
+{%- endblock -%} \ No newline at end of file diff --git a/core/templates/core/user_pictures.jinja b/core/templates/core/user_pictures.jinja index 2d4e26a0..ba98fc95 100644 --- a/core/templates/core/user_pictures.jinja +++ b/core/templates/core/user_pictures.jinja @@ -1,26 +1,48 @@ {% extends "core/base.jinja" %} +{%- block additional_css -%} + +{%- endblock -%} + {% block title %} {% trans user_name=profile.get_display_name() %}{{ user_name }}'s pictures{% endtrans %} {% endblock %} {% block content %} +
{% if can_edit(profile, user) %} {% endif %} -{% for a in albums %} -
+ {% for a in albums %}

{{ a.name }}

-
- {% for picture in pictures[a.id] %} -
- - {{ picture.get_display_name() }} - +
+ {% for p in pictures[a.id] %} + {% if p.can_be_viewed_by(user) %} + +
+ {% if not p.is_moderated %} +
 
+
{% trans %}To be moderated{% endtrans %}
+ {% else %} +
 
+ {% endif %} +
+
+ {% else %} +
+
+
{% trans %}Picture Unavailable{% endtrans %}
+
+
+ {% endif %} + {% endfor %}
+
{% endfor %} -
-{% endfor %} +
{% endblock %} {% block script %} diff --git a/core/templates/core/user_preferences.jinja b/core/templates/core/user_preferences.jinja index 97416f47..58708635 100644 --- a/core/templates/core/user_preferences.jinja +++ b/core/templates/core/user_preferences.jinja @@ -1,46 +1,69 @@ {% extends "core/base.jinja" %} +{%- block additional_css -%} + +{%- endblock -%} + {% block title %} {% trans %}Preferences{% endtrans %} {% endblock %} {% block content %} -

{% trans %}Preferences{% endtrans %}

-
- {% csrf_token %} - {{ form.as_p() }} -

-
-

{% trans %}Trombi{% endtrans %}

-{% if trombi_form %} -
- {% csrf_token %} - {{ trombi_form.as_p() }} -

-
-{% else %} -

{% trans trombi=user.trombi_user.trombi %}You already choose to be in that Trombi: {{ trombi }}.{% endtrans %} -{% trans %}Go to my Trombi tools{% endtrans %}

-{% endif %} -{% if profile.customer %} -

{% trans %}Student cards{% endtrans %}

-

{% trans %}You can add a card by asking at a counter or add it yourself here. If you want to manually add a student card yourself, you'll need a NFC reader. We store the UID of the card which is 14 characters long.{% endtrans %}

-
- {% csrf_token %} - {{ student_card_form.as_p() }} -

-
-{% if profile.customer.student_cards.exists() %} - -{% else %} -

{% trans %}No student cards registered.{% endtrans %}

-{% endif %} -{% endif %} -{% endblock %} +
+

{% trans %}Preferences{% endtrans %}

+

{% trans %}General{% endtrans %}

+
+ {% csrf_token %} + {{ form.as_p() }} + +
+ +

{% trans %}Trombi{% endtrans %}

+ + {% if trombi_form %} +
+ {% csrf_token %} + {{ trombi_form.as_p() }} + +
+ + {% else %} +

{% trans trombi=user.trombi_user.trombi %}You already choose to be in that Trombi: {{ trombi }}.{% endtrans %} +
+ {% trans %}Go to my Trombi tools{% endtrans %} +

+ {% endif %} + {% if profile.customer %} +

{% trans %}Student cards{% endtrans %}

+ {% if profile.customer.student_cards.exists() %} + + {% else %} + {% trans %}No student card registered.{% endtrans %} +

+ {% trans %}You can add a card by asking at a counter or add it yourself here. If you want to manually + add a student card yourself, you'll need a NFC reader. We store the UID of the card which is 14 characters long.{% endtrans %} +

+ {% endif %} + +
+ {% csrf_token %} + {{ student_card_form.as_p() }} + +
+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/core/templates/core/user_stats.jinja b/core/templates/core/user_stats.jinja index a481ca99..be7c44cc 100644 --- a/core/templates/core/user_stats.jinja +++ b/core/templates/core/user_stats.jinja @@ -1,25 +1,41 @@ {% extends "core/base.jinja" %} +{%- block additional_css -%} + +{%- endblock -%} + {% block title %} {% trans user_name=profile.get_display_name() %}{{ user_name }}'s stats{% endtrans %} {% endblock %} {% block content %} +
+
{% if profile.permanencies %} -

{% trans %}Permanencies{% endtrans %}

-

Total: {{ total_perm_time }}

-

Foyer: {{ total_foyer_time }}

-

MDE: {{ total_mde_time }}

-

La Gommette: {{ total_gommette_time }}

+

{% trans %}Permanencies{% endtrans %}

+
+
Foyer :{{ total_foyer_time }}
+
Gommette :{{ total_gommette_time }}
+
MDE :{{ total_mde_time }}
+
Total :{{ total_perm_time }}
+
{% endif %} -

{% trans %}Buyings{% endtrans %}

+
-

Foyer: {{ total_foyer_buyings }} €

-

MDE: {{ total_mde_buyings }} €

-

La Gommette: {{ total_gommette_buyings }} €

+

{% trans %}Buyings{% endtrans %}

+
+
Foyer :{{ total_foyer_buyings }} €
+
Gommette :{{ total_gommette_buyings }} €
+
MDE :{{ total_mde_buyings }} €
+
Total :{{ total_foyer_buyings + total_gommette_buyings + total_mde_buyings }} € +
+
+
+ +

{% trans %}Product top 10{% endtrans %}

@@ -29,14 +45,14 @@ - {% for p in top_product %} + {% for p in top_product %} - {% endfor %} + {% endfor %}
{{ p['product__name'] }} {{ p['product_sum'] }}
-{% endblock %} - - +
+
+{% endblock %} \ No newline at end of file diff --git a/core/templates/core/user_tools.jinja b/core/templates/core/user_tools.jinja index 4804f016..b0fb9b8e 100644 --- a/core/templates/core/user_tools.jinja +++ b/core/templates/core/user_tools.jinja @@ -1,137 +1,176 @@ {% extends "core/base.jinja" %} +{%- block additional_css -%} + +{%- endblock -%} + {% block title %} {% trans user_name=user.get_display_name() %}{{ user_name }}'s tools{% endtrans %} {% endblock %} {% block content %} -

{% trans %}User Tools{% endtrans %}

+
+

{% trans %}User Tools{% endtrans %}

-
-

{% trans %}Sith management{% endtrans %}

- - -
-

{% trans %}Counters{% endtrans %}

- -
-

{% trans %}Accounting{% endtrans %}

- + {% set is_admin_on_a_counter = false %} + {% for b in settings.SITH_COUNTER_BARS if user.is_in_group(b[1] + " admin") %} + {% set is_admin_on_a_counter = true %} + {% endfor %} -
-

{% trans %}Communication{% endtrans %}

- + {% if + user.is_in_group(settings.SITH_GROUP_COUNTER_ADMIN_ID) or user.is_root + or is_admin_on_a_counter + %} +
+

{% trans %}Counters{% endtrans %}

+ +
+ {% endif %} + {% if + user.is_in_group(settings.SITH_GROUP_ACCOUNTING_ADMIN_ID) or user.is_root + or user.memberships.filter(end_date=None).filter(role__gte=7).all() | length > 10 + %} +
+

{% trans %}Accounting{% endtrans %}

+ +
+ {% endif %} -
-

{% trans %}Elections{% endtrans %}

- + {% if user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) or user.is_root %} + + {% endif %} -
-

{% trans %}Other tools{% endtrans %}

- - -{% endblock %} + {% if user.memberships.filter(end_date=None).all().count() > 0 %} +
+

{% trans %}Club tools{% endtrans %}

+
    + {% for m in user.memberships.filter(end_date=None).all() %} +
  • {{ m.club }}
  • + {% endfor %} +
+
+ {% endif %} + {% if user.is_in_group(settings.SITH_GROUP_PEDAGOGY_ADMIN_ID) or user.is_root %} + + {% endif %} +
+

{% trans %}Elections{% endtrans %}

+ +
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/core/tests.py b/core/tests.py index ddb9f03d..fd44ae24 100644 --- a/core/tests.py +++ b/core/tests.py @@ -272,7 +272,7 @@ class UserRegistrationTest(TestCase): ) self.assertTrue(response.status_code == 200) self.assertTrue( - """

Votre nom d\\'utilisateur et votre mot de passe ne correspondent pas. Merci de r\\xc3\\xa9essayer.

""" + """

Votre nom d\\'utilisateur et votre mot de passe ne correspondent pas. Merci de r\\xc3\\xa9essayer.

""" in str(response.content) ) diff --git a/core/utils.py b/core/utils.py index 0c5fa10c..37ff611e 100644 --- a/core/utils.py +++ b/core/utils.py @@ -22,6 +22,7 @@ # # +import subprocess import re # Image utils @@ -37,6 +38,17 @@ from django.conf import settings from django.core.files.base import ContentFile +def get_git_revision_short_hash() -> str: + """ + Return the short hash of the current commit + """ + return ( + subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) + .decode("ascii") + .strip() + ) + + def get_start_of_semester(d=date.today()): """ This function computes the start date of the semester with respect to the given date (default is today), diff --git a/core/views/forms.py b/core/views/forms.py index 9359cd28..936abb26 100644 --- a/core/views/forms.py +++ b/core/views/forms.py @@ -250,6 +250,7 @@ class UserProfileForm(forms.ModelForm): "scrub_pict": forms.ClearableFileInput, "phone": PhoneNumberInternationalFallbackWidget, "parent_phone": PhoneNumberInternationalFallbackWidget, + "quote": forms.Textarea, } labels = { "profile_pict": _( diff --git a/counter/templates/counter/activity.jinja b/counter/templates/counter/activity.jinja index 08e405ff..701dbc05 100644 --- a/counter/templates/counter/activity.jinja +++ b/counter/templates/counter/activity.jinja @@ -5,23 +5,41 @@ {% trans counter_name=counter %}{{ counter_name }} activity{% endtrans %} {% endblock %} -{% block content %} -

{% trans counter_name=counter %}{{ counter_name }} activity{% endtrans %}

- {% if counter.type == 'BAR' %} -

{% trans %}Barmen list{% endtrans %}

-
    - {% for b in counter.get_barmen_list() %} -
  • {{ user_profile_link(b) }}
  • - {% endfor %} -
- {% endif %} +{%- block additional_css -%} + +{%- endblock -%} -
{% trans %}Legend{% endtrans %}
- : {% trans %}counter is open, there's at least one barman connected{% endtrans %} -
- ? : {% trans minutes=settings.SITH_COUNTER_MINUTE_INACTIVE %}counter is open but not active, the last sale was done at least {{ minutes }} minutes ago {% endtrans %} -
- : {% trans %}counter is not open : no one is connected{% endtrans %} +{% block content %} +

{% trans counter_name=counter %}{{ counter_name }} activity{% endtrans %}

+ {% if counter.type == 'BAR' %} +

{% trans %}Barmen list{% endtrans %}

+
    + {% set barmans_list = counter.get_barmen_list() %} + {% if barmans_list | length > 0 %} + {% for b in barmans_list %} +
  • {{ user_profile_link(b) }}
  • + {% endfor %} + {% else %} + {% trans %}There is currently no barman connected.{% endtrans %} + {% endif %} +
+ {% endif %} + +
{% trans %}Legend{% endtrans %}
+
+
+ + {% trans %}counter is open, there's at least one barman connected{% endtrans %} +
+
+ + {% trans minutes=settings.SITH_COUNTER_MINUTE_INACTIVE %}counter is open but not active, the last sale was done at least {{ minutes }} minutes ago {% endtrans %} +
+
+ + {% trans %}counter is not open : no one is connected{% endtrans %} +
+
{% endblock %} diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 977437bc..04f0ff27 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -1641,6 +1641,10 @@ msgstr "Appels affichés" msgid "Calls to moderate" msgstr "Appels à modérer" +#: core/templates/core/base.jinja +msgid "Site version:" +msgstr "Version du site :" + #: com/templates/com/news_admin_list.jinja:242 #: core/templates/core/base.jinja:183 msgid "Events" @@ -2211,8 +2215,8 @@ msgid "Visitor" msgstr "Visiteur" #: core/models.py:787 -msgid "do you want to receive the weekmail" -msgstr "voulez-vous recevoir le Weekmail" +msgid "receive the Weekmail" +msgstr "recevoir le Weekmail" #: core/models.py:789 msgid "show your stats to others" @@ -2220,11 +2224,11 @@ msgstr "montrez vos statistiques aux autres" #: core/models.py:791 msgid "get a notification for every click" -msgstr "recevez une notification pour chaque click" +msgstr "avoir une notification pour chaque click" #: core/models.py:794 msgid "get a notification for every refilling" -msgstr "recevez une notification pour chaque rechargement" +msgstr "avoir une notification pour chaque rechargement" #: core/models.py:817 msgid "file name" @@ -2399,7 +2403,7 @@ msgstr "Connexion" #: core/templates/core/base.jinja:62 core/templates/core/register.jinja:18 msgid "Register" -msgstr "S'enregister" +msgstr "Inscription" #: core/templates/core/base.jinja:91 core/templates/core/base.jinja:92 #: forum/templates/forum/macros.jinja:171 @@ -2559,9 +2563,9 @@ msgstr "Aide & Documentation" msgid "R&D" msgstr "R&D" -#: core/templates/core/base.jinja:268 -msgid "Site made by good people" -msgstr "Site réalisé par des gens bons" +#: core/templates/core/base.jinja:262 +msgid "Site created by the IT Department of the AE" +msgstr "Site réalisé par le Pôle Informatique de l'AE" #: core/templates/core/create.jinja:4 core/templates/core/create.jinja:8 #, python-format @@ -2641,6 +2645,11 @@ msgstr "Coller" msgid "Clipboard: " msgstr "Presse-papier : " +#: sas/templates/sas/album.jinja:69 +#: sas/templates/sas/album.jinja:97 +msgid "To be moderated" +msgstr "A modérer" + #: core/templates/core/file_detail.jinja:53 msgid "Real name: " msgstr "Nom réel : " @@ -3323,6 +3332,10 @@ msgstr "Télécharger toutes mes photos" msgid "Error downloading your pictures" msgstr "Erreur de téléchargement de vos photos" +#: core/templates/core/user_picture.jinja: +msgid "Picture Unavailable" +msgstr "Photo Indisponible" + #: core/templates/core/user_preferences.jinja:4 #: core/templates/core/user_preferences.jinja:8 core/views/user.py:234 msgid "Preferences" @@ -3357,8 +3370,8 @@ msgstr "" "14 caractères de long." #: core/templates/core/user_preferences.jinja:40 -msgid "No student cards registered." -msgstr "Aucune cartes étudiante enregistré." +msgid "No student card registered." +msgstr "Aucune carte étudiante enregistrée." #: core/templates/core/user_stats.jinja:4 #, python-format @@ -3981,6 +3994,10 @@ msgstr "Activité sur %(counter_name)s" msgid "Barmen list" msgstr "Barmans" +#: counter/templates/counter/activity.jinja:23 +msgid "There is currently no barman connected." +msgstr "Il n'y a actuellement aucun barman connecté." + #: counter/templates/counter/activity.jinja:19 msgid "Legend" msgstr "Légende" @@ -5328,12 +5345,20 @@ msgstr "photo" msgid "SAS" msgstr "SAS" +#: sas/templates/sas/album.jinja:102 +msgid "This album does not contain any photos." +msgstr "Cet album ne contient aucune photo." + #: sas/templates/sas/album.jinja:53 sas/templates/sas/album.jinja:55 #: sas/templates/sas/main.jinja:13 sas/templates/sas/main.jinja:15 #: sas/templates/sas/main.jinja:17 msgid "preview" msgstr "miniature" +#: sas/templates/sas/main.jinja:42 +msgid "You must be logged in to see the SAS." +msgstr "Vous devez être connecté pour voir les photos." + #: sas/templates/sas/album.jinja:89 msgid "Upload" msgstr "Envoyer" @@ -5752,6 +5777,12 @@ msgstr "Vous avez acheté %s" msgid "You have a notification" msgstr "Vous avez une notification" +#: core/templates/core/base.jinja +msgid "You do not have any unread notification" +msgstr "Vous n'avez aucune notification non lue" + +#: sith/settings.py:624 +#: sith/settings.py:648 #: sith/settings.py:650 msgid "Success!" msgstr "Succès !" diff --git a/sas/models.py b/sas/models.py index db82aef3..c66c6498 100644 --- a/sas/models.py +++ b/sas/models.py @@ -69,7 +69,6 @@ class Picture(SithFile): im = Image.open(BytesIO(f.read())) (w, h) = im.size return (w / h) < 1 - return False def can_be_edited_by(self, user): return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) @@ -79,11 +78,20 @@ class Picture(SithFile): # Result is cached 4s for this user if user.is_anonymous: return False + perm = cache.get("%d_can_view_pictures" % (user.id), False) - if perm: + + # use cache only when user is in SAS Admins or when picture is moderated + if perm and (self.is_moderated or self.can_be_edited_by(user)): return perm - perm = self.is_in_sas and self.is_moderated and user.was_subscribed + + perm = ( + self.is_in_sas + and (self.is_moderated or self.can_be_edited_by(user)) + and user.was_subscribed + ) cache.set("%d_can_view_pictures" % (user.id), perm, timeout=4) + return perm def get_download_url(self): diff --git a/sas/templates/sas/album.jinja b/sas/templates/sas/album.jinja index 6958adc6..16ae6d29 100644 --- a/sas/templates/sas/album.jinja +++ b/sas/templates/sas/album.jinja @@ -1,202 +1,248 @@ {% extends "core/base.jinja" %} {% from "core/macros.jinja" import paginate %} +{%- block additional_css -%} + +{%- endblock -%} + {% block title %} -{% trans %}SAS{% endtrans %} + {% trans %}SAS{% endtrans %} {% endblock %} {% macro print_path(file) %} -{% if file and file.parent %} -{{ print_path(file.parent) }} -{{ file.get_display_name() }} > -{% endif %} + {% if file and file.parent %} + {{ print_path(file.parent) }} + {{ file.get_display_name() }} / + {% endif %} {% endmacro %} {% block content %} -SAS > {{ print_path(album.parent) }} {{ album.get_display_name() }} -

{{ album.get_display_name() }}

-{% trans %}Edit{% endtrans %}
-{% set start = timezone.now() %} -
-{% set edit_mode = user.can_edit(album) %} -{% if edit_mode %} -
- {% csrf_token %} -

- | - | - | - -

- {% if clipboard %} -

{% trans %}Clipboard: {% endtrans %} -

    - {% for f in clipboard %} -
  • {{ f.get_full_path() }}
  • - {% endfor %} -
-

- {% endif %} -{% endif %} -
- {% for a in album.children_albums.order_by('-date') %} -
- {% if edit_mode %} - - {% endif %} - {% if user.can_view(a) %} - -
-
- {% if a.file %} - {% trans %}preview{% endtrans %} - {% else %} - {% trans %}preview{% endtrans %} - {% endif %} + + SAS / {{ print_path(album.parent) }} {{ album.get_display_name() }} + + + {% set edit_mode = user.can_edit(album) %} + {% set start = timezone.now() %} + + {% if edit_mode %} + + {% csrf_token %} + + - {{ a.name }} + + {% if clipboard %} +
+ {% trans %}Clipboard: {% endtrans %} +
    + {% for f in clipboard %} +
  • {{ f.get_full_path() }}
  • + {% endfor %} +
+ +
+ {% endif %} + {% endif %} + + {% if album.children_albums.count() > 0 %} +

{% trans %}Albums{% endtrans %}

+
+ {% for a in album.children_albums.order_by('-date') %} + {% if a.can_be_viewed_by(user) %} + +
+ {% if not a.is_moderated %} +
 
+
{% trans %}To be moderated{% endtrans %}
+ {% else %} +
{{ a.name }}
+ {% endif %} +
+ {% if edit_mode %} + + {% endif %} +
+ {% endif %} + {% endfor %}
- - {% endif %} + +
+ {% endif %} + +

{% trans %}Pictures{% endtrans %}

+ {% if pictures | length != 0 %} + - {% endfor %} -
-
- {% for p in pictures %} -
- {% if edit_mode %} - - {% endif %} - {% if user.can_view(p) %} -
- - {{ p.get_display_name() }} - + {% else %} + {% trans %}This album does not contain any photos.{% endtrans %} + {% endif %} + + {% if pictures.has_previous() or pictures.has_next() %} +
+ {{ paginate(pictures, paginator) }}
- {% endif %} -
- {% endfor %} -
-
- {{ paginate(pictures, paginator) }} -{% if edit_mode %} - -{% endif %} -
- {% csrf_token %} - {{ form.as_p() }} -

-
-

{% trans %}Template generation time: {% endtrans %} -{{ timezone.now() - start }} -

+ {% endif %} + + {% if edit_mode %} + + {% endif %} + + {% if user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %} +
+ {% csrf_token %} +
+ {{ form.as_p() }} + + +
+
+ {% endif %} + +
+ +

{% trans %}Template generation time: {% endtrans %} + {{ timezone.now() - start }} +

{% endblock %} {% block script %} -{{ super() }} - + while(errorList.childElementCount > 0) + errorList.removeChild(errorList.firstElementChild); + + let progress; + if((progress = this.querySelector('progress')) === null) { + progress = document.createElement('progress'); + progress.value = 0; + let p = document.createElement('p'); + p.appendChild(progress); + this.insertBefore(p, this.lastElementChild); + } + + let dataHolder; + + if(formData.get('album_name')) { + dataHolder = new FormData(); + dataHolder.set('csrfmiddlewaretoken', '{{ csrf_token }}'); + dataHolder.set('album_name', formData.get('album_name')); + $.ajax({ + method: 'POST', + url: "{{ url('sas:album_upload', album_id=object.id) }}", + data: dataHolder, + processData: false, + contentType: false, + success: onSuccess + }); + } + + let images = formData.getAll('images'); + let imagesCount = images.length; + let completeCount = 0; + + let poolSize = 1; + let imagePool = []; + + while(images.length > 0 && imagePool.length < poolSize) { + let image = images.shift(); + imagePool.push(image); + sendImage(image); + } + + function sendImage(image) { + dataHolder = new FormData(); + dataHolder.set('csrfmiddlewaretoken', '{{ csrf_token }}'); + dataHolder.set('images', image); + + $.ajax({ + method: 'POST', + url: "{{ url('sas:album_upload', album_id=object.id) }}", + data: dataHolder, + processData: false, + contentType: false, + }) + .fail(onSuccess.bind(undefined, image)) + .done(onSuccess.bind(undefined, image)) + .always(next.bind(undefined, image)); + } + + function next(image, _, __) { + let index = imagePool.indexOf(image); + let nextImage = images.shift(); + + if(index !== -1) + imagePool.splice(index, 1); + + if(nextImage) { + imagePool.push(nextImage); + sendImage(nextImage); + } + } + + function onSuccess(image, data, _, __) { + let errors = []; + + if ($(data.responseText).find('.errorlist.nonfield')[0]) + errors = Array.from($(data.responseText).find('.errorlist.nonfield')[0].children); + + while(errors.length > 0) + errorList.appendChild(errors.shift()); + + progress.value = ++completeCount / imagesCount; + if(progress.value === 1 && errorList.children.length === 0) + document.location.reload() + } + }); + {% endblock %} diff --git a/sas/templates/sas/main.jinja b/sas/templates/sas/main.jinja index 3982bf47..fb9cd594 100644 --- a/sas/templates/sas/main.jinja +++ b/sas/templates/sas/main.jinja @@ -1,56 +1,110 @@ {% extends "core/base.jinja" %} +{%- block additional_css -%} + +{%- endblock -%} + {% block title %} -{% trans %}SAS{% endtrans %} + {% trans %}SAS{% endtrans %} {% endblock %} -{% macro display_album(a) %} -{% if a.is_moderated %} - -
-
- {% if a.file %} - {% trans %}preview{% endtrans %} - {% elif a.children.filter(is_folder=False, is_moderated=True).exists() %} - {% trans %}preview{% endtrans %} - {% else %} - {% trans %}preview{% endtrans %} - {% endif %} -
- {{ a.name }} -
-
-{% elif user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %} - -{% endif %} +{% set edit_mode = user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %} + +{% macro display_album(a, checkbox) %} + + {% if a.file %} + {% set img = a.get_download_url() %} + {% elif a.children.filter(is_folder=False, is_moderated=True).exists() %} + {% set img = a.children.filter(is_folder=False).first().as_picture.get_download_thumb_url() %} + {% else %} + {% set img = static('core/img/sas.jpg') %} + {% endif %} + +
+
+ {{ a.name }} +
+
+ {# {% if edit_mode and checkbox %} + + {% endif %} #} +
{% endmacro %} {% block content %} -

{% trans %}SAS{% endtrans %}

-
-

{% trans %}Latest albums{% endtrans %}

-
- {% for a in latest %} - {{ display_album(a) }} - {% endfor %} -
-
-

{% trans %}All categories{% endtrans %}

-
- {% for a in categories %} - {{ display_album(a) }} - {% endfor %} -
-{% if user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %} -
- {% csrf_token %} - {{ form.non_field_errors() }} -

{{ form.album_name.errors }} - {{ form.album_name }}

-

-
-{% endif %} +
+

{% trans %}SAS{% endtrans %}

+ + {% if not user.is_authenticated %} +

{% trans %}You must be logged in to see the SAS.{% endtrans %}

+ {% else %} +
+

{% trans %}Latest albums{% endtrans %}

+ +
+ {% for a in latest %} + {{ display_album(a) }} + {% endfor %} +
+ +
+ + {% if edit_mode %} +
+ {% csrf_token %} + + + + {% if clipboard %} +
+ {% trans %}Clipboard: {% endtrans %} +
    + {% for f in clipboard %} +
  • {{ f.get_full_path() }}
  • + {% endfor %} +
+ +
+ {% endif %} + {% else %} +

{% trans %}All categories{% endtrans %}

+ {% endif %} + +
+ {% for a in categories %} + {{ display_album(a, true) }} + {% endfor %} +
+ + {% if edit_mode %} +
+ +
+ +
+ {% csrf_token %} + +
+
+ + {{ form.album_name }} +
+ +
+ + {{ form.non_field_errors() }} + {{ form.album_name.errors }} +
+ {% endif %} + {% endif %} +
{% endblock %} diff --git a/sas/templates/sas/picture.jinja b/sas/templates/sas/picture.jinja index 68253ea4..f04f1112 100644 --- a/sas/templates/sas/picture.jinja +++ b/sas/templates/sas/picture.jinja @@ -1,150 +1,176 @@ {% extends "core/base.jinja" %} -{% block head %} -{{ super() }} - +{%- block additional_css -%} + +{%- endblock -%} -{% if picture.get_previous() %} - -{% endif %} -{% if picture.get_next() %} - -{% endif %} +{% block head %} + {{ super() }} + + {% if picture.get_previous() %} + + {% endif %} + {% if picture.get_next() %} + + {% endif %} {% endblock %} {% block title %} -{% trans %}SAS{% endtrans %} + {% trans %}SAS{% endtrans %} {% endblock %} {% macro print_path(file) %} -{% if file and file.parent %} -{{ print_path(file.parent) }} -{{ file.get_display_name() }} > -{% endif %} + {% if file and file.parent %} + {{ print_path(file.parent) }} + {{ file.get_display_name() }} / + {% endif %} {% endmacro %} {% block content %} -SAS > {{ print_path(picture.parent) }} {{ picture.get_display_name() }} -({{ picture.parent.children.filter(id__lte=picture.id).count() }} / {{ picture.parent.children.count() }}) -

{{ picture.get_display_name() }}

-
-
- - + + SAS / {{ print_path(picture.parent) }} {{ picture.get_display_name() }} + + +
+ +
+

{{ picture.get_display_name() }}

+

{{ picture.parent.children.filter(id__lte=picture.id).count() }} / {{ picture.parent.children.count() }}

-
-
{% trans %}People{% endtrans %}
-
    - {% for r in picture.people.all() %} -
  • - {{ r.user.get_short_name() }} - {% if user == r.user or user.can_edit(picture) %} - {% trans %}Delete{% endtrans %} + + + {% if not picture.is_moderated %} + {% set next = picture.get_next() %} + {% if not next %} + {% set next = url('sas:moderation') %} + {% else %} + {% set next = next.get_absolute_url() + "#pict" %} + {% endif %} + +
    +
    + {% if picture.asked_for_removal %} + {% trans %}Asked for removal{% endtrans %} + {% else %} +   {% endif %} -
  • - {% endfor %} -
-
- {% csrf_token %} - {{ form.as_p() }} -

-
-
-
-
{% trans %}Infos{% endtrans %}
-

{% trans %}Date: {% endtrans %}{{ picture.date|date(DATETIME_FORMAT) }}

-

{% trans %}Owner: {% endtrans %}{{ picture.owner.get_short_name() }}

- {% if picture.moderator %} -

{% trans %}Moderator: {% endtrans %}{{ picture.moderator.get_short_name() }}

- {% endif %} -

{{ picture.parent.children.filter(id__lte=picture.id).count() }} / {{ picture.parent.children.count() }}

-
- -
-{% if picture.is_moderated %} -
-{% else %} -
-{% set next = picture.get_next() %} -{% if not next %} - {% set next = url('sas:moderation') %} -{% else %} - {% set next = next.get_absolute_url() + "#pict" %} -{% endif %} -
- {% if picture.asked_for_removal %} - {% trans %}Asked for removal{% endtrans %} +
+ +
{% endif %} - - {% trans %}Moderate{% endtrans %} | - - {% trans %}Delete{% endtrans %} -
-{% endif %} - {% if picture.is_vertical %} - {{ picture.get_display_name() }} - {% else %} - {{ picture.get_display_name() }} - {% endif %} -
+ +
+
+ +
+ {{ picture.get_display_name() }} +
+ +
+
+
{% trans %}Infos{% endtrans %}
+
+
+ {% trans %}Date: {% endtrans %} + {{ picture.date|date(DATETIME_FORMAT) }} +
+
+ {% trans %}Owner: {% endtrans %} + {{ picture.owner.get_short_name() }} +
+ + {% if picture.moderator %} +
+ {% trans %}Moderator: {% endtrans %} + {{ picture.moderator.get_short_name() }} +
+ {% endif %} +
+
+ +
+
{% trans %}Tools{% endtrans %}
+ +
+
+
+ +
+ + +
+
{% trans %}People{% endtrans %}
+
+ {% csrf_token %} + {{ form.as_p() }} + +
+ +
+
+
{% endblock %} {% block script %} -{{ super() }} - + {% endblock %} diff --git a/sith/settings.py b/sith/settings.py index d650f8ba..7a74a0fd 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -357,7 +357,7 @@ SITH_FORUM_PAGE_LENGTH = 30 # SAS variables SITH_SAS_ROOT_DIR_ID = 4 -SITH_SAS_IMAGES_PER_PAGE = 30 +SITH_SAS_IMAGES_PER_PAGE = 60 SITH_BOARD_SUFFIX = "-bureau" SITH_MEMBER_SUFFIX = "-membres"