AdrianFerJ / v2go-api

V2go web app's repo contains client and server apps (django and angular), and infastructure setup for both apps, postgres, redis, and nginx using docker
0 stars 0 forks source link

CS Event (in volt_reservation/models.py) has an unnecesary save() restriction #34

Closed AdrianFerJ closed 5 years ago

AdrianFerJ commented 5 years ago

The class CSEvent(models.Model): save method has a restriction that prevents the creation of a CSEvent if the start and end date time is the same as a different CSEvent, even if this event is for a different CS. This restriction makes sense within the same CS, but not as a general restriction.

Recommended fix: Add cs to the logical test case: if self.cs_event_nk is None and CSEvent.objects.filter(startDateTime=self.startDateTime, endDateTime=self.endDateTime, cs = self.cs ).exists():

Also, I recommend renaming CSEvent and EVEvent (and all references) to EventCS and EventEV

AdrianFerJ commented 5 years ago

Also, this should be tested inside the tests/test_models.py