diff --git a/helpdesk/migrations/0018_auto_20181017_1737.py b/helpdesk/migrations/0018_auto_20181017_1737.py new file mode 100644 index 00000000..803d3370 --- /dev/null +++ b/helpdesk/migrations/0018_auto_20181017_1737.py @@ -0,0 +1,65 @@ +# Generated by Django 2.1.2 on 2018-10-17 17:37 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('helpdesk', '0017_default_owner_on_delete_null'), + ] + + operations = [ + migrations.AddField( + model_name='kbitem', + name='voted_by', + field=models.ManyToManyField(to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='followup', + name='public', + field=models.BooleanField(blank=True, default=False, help_text='Public tickets are viewable by the submitter and all staff, but non-public tickets can only be seen by staff.', verbose_name='Public'), + ), + migrations.AlterField( + model_name='ignoreemail', + name='keep_in_mailbox', + field=models.BooleanField(blank=True, default=False, help_text='Do you want to save emails from this address in the mailbox? If this is unticked, emails from this address will be deleted.', verbose_name='Save Emails in Mailbox?'), + ), + migrations.AlterField( + model_name='queue', + name='allow_email_submission', + field=models.BooleanField(blank=True, default=False, help_text='Do you want to poll the e-mail box below for new tickets?', verbose_name='Allow E-Mail Submission?'), + ), + migrations.AlterField( + model_name='queue', + name='allow_public_submission', + field=models.BooleanField(blank=True, default=False, help_text='Should this queue be listed on the public submission form?', verbose_name='Allow Public Submission?'), + ), + migrations.AlterField( + model_name='queue', + name='email_box_ssl', + field=models.BooleanField(blank=True, default=False, help_text='Whether to use SSL for IMAP or POP3 - the default ports when using SSL are 993 for IMAP and 995 for POP3.', verbose_name='Use SSL for E-Mail?'), + ), + migrations.AlterField( + model_name='savedsearch', + name='shared', + field=models.BooleanField(blank=True, default=False, help_text='Should other users see this query?', verbose_name='Shared With Other Users?'), + ), + migrations.AlterField( + model_name='ticket', + name='on_hold', + field=models.BooleanField(blank=True, default=False, help_text='If a ticket is on hold, it will not automatically be escalated.', verbose_name='On Hold'), + ), + migrations.AlterField( + model_name='ticketcc', + name='can_update', + field=models.BooleanField(blank=True, default=False, help_text='Can this CC login and update the ticket?', verbose_name='Can Update Ticket?'), + ), + migrations.AlterField( + model_name='ticketcc', + name='can_view', + field=models.BooleanField(blank=True, default=False, help_text='Can this CC login to view the ticket details?', verbose_name='Can View Ticket?'), + ), + ] diff --git a/helpdesk/models.py b/helpdesk/models.py index db22bd81..a2311b96 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -1060,6 +1060,7 @@ class KBItem(models.Model): An item within the knowledgebase. Very straightforward question/answer style system. """ + voted_by= models.ManyToManyField(settings.AUTH_USER_MODEL) category = models.ForeignKey( KBCategory, on_delete=models.CASCADE, diff --git a/helpdesk/views/kb.py b/helpdesk/views/kb.py index a7e7a1e8..5e66d6ab 100644 --- a/helpdesk/views/kb.py +++ b/helpdesk/views/kb.py @@ -46,9 +46,11 @@ def vote(request, item): item = get_object_or_404(KBItem, pk=item) vote = request.GET.get('vote', None) if vote in ('up', 'down'): - item.votes += 1 - if vote == 'up': - item.recommendations += 1 - item.save() + if request.user not in item.voted_by: + + item.votes += 1 + if vote == 'up': + item.recommendations += 1 + item.save() return HttpResponseRedirect(item.get_absolute_url())