Skip to content
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

Merged
merged 9 commits into from
Dec 16, 2016
Merged

Implemented User-Storys 3, 8, 9 #8

merged 9 commits into from
Dec 16, 2016

Conversation

yduman
Copy link
Contributor

@yduman yduman commented Dec 9, 2016

  • enabled logging for state transitions
  • enabled state transition through barcode scan
  • enabled a notification for the user, if the lecturer is "N.N"

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 :)

@coveralls
Copy link

coveralls commented Dec 9, 2016

Coverage Status

Coverage increased (+0.7%) to 91.116% when pulling 94379ed on yduman:master into 2bac9ca on d120:master.

from django import forms

def status_angelegt(modeladmin, request, queryset):
queryset.update(status=100)
Copy link
Collaborator

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
Copy link
Collaborator

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 91.116% when pulling 0114ca2 on yduman:master into 2bac9ca on d120:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 91.116% when pulling 0114ca2 on yduman:master into 2bac9ca on d120:master.

Copy link
Collaborator

@ckleemann ckleemann left a 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'

Copy link
Collaborator

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):
Copy link
Collaborator

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):
Copy link
Collaborator

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):
Copy link
Collaborator

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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.

@coveralls
Copy link

coveralls commented Dec 15, 2016

Coverage Status

Coverage increased (+0.7%) to 91.116% when pulling 57d573d on yduman:master into daf155e on d120:master.

@coveralls
Copy link

coveralls commented Dec 15, 2016

Coverage Status

Coverage increased (+1.02%) to 91.401% when pulling addb3bf on yduman:master into daf155e on d120:master.

Copy link
Collaborator

@ckleemann ckleemann left a 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):
Copy link
Collaborator

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,
Copy link
Collaborator

@ckleemann ckleemann Dec 15, 2016

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)
Copy link
Collaborator

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.

@coveralls
Copy link

coveralls commented Dec 15, 2016

Coverage Status

Coverage increased (+1.05%) to 91.433% when pulling 640be75 on yduman:master into daf155e on d120:master.

@coveralls
Copy link

coveralls commented Dec 15, 2016

Coverage Status

Coverage increased (+1.08%) to 91.458% when pulling 5012631 on yduman:master into daf155e on d120:master.

@ckleemann ckleemann merged commit b8ab0db into d120:master Dec 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants