-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented User-Storys 3, 8, 9 #8
Conversation
from django import forms | ||
|
||
def status_angelegt(modeladmin, request, queryset): | ||
queryset.update(status=100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use Veranstaltung.STATUS_ANGELEGT instead of 100 same for the other functions
@@ -205,13 +204,6 @@ class AlternativVorname(models.Model): | |||
vorname = models.CharField(_('first name'), max_length=30, blank=True) | |||
person = models.ForeignKey(Person, on_delete=models.CASCADE) | |||
|
|||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess the remove of this function is a glitch in the pr. Maybe you like to add the function again.
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also read the outdatet comment because it is still valid
queryset.update(status=900) | ||
for veranstaltung in queryset: | ||
veranstaltung.log(True, False) | ||
status_boegen_gescannt.short_description = 'Status: gescannt' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution requires a new function each time a new Status is added. Please refactore to one function "Status ändern" which redirects the user to a intermediate page where the user select the targed state. See https://docs.djangoproject.com/en/1.10/ref/contrib/admin/actions/#actions-that-provide-intermediate-pages
list_display_links = ['name'] | ||
list_filter = ('typ', 'semester', 'grundstudium', 'evaluieren', 'sprache') | ||
search_fields = ['name'] | ||
filter_horizontal = ('veranstalter', 'ergebnis_empfaenger') # @see http://stackoverflow.com/a/5386871 | ||
readonly_fields = ('link_veranstalter',) | ||
|
||
|
||
class VeranstaltungStatus(Veranstaltung): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just drop this model and the admin for it and integrate the function in to the normal Admin for the Veranstaltung model.
In the Veranstaltung admin you can add a table inline admin which lists all the log entrys of the instance of a Veranstaltung. Please make sure that you can not add a new log entry manual.
] | ||
|
||
|
||
class LogAdmin(admin.ModelAdmin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sould not be possible for the user to manual manipulate a log. So just drop the admin for log
@@ -316,6 +324,18 @@ class Veranstaltung(models.Model): | |||
freiefrage2 = models.TextField(verbose_name='2. Freie Frage', blank=True) | |||
kleingruppen = models.TextField(verbose_name='Kleingruppen', blank=True) | |||
|
|||
def get_next_state(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use a dict for it where the source state is the key and the targed state is the value.
Whats about the case that there are more then one possible targed state? So you might better return a tuple containing all targed states then a single value.
veranstaltung = models.ForeignKey(Veranstaltung, null=True) | ||
timestamp = models.DateTimeField(auto_now_add=True) | ||
status = models.IntegerField(choices=Veranstaltung.STATUS_CHOICES, default=Veranstaltung.STATUS_ANGELEGT) | ||
verursacher = models.CharField(max_length=30, blank=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use two foreign Key relations for verursacher instead of a CharField. If the verursacher is a user or a Veranstalter you should link to the Django auth user model. There should be a Veranstalter user in auth ;)
If the Verursacher is a Barcode scanner you should link to the Barcode scanner.
timestamp = models.DateTimeField(auto_now_add=True) | ||
status = models.IntegerField(choices=Veranstaltung.STATUS_CHOICES, default=Veranstaltung.STATUS_ANGELEGT) | ||
verursacher = models.CharField(max_length=30, blank=True) | ||
interface = models.CharField(max_length=30, blank=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of interface is limited to 3 so please use a select choices for it.
if next_state is None: | ||
response_message = "Nachster Status ungultig." | ||
else: | ||
time_offset = datetime.date.today() - datetime.timedelta(hours=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The limit should 1 Minute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Protection against double scaning is not working
self.veranstaltung.refresh_from_db() | ||
self.assertEqual(self.veranstaltung.status, Veranstaltung.STATUS_GEDRUCKT) | ||
|
||
def test_double_scan(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This testsetup is incomplete: Because the scanner only can reach one state. There is no testing of the time constraint at all!
self.barcode_scanner_no_access_right = BarcodeScanner.objects.create(token="LRh73Ds22", description="") | ||
|
||
self.barcode_scanner = BarcodeScanner.objects.create(token="LRh73Ds23", description="") | ||
BarcodeAllowedState.objects.create(barcode_scanner=self.barcode_scanner, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For double scan testing another allowed State is required e.g.
@@ -25,7 +25,7 @@ def barcodedrop(request): | |||
if next_state is None: | |||
response_message = "Nachster Status ungultig." | |||
else: | |||
time_offset = datetime.date.today() - datetime.timedelta(hours=1) | |||
time_offset = datetime.date.today() - datetime.timedelta(minutes=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datetime.date.today() is not what you want. datetime.datetime.now() has a time resolution and not only a date resulution.
Take your time with this PR, since it is a big commit (we had some issues while branching). If there a open questions, just email me :)