Build a TOP screen for Django users

We have created a page for logged-in users so that it will be displayed first when you log in.

In going into production

"You can check the schedule" "Use ToDo"

We decided to start with these two points. It's hard to do work now, so I feel that I need to be involved in consulting when I start using it.

I felt that IT is something that non-IT people don't know, so it takes a lot of support to go from 0 to 1.

Then, Top screen

image.png

The shift schedule for one week of the person is displayed on the left and the ToDo is displayed on the right.

Some programs are commented out so that they do not work, but we plan to open them when they can be operated so that the bulletin board is also displayed.

accounts.views


from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
from django.shortcuts import render, redirect, HttpResponseRedirect
from shisetsu.models import *
from accounts.models import *
from todo.models import *
from schedule.models import *
from board.models import *
from riyousha.models import *
from .models import *
from datetime import date
import datetime
from datetime import timedelta
from datetime import datetime as dt
from django.db.models import Q

# Create your views here.
@login_required 
def home(request):
    #if request.method == "POST":
    #    shisetsu = int(shisetsu_num)
    #    shisetsu_detail = Shisetsu.objects.get(id = shisetsu)
    #    shisetsu_name = shisetsu_detail.name
    #    print(shisetsu_name)
    #    current_user = request.user
    #    form = Messageform
    #    message = request.POST['message']

    #    new_object=[]
    #    new_object=MessageModel(
    #        message = message,
    #        shisetsu_name = shisetsu_detail,
    #        )
    #    new_object.save()
    #    return HttpResponseRedirect('/shisetsu/info/%s' % (shisetsu,))
    #else:
    #If something different from your affiliation is selected, change it to your affiliation
    current_user = request.user
    UserShozoku_list = UserShozokuModel.objects.filter(user = current_user)
    User_info = CustomUser.objects.get(id = current_user.id)

    UserShozoku = UserShozokuModel.objects.filter(user = current_user).values_list("shisetsu_name", flat=True)
    UserShozoku = list(UserShozoku)
    shisetsu_list = Shisetsu.objects.filter(id__in = UserShozoku).select_related().all().order_by("id")

    #Get a list of users
    #riyousha_list = M_Riyousha.objects.filter(shisetsu_name = shisetsu, taisho_date__isnull=True).select_related().all().order_by("shisetsu_name_id")

    startdate = date.today()
    enddate = startdate + timedelta(days=7) 

    #Worker list
    schedule_list = Schedule.objects.filter(date__range=(startdate, enddate), user=current_user, open_flag = True).select_related().all()
    print(schedule_list)
     #schedule_list = Schedule.objects.filter(Q(date=startdate, shisetsu_name_1=shisetsu)|
    #    Q(date=startdate, shisetsu_name_2=shisetsu)|
    #    Q(date=startdate, shisetsu_name_3=shisetsu)|
    #    Q(date=startdate, shisetsu_name_4=shisetsu)
    #    ).select_related().order_by("date")
    
    #Bulletin board acquisition
    #bord_list = BoardModel.objects.filter(shisetsu_name = shisetsu, create_date__range=(enddate, timezone.now())).select_related().all().order_by("-create_date")[0:4]

    #get todo
    todo_list = TodoModel.objects.filter(shisetsu_name__in = shisetsu_list, enddate__isnull=True, plants_enddate__lt=enddate ).select_related().all().order_by("plants_enddate")
 
    #message
    #form = Messageform
    #message_list = MessageModel.objects.filter(shisetsu_name=shisetsu, read_flag=False).select_related().all().order_by("create_date")

    context = {
        #'shisetsu_detail' : shisetsu_detail,
        'todo_list' : todo_list,
        'schedule_list' : schedule_list,
        'startdate' : startdate,
        #'bord_list' : bord_list,
        #'riyousha_list' : riyousha_list,
        'shisetsu_list' : shisetsu_list,
        #'form' : form,
        #'message_list' : message_list,
        'User_info' : User_info,
    }
    #return render(request,'shisetsu/detail.html', context)
    return render(request, 'accounts/index.html', context)

I learned the range specification again by acquiring ToDo

todo_list = TodoModel.objects.filter(shisetsu_name__in = shisetsu_list, enddate__isnull=True, plants_enddate__lt=enddate ).select_related().all().order_by("plants_enddate")

Field name __range = (range start, range end)

accounts.html


{% extends 'accounts/base.html' %}
{% load static %}
{% block customcss %}
<link rel="stylesheet" href="{% static 'accounts/detail.css' %}">
{% endblock customcss %}

{% block header %}
{% endblock header %}

{% block content %}
{% csrf_token %}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
<div class="container bootstrap snippets bootdey">
<div class="row">
  <div class="profile-nav col-md-3">
      <div class="panel">
          <div class="user-heading round">
              <h1>{{ User_info.get_full_name }}</h1>
          </div>
            <p> 
                <h5>today:{{ startdate }}</h5>
            </p>
            <p> 
                <h5>shift</h5>
            </p>
            {% for schedule in schedule_list %}
                <p>
                    <h8>
                    {% if schedule.shift_name_1|stringformat:"s" != "Closed" and schedule.shift_name_1|stringformat:"s" != "Yes" and schedule.shift_name_1|stringformat:"s" != "Not" %}
                        {{schedule.date|date:"n month j day"}} {{ schedule.shisetsu_name_1.name }} : {{ schedule.shift_name_1.name }} {{ schedule.shift_name_1.start_time |date:"H"}}~{{ schedule.shift_name_1.end_time |date:"H"}}
                    {% else %}
                        {{schedule.date|date:"n month j day"}} {{ schedule.shift_name_1.name }}              
                    {% endif %}
                    {% if schedule.shift_name_2|stringformat:"s" == "None" %}

                    {% elif schedule.shift_name_2|stringformat:"s" != "Closed" and schedule.shift_name_2|stringformat:"s" != "Yes" and schedule.shift_name_2|stringformat:"s" != "Not" %}
                        <p>
                        {{ schedule.shisetsu_name_2.name }} : {{ schedule.shift_name_2.name }} {{ schedule.shift_name_2.start_time |date:"H"}}~{{ schedule.shift_name_2.end_time |date:"H"}}
                        </p>
                    {% else %}
                        <p>
                        {{ schedule.shift_name_1.name }}             
                        </p> 
                    {% endif %}
                </h8>
            </p>
            {% endfor %}
            <!--
            <h5>User information</h5>
            {% for riyousha in riyousha_list %}
                <i class="fa fa-user"></i><a href="{% url 'riyousha:riyoushainfo' riyousha.riyousha_id %}">{{ riyousha.full_name }}</a>
            {% endfor %}-->
      </div>
  </div>
  <div class="profile-info col-md-9">
    <div class="bio-graph-heading">              
Create the future by "pioneering" and nurturing "freedom to choose" and "power to choose"
    </div>

      <div class="row">
          <!--
        <h4>Bulletin board</h4>
                <table class="table table-striped table-bordered table-hover ">
                    <thead>
                    <th>title</th>
                    <th>Contributor</th>
                    <th>Created date</th>
                    </thead>
                {% for board in bord_list %}
                    <tr>
                        <td ><a href="{% url 'board:detail' board.pk %}">{{ board.title }}</a></td>
                        <td >{{ board.author }}</td>
                        <td >{{ board.create_date }}
                    </tr>
                    {% endfor %}
                </table>
                <p>
        -->            
        <h4>ToDo</h4><a href="{% url 'todo:create' %}" class="btn-info btn active">Create New</a>
            <table class="table table-striped table-bordered table-hover ">
                <thead>
                    <th>Facility</th>
                    <th>title</th>
                    <th>priority</th>
                    <th>Person in charge</th>
                    <th>Expected end date</th>
                </thead>
                {% for todo in todo_list %}
                <tr>
                        <td>{{ todo.shisetsu_name }}</td>
                        <td ><a href="{% url 'todo:update' todo.pk %}" >{{ todo.title }}</a></td>
                        <td >{{ todo.get_priority_display }} </td>
                        <td >{{ todo.user.get_full_name|default:"" }}</td>
                        <td >{{ todo.plants_enddate|date:"n month j day"|default:"" }}</td>
                </tr>
                {% endfor %}
            </table>
                  </div>
                <!--
                <div class="panel-body bio-graph-info">
                  </div>
                  <div class="panel">

                        <div class="right">

                            <h4>message</h4>
                            <table class="table table-striped table-bordered table-hover ">
                                <thead>
                                    <th>message</th>
                                    <th>Filler</th>
                                    <th>Date and time</th>
                                    <th>Verification</th>
                                </thead>
                            {% for message in message_list %}
                            <tr>
                                <td>{{ message.message }}</td>
                                <td>{{ message.create_user }}</td>
                                <td>{{ message.create_date }}</td>
                                <td><a href="{% url 'shisetsu:messageread' message.pk shisetsu_detail.id %}" class="btn-sm btn-info pull-right">Confirmed</a></td>
                            </tr>
                            {% endfor %}
                            </table>
                        </div>

                    <form action="" method="POST" role="form">{% csrf_token %}
                        {{ form.as_p }}
                        <div class="right">
                            <button class="btn btn-success pull-right" input type="submit">Registration</button>
                        </div>
                    </form>
              </div>
          </div>
          -->
        </div>
      </div>
  </div>
</div>
</div>
{% endblock content %}

I basically don't memorize the code at all. I just thought that I wrote such a pattern somewhere, and I can't write it without looking at the filter, but I'm wondering if this method is okay.

It is necessary to deepen the understanding of the code little by little, but there are many difficult aspects if you are self-taught ... Moreover, you are not doing it at work.

I would like to make something as good as possible and use it for society! As a person working in the IT department at a small and medium-sized enterprise, I have a lot of experience in RPA, groupware, AD, security, computerization, system replacement, etc.

Vendors almost always don't come up with specific ideas or advice on operational issues that only sell. I think it is better to develop IT human resources by ourselves or to provide fixed consulting.

However, it is really difficult to develop IT human resources in a non-IT company ... because I haven't joined the company thinking that I'm IT, so I have to find out where I'm unlikely to like it ...

Recently I started thinking that if there is a demand for information dissemination as a work in an information system, I should do it.

Recommended Posts

Build a TOP screen for Django users
Create a Django login screen
Build a Django environment for Win10 (with virtual space)
[Memo] Build a development environment for Django + Nuxt.js with Docker
[Python] Create a screen for HTTP status code 403/404/500 with Django
Build a web application with Django
[DynamoDB] [Docker] Build a development environment for DynamoDB and Django with docker-compose
Commands for creating a new django project
Creating a login screen with Django allauth
Building a conda environment for ROS users
Write a short if-else for Django Template
Redo everything for the Django login screen
[Python] Build a Django development environment with Docker
Build a Django environment with Vagrant in 5 minutes
Create a dashboard for Network devices with Django!
A story about implementing a login screen with django
Build a Django development environment with Doker Toolbox
Build a Kubernetes environment for development on Ubuntu
Quickly build a Python Django environment with IntelliJ
Build a mruby development environment for ESP32 (Linux)
Build a Django development environment using pyenv-virtualenv on Mac
Build a local development environment for Laravel6.X on Mac
Build a Python extension for E-Cell 4 on Windows 7 (64bit)
Build a python environment for each directory with pyenv-virtualenv
How to build a Django (python) environment on docker
Build a Python virtual environment using venv (Django + MySQL ①)
How to build a development environment for TensorFlow (1.0.0) (Mac)
Transit to the update screen with the Django a tag
Build a development environment with Poetry Django Docker Pycharm
Django + redis Issue a dedicated URL valid for 1 hour
Create a Django schedule
Creating a Home screen
Django2 screen addition flow
Start a Django project
Avoiding the pitfalls of using a Mac (for Linux users?)
Build a Django development environment with Docker! (Docker-compose / Django / postgreSQL / nginx)
Easily build a GCP environment for Kaggle at high speed
[Django] Build a Django container (Docker) development environment quickly with PyCharm
[Django] Create a model suitable for phone numbers / zip codes
Build a bulletin board app from scratch with Django. (Part 2)
Build a bulletin board app from scratch with Django. (Part 3)
Build a Python extension for E-Cell 4 on Mac OSX (Yosemite)
[Django] A collection of scripts that are convenient for development
<Python> Build a dedicated server for Jupyter Notebook data analysis
Create a Todo app with Django ① Build an environment with Docker
(For beginners) Try creating a simple web API with Django
Build a PyData environment for a machine learning study session (January 2017)
Build a python environment on CentOS 7.7 for your home server
Create a social integration API for smartphone apps with Django