Compare commits
	
		
			2 Commits
		
	
	
		
			0.2.4
			...
			beec919b2e
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| beec919b2e | |||
| e51d586255 | 
@ -1,3 +1,9 @@
 | 
			
		||||
## Unreleased
 | 
			
		||||
 | 
			
		||||
* New
 | 
			
		||||
  * When adding session, pre-select game with the last session
 | 
			
		||||
  * Date and time input fields now have proper pickers
 | 
			
		||||
 | 
			
		||||
## 0.2.4 / 2023-01-16 19:39+01:00
 | 
			
		||||
 | 
			
		||||
* Fixed
 | 
			
		||||
 | 
			
		||||
@ -13,12 +13,26 @@ class SessionForm(forms.ModelForm):
 | 
			
		||||
            "duration_manual",
 | 
			
		||||
            "note",
 | 
			
		||||
        ]
 | 
			
		||||
        custom_datetime_widget = forms.SplitDateTimeWidget(
 | 
			
		||||
            date_attrs={"type": "date"}, time_attrs={"type": "time"}
 | 
			
		||||
        )
 | 
			
		||||
        widgets = {
 | 
			
		||||
            "timestamp_start": custom_datetime_widget,
 | 
			
		||||
            "timestamp_end": custom_datetime_widget,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PurchaseForm(forms.ModelForm):
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Purchase
 | 
			
		||||
        fields = ["game", "platform", "date_purchased", "date_refunded"]
 | 
			
		||||
        custom_date_widget = forms.DateInput(
 | 
			
		||||
            format=("%d-%m-%Y"), attrs={"type": "date"}
 | 
			
		||||
        )
 | 
			
		||||
        widgets = {
 | 
			
		||||
            "date_purchased": custom_date_widget,
 | 
			
		||||
            "date_refunded": custom_date_widget,
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GameForm(forms.ModelForm):
 | 
			
		||||
@ -31,3 +45,7 @@ class PlatformForm(forms.ModelForm):
 | 
			
		||||
    class Meta:
 | 
			
		||||
        model = Platform
 | 
			
		||||
        fields = ["name", "group"]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UnifiedGameForm(forms.ModelForm):
 | 
			
		||||
    GameFormSet = forms.inlineformset_factory(Game, Purchase)
 | 
			
		||||
 | 
			
		||||
@ -81,7 +81,7 @@ class Session(models.Model):
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def last(self) -> Manager[Any]:
 | 
			
		||||
        return Session.objects.all().order_by("timestamp_start")[:-1]
 | 
			
		||||
        return Session.objects.all().order_by("timestamp_start")[0]
 | 
			
		||||
 | 
			
		||||
    def save(self, *args, **kwargs):
 | 
			
		||||
        if self.timestamp_start != None and self.timestamp_end != None:
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,7 @@
 | 
			
		||||
                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="self-center w-6 h-6 inline">
 | 
			
		||||
                        <path stroke-linecap="round" stroke-linejoin="round" d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.348a1.125 1.125 0 010 1.971l-11.54 6.347a1.125 1.125 0 01-1.667-.985V5.653z" />
 | 
			
		||||
                    </svg>
 | 
			
		||||
                    {{ dataset.last.purchase }}
 | 
			
		||||
                    {{ last.purchase }}
 | 
			
		||||
                </button>
 | 
			
		||||
            </a>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,8 @@ def model_counts(request):
 | 
			
		||||
def add_session(request):
 | 
			
		||||
    context = {}
 | 
			
		||||
    now = now_with_tz()
 | 
			
		||||
    initial = {"timestamp_start": now}
 | 
			
		||||
    last = Session.objects.all().last()
 | 
			
		||||
    initial = {"timestamp_start": now, "purchase": last.purchase}
 | 
			
		||||
    form = SessionForm(request.POST or None, initial=initial)
 | 
			
		||||
    if form.is_valid():
 | 
			
		||||
        form.save()
 | 
			
		||||
@ -74,6 +75,7 @@ def list_sessions(request, filter="", purchase_id="", platform_id="", game_id=""
 | 
			
		||||
 | 
			
		||||
    context["total_duration"] = dataset.total_duration()
 | 
			
		||||
    context["dataset"] = dataset
 | 
			
		||||
    context["last"] = Session.objects.all().last()
 | 
			
		||||
    # charts are always oldest->newest
 | 
			
		||||
    context["chart"] = playtime_over_time_chart(dataset.order_by("timestamp_start"))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user