Вывод на экран
This commit is contained in:
1 parent
b437bfa7b0
commit
30f0dee390
7 files changed
+56
-27
No files matched your search
@@ -22,7 +22,7 @@ class DailyRoundUp(models.Model):
|
||||
verbose_name_plural = "Ежедневный обход"
|
||||
|
||||
def __str__(self):
|
||||
return str(self.name)
|
||||
return str(self.position)
|
||||
|
||||
class GeneralVacation(models.Model):
|
||||
CHOICES = (
|
||||
|
||||
@@ -11,4 +11,11 @@ class PlanCalendarSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = PlanCalendar
|
||||
fields ='__all__'
|
||||
fields ='__all__'
|
||||
|
||||
class DailyRoundUpSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = DailyRoundUp
|
||||
fields ='__all__'
|
||||
|
||||
@@ -5,4 +5,5 @@ from .views import *
|
||||
urlpatterns = [
|
||||
path('generalvacation/', GeneralVacationAPIView.as_view(), name='generalvacation'),
|
||||
path('dailyroundup/', DailyRoundUpAPIView.as_view(), name='dailyroundup'),
|
||||
path('dailyload/', DailyloadAPIView.as_view(), name='dailyload'),
|
||||
]
|
||||
+25
-22
@@ -1,4 +1,4 @@
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
import os
|
||||
from openpyxl import load_workbook
|
||||
import openpyxl
|
||||
@@ -196,30 +196,15 @@ class DailyRoundUpAPIView(APIView):
|
||||
ws.cell(row = k+3, column=8).value = f"=F{k+1}-H{k+1}-J{k+1}-L{k+1}"
|
||||
ws.cell(row = k+3, column=8).font = Font(name='Times New Roman', size=14, bold=True)
|
||||
|
||||
# print(ws.write(k+3, col, 'hhh'), '-------------------1')
|
||||
|
||||
|
||||
wb.save(file_path)
|
||||
|
||||
# urllib.request.urlretrieve(file_path, 'Пупка.xlsx')
|
||||
|
||||
# file_path = 'media/DailyRoundUp.xlsx'
|
||||
|
||||
|
||||
return Response(file_path)
|
||||
|
||||
# with ExcelWriter(file_path, mode="a" if os.path.exists(file_path) else "w" , if_sheet_exists='replace') as writer:
|
||||
# #
|
||||
# for i in df['department'].unique():
|
||||
# for i in df['department'].unique():
|
||||
# k = pd.DataFrame(df[(df.department==i)][['tabel', 'familyname', 'name', 'parentname']])
|
||||
# # k.to_excel(writer,header=None,index=None)
|
||||
# print(i)
|
||||
# print(k)
|
||||
# return Response('')
|
||||
#
|
||||
#
|
||||
# df.to_excel(table)
|
||||
|
||||
|
||||
def post(self, request):
|
||||
@@ -236,7 +221,7 @@ class DailyRoundUpAPIView(APIView):
|
||||
|
||||
# DailyRoundUp.objects.update_or_create(todaysDate=datetime.datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'), defaults={'user':self.request.user, 'position':base})
|
||||
df.columns = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
|
||||
df=df.iloc[6:, ]
|
||||
df=df.iloc[6:]
|
||||
df= df[df.b.notna()]
|
||||
df= df[df.a.notna()]
|
||||
df['b']=df['b'].str[-3:]
|
||||
@@ -253,7 +238,6 @@ class DailyRoundUpAPIView(APIView):
|
||||
df3=df3[['login', 'f', 'h', 'j','l']]
|
||||
|
||||
|
||||
# base=BasePosition.objects.get(pk=keys)
|
||||
|
||||
for ind in df3.index:
|
||||
keys = ''
|
||||
@@ -266,11 +250,30 @@ class DailyRoundUpAPIView(APIView):
|
||||
else:
|
||||
keys = 6
|
||||
base=BasePosition.objects.get(pk=keys)
|
||||
DailyRoundUp.objects.update_or_create(todaysDate=datetime.datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'),
|
||||
DailyRoundUp.objects.update_or_create(todaysDate=datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'),
|
||||
user=df3['login'][ind], defaults={'position':base})
|
||||
|
||||
print(base)
|
||||
|
||||
|
||||
|
||||
# serializer_for_daily = DailyRoundUpSerializer(
|
||||
# instance=daily, # Передаём набор записей
|
||||
# many=True # Указываем, что на вход подаётся именно набор записей
|
||||
# )
|
||||
|
||||
|
||||
|
||||
return Response('')
|
||||
return Response("")
|
||||
|
||||
|
||||
class DailyloadAPIView(APIView):
|
||||
def get(self, request):
|
||||
daily = DailyRoundUp.objects.filter(todaysDate=datetime.now())
|
||||
print(daily, '-----------------------------')
|
||||
|
||||
#
|
||||
# serializer_for_daily = DailyRoundUpSerializer(
|
||||
# instance=daily, # Передаём набор записей
|
||||
# many=True # Указываем, что на вход подаётся именно набор записей
|
||||
# )
|
||||
return Response('kkkk')
|
||||
# return Response({"Обход":serializer_for_daily})
|
||||
Reference in new issue
Block a user