Compare commits
	
		
			1 Commits
		
	
	
		
			fix-splitd
			...
			beec919b2e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| beec919b2e | 
@ -4,23 +4,6 @@ from .models import Game, Platform, Purchase, Session
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SessionForm(forms.ModelForm):
 | 
					class SessionForm(forms.ModelForm):
 | 
				
			||||||
    custom_datetime_widget = forms.SplitDateTimeWidget(
 | 
					 | 
				
			||||||
        date_format=("%d-%m-%Y"),
 | 
					 | 
				
			||||||
        time_format=("%H:%M"),
 | 
					 | 
				
			||||||
        date_attrs={"type": "date"},
 | 
					 | 
				
			||||||
        time_attrs={"type": "time"},
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
    timestamp_start = forms.SplitDateTimeField(
 | 
					 | 
				
			||||||
        input_date_formats="['%d-%m-%Y]",
 | 
					 | 
				
			||||||
        input_time_formats="['%H:%M']",
 | 
					 | 
				
			||||||
        widget=custom_datetime_widget,
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
    timestamp_end = forms.SplitDateTimeField(
 | 
					 | 
				
			||||||
        input_date_formats="['%d-%m-%Y]",
 | 
					 | 
				
			||||||
        input_time_formats="['%H:%M']",
 | 
					 | 
				
			||||||
        widget=custom_datetime_widget,
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        model = Session
 | 
					        model = Session
 | 
				
			||||||
        fields = [
 | 
					        fields = [
 | 
				
			||||||
@ -30,15 +13,13 @@ class SessionForm(forms.ModelForm):
 | 
				
			|||||||
            "duration_manual",
 | 
					            "duration_manual",
 | 
				
			||||||
            "note",
 | 
					            "note",
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
 | 
					        custom_datetime_widget = forms.SplitDateTimeWidget(
 | 
				
			||||||
        # fields_classes = {
 | 
					            date_attrs={"type": "date"}, time_attrs={"type": "time"}
 | 
				
			||||||
        #     "timestamp_start": custom_datetime_field,
 | 
					        )
 | 
				
			||||||
        #     "timestamp_end": custom_datetime_field,
 | 
					        widgets = {
 | 
				
			||||||
        # }
 | 
					            "timestamp_start": custom_datetime_widget,
 | 
				
			||||||
        # widgets = {
 | 
					            "timestamp_end": custom_datetime_widget,
 | 
				
			||||||
        #     "timestamp_start": custom_datetime_widget,
 | 
					        }
 | 
				
			||||||
        #     "timestamp_end": custom_datetime_widget,
 | 
					 | 
				
			||||||
        # }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PurchaseForm(forms.ModelForm):
 | 
					class PurchaseForm(forms.ModelForm):
 | 
				
			||||||
@ -64,3 +45,7 @@ class PlatformForm(forms.ModelForm):
 | 
				
			|||||||
    class Meta:
 | 
					    class Meta:
 | 
				
			||||||
        model = Platform
 | 
					        model = Platform
 | 
				
			||||||
        fields = ["name", "group"]
 | 
					        fields = ["name", "group"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class UnifiedGameForm(forms.ModelForm):
 | 
				
			||||||
 | 
					    GameFormSet = forms.inlineformset_factory(Game, Purchase)
 | 
				
			||||||
 | 
				
			|||||||
@ -23,11 +23,7 @@ def add_session(request):
 | 
				
			|||||||
    context = {}
 | 
					    context = {}
 | 
				
			||||||
    now = now_with_tz()
 | 
					    now = now_with_tz()
 | 
				
			||||||
    last = Session.objects.all().last()
 | 
					    last = Session.objects.all().last()
 | 
				
			||||||
    initial = {
 | 
					    initial = {"timestamp_start": now, "purchase": last.purchase}
 | 
				
			||||||
        "timestamp_start_0": now.date(),
 | 
					 | 
				
			||||||
        "timestamp_start_1": now.time(),
 | 
					 | 
				
			||||||
        "purchase": last.purchase,
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    form = SessionForm(request.POST or None, initial=initial)
 | 
					    form = SessionForm(request.POST or None, initial=initial)
 | 
				
			||||||
    if form.is_valid():
 | 
					    if form.is_valid():
 | 
				
			||||||
        form.save()
 | 
					        form.save()
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user