토이2(프로젝트)
-
오늘 누적시간(합)해당유저 시간토이2(프로젝트) 2023. 6. 8. 23:24
@login_required def index(request):#경과시간 print(0) #오늘 누적 today_start = timezone.now().replace(hour=0, minute=0, second=0, microsecond=0) my_objects = test.objects.all().filter(time=today_start, user=request.user) total_sum = sum(i.end_time for i in my_objects) #오늘 누적 today_start 오늘 날짜(시간x) my_objects는@login_required있다면 request.user는 로그인 유저만 가능하고 user할당하고 time(생성날짜)에 today_start(오늘날짜)를 할당 my_obje..
-
함수 실행(공부여부)토이2(프로젝트) 2023. 6. 5. 23:53
@login_required def index(request):#경과시간 print(0) user = request.user user.is_running=0#기본 값으로 변경 user.save() return render(request, "stopwatch/index.html") @login_required def stop(request): print(1) user = request.user user.is_running=1#기본 값으로 변경 user.save() stopwatch/ 에서 시작버튼 클릭(stopwatch/stop/이동) 하면 유저 is_running(기본값0)에 1저장 stopwatch/stop에서 저장 버튼 클릭(stopwatch/이동)하면 기본 값0으로 저장 그래서 실행여부 확인
-
db(test)에 유저정보(id) 추가/db 생성 시간 추가토이2(프로젝트) 2023. 6. 2. 01:31
class test(models.Model): end_time=models.IntegerField() user=models.ForeignKey(get_user_model(), on_delete=models.CASCADE)#유저 id time=models.DateTimeField(auto_now_add=True)#저장 시간 모델에 추가 @login_required def stop(request): if request.method =="POST": form=testForm(request.POST) if form.is_valid(): test=form.save(commit=False) test.user = request.user#유저정보 test.save()#유저정보 return redirect('stopwa..
-
시간(값) 기록 알림토이2(프로젝트) 2023. 5. 26. 21:03
스톱워치에서 저장하기전에 값(시간)이 얼마인지 보여주는 알림 정지버튼을 누르면 값(시간)이 얼마인지 보여준다그런데 알림창기록 내용이랑 DB 저장하는 오차가 1이있다 오차 때문에 원래 값에서 -1하고 알림에서 보여주고그러면 시작버튼과 정지버튼 바로클릭할때 -1기록 그래서 최소 값을 0으로 기록으로 수정 function alerttest(){ if (end_time-1==-1){ alert(0+"기록함");//0이면기록 }else{ alert(end_time-1+"기록함");//오차 -1 } }