Another round of proofreading. Sorry for being so nitpicking...

Comments in the code.

Diff comments:

> 
> === added file 'media/css/scheduling.css'
> --- media/css/scheduling.css  1970-01-01 00:00:00 +0000
> +++ media/css/scheduling.css  2018-01-17 19:07:26 +0000
> @@ -0,0 +1,230 @@
> +/* Main */
> +.main-choices {
> +    display: flex;
> +    justify-content: space-around;
> +    margin-top: 40px;
> +}
> +
> +.main-choices button {
> +    padding: 40px;
> +    font-size: 1em;
> +}
> +
> +/* actual scheduling module */
> +#calandar {
> +    display: flex;
> +    justify-content: center;
> +}
> +
> +/*  Hours of each day display for the user  */
> +.day {
> +    margin-bottom: 15px;
> +    background-image: url("../img/black50.png");
> +    padding: 10px;
> +}
> +
> +.day-title h3{
> +    color:white;
> +    font-weight: bold;
> +    margin-top: 0;
> +}
> +
> +.hours-wrapper {
> +    display: flex;
> +}
> +
> +.hours-title-wrapper {
> +    display: flex;
> +    width: 100%;
> +}
> +
> +.hours-title-wrapper p{
> +    width: 42px;
> +    user-select: none;
> +}
> +
> +.hours {
> +    border: 1px solid #909090;
> +    height:40px;
> +    width: 40px;
> +    cursor: pointer;
> +}
> +
> +.hours.selected {
> +    background-color: #118811;
> +}
> +
> +.hours:hover {
> +    background-color: lightgreen;
> +}
> +
> +.hidden-hour {
> +    height: 40px;
> +    width: 40px;
> +}
> +
> +
> +/*  Display for the other users  */
> +#other-users-wrapper {
> +    display: flex;
> +    flex-wrap: wrap;
> +    padding: 1%;
> +}
> +
> +.other-user-div{
> +    width: 29%;
> +    border: 1px solid black;
> +    background-image: url("../img/black50.png");
> +    padding: 11px;
> +    margin-top: 5px;
> +    margin-right: 5px;
> +}
> +
> +.other-user-div > div {
> +    margin-top: 14px;
> +}
> +
> +.other-user-div .hours{
> +    height: 10px;
> +    width: 20px;
> +}
> +
> +.other-user-div .title {
> +    height: 36px;
> +    display: flex;
> +    justify-content: space-between;
> +    margin-top: 0;
> +}
> +
> +.other-user-div .title p {
> +    font-size: 20px;
> +    margin-top: 5px;
> +    text-transform: capitalize;
> +    white-space: nowrap;
> +    overflow: hidden !important;
> +    text-overflow: ellipsis;
> +    color: #feea72;;
> +    font-weight: bold;
> +}
> +
> +.other-user-div .title button {
> +    min-width: 114px;
> +}
> +
> +.other-user-div .title button:hover {
> +    background-color:#118811;;
> +}
> +
> +.other-user-div .title img {
> +    margin-right: 4px;
> +}
> +
> +
> +/* btn */
> +#validate-btn {
> +    margin-top: 10px;
> +}
> +
> +
> +/**************************/
> +/* CSS for the datepicker */
> +/**************************/
> +
> +.ui-datepicker {
> +    background-image: url("../img/wood.png");
> +    border: 1px solid black;
> +    border-radius: 4px;
> +    box-shadow: 4px 4px 4px 0px rgba(0, 0, 0, 0.7);
> +    padding: 0.8em;
> +    display: none;
> +}
> +
> +.ui-datepicker-header {
> +    text-align: center;
> +    border: 1px inset darkgray;
> +    background-image: url("../img/black50.png");
> +    margin-bottom: 5px;
> +}
> +
> +.ui-datepicker-calendar {
> +    border: 1px inset darkgray;
> +    background-image: url("../img/black20.png");
> +}
> +
> +.ui-datepicker-prev {
> +    padding: 0 3em 0 0;
> +    cursor: pointer;
> +}
> + 
> +.ui-datepicker-next {
> +    padding: 0 0 0 3em;
> +    cursor: pointer;
> +}
> +
> +.ui-widget-content {
> +    display: flex !important;
> +    justify-content: space-around;
> +    width: 540px !important;
> +}
> +
> +.ui-datepicker-header {
> +    height: 42px;
> +    position: relative;
> +}
> +
> +.ui-datepicker-title {
> +    position: absolute;
> +    transform: translateX(-50%);
> +    left: 50%;
> +    bottom: 0;
> +}
> +
> +
> +
> +
> +/**********  clock **********/
> +
> +#clocks-wrapper {
> +    display:flex;

To have the clocks in a row can't we add:
flex-flow: row wrap;
? So on small screens they get wrapped but on big screens they are in a row.

> +    height: 210px;
> +    margin-top: 20px;
> +    background-image: url("../img/black50.png");
> +}
> +
> +#clocks-wrapper h1{
> +    text-align: center;
> +}
> +
> +svg.clock-svg {
> +    width: 150px;
> +    height: 150px;
> +}
> +
> +.hour-area {
> +    stroke-linejoin:round;
> +    stroke-width:8;
> +    fill: #312925;
> +    stroke: black;
> +}
> +
> +.hour-area.active {
> +    fill: #118811;
> +}
> +
> +
> +.number-wrapper {
> +    line-height:100%;
> +    fill: white;
> +    
> +    stroke:black;
> +    stroke-width:2.7;
> +}
> +
> +.number {
> +    -inkscape-font-specification: "sans-serif";
> +    font-family:"sans-serif";
> +}
> +
> +.circle {
> +    fill: #312925;
> +}
> \ No newline at end of file
> 
> === added directory 'templates/wlscheduling'
> === added file 'templates/wlscheduling/base.html'
> --- templates/wlscheduling/base.html  1970-01-01 00:00:00 +0000
> +++ templates/wlscheduling/base.html  2018-01-17 19:07:26 +0000
> @@ -0,0 +1,9 @@
> +{% extends "base.html" %}

Something i had forgotten myself many times: Adding such a block keeps the 
browsers history understandable to the user, e.g. by holding down the left 
mouse button on the back-button in the browser. This example will show up then 
as "Scheduling - wl.widelands.org":

{% block title %}
Scheduling- {{ block.super }}
{% endblock %}

Such blocks may also be useful in the other templates.

> +{% block extra_head %}
> +
> +<link  rel="stylesheet" type="text/css" href="{{ MEDIA_URL 
> }}css/jquery-ui.multidatespicker.css" >
> +<link  rel="stylesheet" type="text/css" href="{{ MEDIA_URL 
> }}css/scheduling.css" >
> +
> +<script src="{{ MEDIA_URL }}js/jquery-ui.multidatespicker.js" 
> type="text/javascript"></script>
> +<script src="{{ MEDIA_URL }}js/scheduling.js" 
> type="text/javascript"></script>
> +{% endblock %}
> \ No newline at end of file
> 
> === added file 'templates/wlscheduling/find.html'
> --- templates/wlscheduling/find.html  1970-01-01 00:00:00 +0000
> +++ templates/wlscheduling/find.html  2018-01-17 19:07:26 +0000
> @@ -0,0 +1,37 @@
> +
> +

Remove the first two empty lines

> +{% extends "wlscheduling/base.html" %}
> +{% comment %}
> +   vim:ft=htmldjango
> +{% endcomment %}
> +
> +{% block content %}
> +<script type="text/javascript">
> +document.addEventListener('DOMContentLoaded', function(){ 
> +    addTimeZoneWarningIfNeeded();
> +    addOtherUsersAvailabilities();
> +}, false);
> +</script>
> +
> +<div class="blogEntry">
> +    <h1>Times other players are available</h1>
> +    {% include "wlscheduling/timezone-msg.html" %}
> +    <div id="other-users-wrapper"></div>
> +    <div id="no-user-to-display" hidden="hidden">Sorry currently there isn't 
> anybody who has scheduled a gaming session. Don't hesitate to signal to other 
> when you'll be available <a href="{% url 'scheduling_scheduling' 
> %}">here</a></div>
> +
> +</div>
> +
> +<!-- Templates for the js script -->
> +{% include "wlscheduling/other-users-date.html" %}
> +
> +<div id="other-user-template" class="other-user-div" hidden="hidden">
> +    <div class="title"></div>
> +</div>
> +
> +
> +
> +<!-- Div to send django data to js file -->
> +<div id="django-data" user-time-zone="{{user.wlprofile.time_zone}}" 
> users-to-fill="{{other_users_availabilities}}"></div>
> +
> +
> +{% endblock %}
> \ No newline at end of file
> 
> === added file 'templates/wlscheduling/main.html'
> --- templates/wlscheduling/main.html  1970-01-01 00:00:00 +0000
> +++ templates/wlscheduling/main.html  2018-01-17 19:07:26 +0000
> @@ -0,0 +1,22 @@
> +

Remove empty first line

> +{% extends "wlscheduling/base.html" %}
> +{% comment %}
> +   vim:ft=htmldjango
> +{% endcomment %}
> +
> +{% block content %}
> +
> +
> +<div class="blogEntry">
> +    <h1>Welcome in the scheduling module!</h1>
> +    <div id="main-choices" class="main-choices">
> +        <a href="{% url 'scheduling_scheduling' %}" >
> +            <button title="You know when you will be available to play and 
> want to display when you're available and find other players that will be 
> available at these hours">Define your playtime and find a game</button>
> +        </a>
> +        <a href="{% url 'scheduling_find' %}" >
> +            <button title="You just want to know when everybody is going to 
> be playing" >Show other users playtime</button>
> +        </a>
> +    </div>
> +</div>
> +
> +{% endblock %}
> \ No newline at end of file
> 
> === added file 'wlscheduling/views.py'
> --- wlscheduling/views.py     1970-01-01 00:00:00 +0000
> +++ wlscheduling/views.py     2018-01-17 19:07:26 +0000
> @@ -0,0 +1,111 @@
> +#!/usr/bin/env python -tt
> +# encoding: utf-8
> +#
> +
> +from django.shortcuts import render
> +from models import Availabilities
> +from django.contrib.auth.decorators import login_required
> +import json
> +from datetime import datetime, timedelta
> +
> +
> +#########
> +# Views #
> +#########
> +def scheduling_main (request):
> +    return render(request, 'wlscheduling/main.html')
> +
> +@login_required
> +def scheduling_find (request):
> +    current_user = request.user
> +    other_users_availabilities = {}
> +    for a in 
> Availabilities.objects.exclude(user=current_user).order_by('avail_time'):
> +        user_utc_dt_avail_time = a.avail_time
> +        if datetime.now() < user_utc_dt_avail_time:
> +            other_user = a.user
> +            current_user_timezone = current_user.wlprofile.time_zone
> +            user_dt_avail_time = user_utc_dt_avail_time + timedelta(hours= 
> current_user_timezone)
> +            user_string_avail_time = datetime.strftime(user_dt_avail_time, 
> '%Y-%m-%dT%H')
> +                
> +            if not other_user.username in other_users_availabilities:
> +                other_users_availabilities[other_user.username] = []
> +            
> other_users_availabilities[other_user.username].append(user_string_avail_time)
> +    return render(request, 'wlscheduling/find.html', 
> {'other_users_availabilities': json.dumps(other_users_availabilities)})
> +
> +@login_required
> +def scheduling(request):
> +    current_user = request.user
> +    current_user_availabilities = []
> +    user_timezone = current_user.wlprofile.time_zone
> +        
> +    # Update of user's availabilities when post mode
> +    if request.method == 'POST':
> +        request_avail_times = []
> +        for r in request.POST:
> +            if r != "csrfmiddlewaretoken":
> +                request_avail_times.append(request.POST[r])
> +
> +
> +        current_user_availabilities = []
> +        for avail_time in request_avail_times:
> +            dt_avail_time = datetime.strptime(avail_time, '%Y-%m-%dT%H')
> +            utc_dt_avail_time =  dt_avail_time + timedelta(hours= - 
> user_timezone)
> +
> +            # We append the string to the list because apparently datetime 
> objects cannot be stored in a list?
> +            utc_string_avail_time = datetime.strftime(utc_dt_avail_time, 
> '%Y-%m-%dT%H')
> +            current_user_availabilities.append(utc_string_avail_time)
> +        
> +        
> +        for request_avail_time in request_avail_times:
> +            dt_avail_time = datetime.strptime(request_avail_time, 
> '%Y-%m-%dT%H')
> +            # Actual change of timezone, we got back to UTC
> +            utc_dt_avail_time =  dt_avail_time + timedelta(hours= - 
> user_timezone)
> +            avail_time_already_exist = False
> +            for a in Availabilities.objects.filter(user=current_user, 
> avail_time=utc_dt_avail_time):
> +                avail_time_already_exist = True
> +            
> +            if not avail_time_already_exist:
> +                a = Availabilities.objects.create(
> +                    user=current_user,
> +                    avail_time=utc_dt_avail_time
> +                )
> +                a.save()
> +        
> +        # We remove any previously stored date that is not present in the 
> request anymore
> +        for a in Availabilities.objects.filter(user=current_user):
> +            utc_dt_avail_time = a.avail_time
> +            to_remove = True
> +            for utc_string_avail_time in current_user_availabilities:
> +                request_utc_dt_avail_time = 
> datetime.strptime(utc_string_avail_time, '%Y-%m-%dT%H')
> +                if utc_dt_avail_time == request_utc_dt_avail_time:
> +                    to_remove = False
> +            if to_remove:
> +                a.delete()
> +
> +        
> +
> +    current_user_availabilities = []
> +    for a in 
> Availabilities.objects.filter(user=current_user).order_by('avail_time'):
> +        utc_dt_avail_time = a.avail_time
> +        # We display the time with current user timezone
> +        dt_avail_time = utc_dt_avail_time + timedelta(hours=user_timezone)
> +        string_avail_time = datetime.strftime(dt_avail_time, '%Y-%m-%dT%H')
> +        current_user_availabilities.append(string_avail_time)
> +
> +    other_users_availabilities = {}
> +    for current_user_a in 
> Availabilities.objects.filter(user=current_user).order_by('avail_time'):
> +        current_user_utc_dt_avail_time = current_user_a.avail_time
> +        for a in 
> Availabilities.objects.filter(avail_time=current_user_utc_dt_avail_time).exclude(user=current_user).order_by('avail_time'):
> +            user_utc_dt_avail_time = a.avail_time
> +            other_user = a.user
> +            current_user_timezone = current_user.wlprofile.time_zone
> +            user_dt_avail_time = user_utc_dt_avail_time + timedelta(hours= 
> current_user_timezone)
> +            user_string_avail_time = datetime.strftime(user_dt_avail_time, 
> '%Y-%m-%dT%H')

The string '%Y-%m-%dT%H' is often used and can lead into errors if one wants to 
change this and forget to change it in one of the other places. If possible 
define it at the top, below the imports, as e.g.: TIME_FORMAT = '%Y-%m-%dT%H' 
and use TIME_FORMAT where this is needed.

> +             
> +            if not other_user.username in other_users_availabilities:
> +                other_users_availabilities[other_user.username] = []
> +            
> other_users_availabilities[other_user.username].append(user_string_avail_time)
> +
> +
> +    return render(request, 'wlscheduling/scheduling.html', 
> {'current_user_availabilities': json.dumps(current_user_availabilities),
> +'other_users_availabilities': json.dumps(other_users_availabilities)})
> \ No newline at end of file


-- 
https://code.launchpad.net/~trimardio/widelands-website/module_scheduling/+merge/335570
Your team Widelands Developers is requested to review the proposed merge of 
lp:~trimardio/widelands-website/module_scheduling into lp:widelands-website.

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to