For the time being, I would like to create a shift creation function, but if there is monthly shift data, implement it first by making it possible to copy it next month, and if it can be developed, the shift conditions of each staff Or, I would like to be able to automatically create shifts for the next month or the current month based on vacation requests and manually correct them.
After copying from the previous month when creating a shift, the shift is edited from the conditions of each staff member. Since this is created in Excel, it is troublesome. I created the creation assistance function in VBA before, but ...
condition is,
・ Regular employees work more than XX hours a month ・ Working only on what day ・ Two people are required to work from XX to XX ・ Staff may work in multiple facilities
I'm going to make it from now on in the form of copying and editing this month when I make it next month. Basically, it seems to be based on the day of the week, so I'd like to put the first Monday in the next Monday.
After implementation, I would like to add useful functions.
I also thought about various tables. If there are multiple shift patterns in a day, I thought about creating it so that it doesn't matter how many it becomes. The technology is still lacking, and from the user's point of view, it doesn't matter whether the back table structure is clean or not. First of all, thinking that it is best to provide something that can be used,
date USER ① Facility shift pattern ② Facility shift pattern ③ Facility shift pattern ④ Facility shift pattern
I will implement it in the form of.
It seems difficult to check the required work of two or more people from XX to XX, so it may be implemented only later (laugh)
I thought that the facility table will be used in various places, so I will create an app for the facility
terminal
python3 manage.py startapp shisetsu
After adding the app, add the app to the setting
config/settigns.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts.apps.AccountsConfig',
'shisetsu'
]
Specify the model of the facility. Be sure to specify the colors for clarity when displaying basic information and shift tables.
shisetsu/models.py
from django.db import models
from phonenumber_field.modelfields import PhoneNumberField
# Create your models here.
class Shisetsu(models.Model):
id = models.IntegerField(verbose_name='Facility ID',primary_key=True)
name = models.CharField(verbose_name='Name of facility', max_length=50)
adress = models.CharField(verbose_name='Street address', max_length=100)
tel = PhoneNumberField(verbose_name='phone number', null=True, blank=True)
fax = PhoneNumberField(verbose_name='Fax number', null=True, blank=True)
color = ColorField(verbose_name='Display color', default='#FF0000')
I'm going to edit on the admin site, so modify admin.py
shisetsu.py
from django.contrib import admin
from .models import Profile
# Register your models here.
admin.site.register(Profile)
Now that the settings are complete, migrate.
terminal
python3 manage.py makemigration
When I implemented it, I got an error.
from phonenumber_field.modelfields import PhoneNumberField
I don't have it, so I think you should import it.
terminal
pip install django-phonenumber-field
pip install phonenumbers
I think that the installation is completed, so try migrating again.
next,
terminal
color = ColorField(verbose_name='Display color', default='#FF0000')
NameError: name 'ColorField' is not defined
I'm getting an error here.
terminal
pip install django-colorfield
Install and add two to the app in the settings file
config/settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts.apps.AccountsConfig',
'shisetsu',
'colorfield',
'phonenumber_field.modelfields',
]
And once again, carry out the migration.
It seems to have succeeded.
I will check it from the management screen.
It was displayed, so when I tried to register, I got an error with my phone number.
I think it's different from the phone number format in Japan ... So fix
python:config.setting.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts.apps.AccountsConfig',
'shisetsu',
'colorfield',
]
Remove phone app
rewrite models
shisetsu.py
from django.db import models
from colorfield.fields import ColorField
# Create your models here.
class Shisetsu(models.Model):
id = models.IntegerField(verbose_name='Facility ID',primary_key=True)
name = models.CharField(verbose_name='Name of facility', max_length=50)
adress = models.CharField(verbose_name='Street address', max_length=100)
tel = models.CharField(verbose_name='phone number', max_length=20)
fax = models.CharField(verbose_name='Fax number', max_length=20)
color = ColorField(verbose_name='Display color', default='#FF0000')
This will carry out another migration. You have now saved it.
Since the facility information does not update the registration so much, we will not create an editing screen.
Recommended Posts