Added flag to track completed equipment requests
This commit is contained in:
parent
afdb834daf
commit
1fb2b65df2
|
@ -367,10 +367,9 @@ SOCIALACCOUNT_QUERY_EMAIL = True
|
||||||
# Select the correct user model
|
# Select the correct user model
|
||||||
AUTH_USER_MODEL = 'users.User'
|
AUTH_USER_MODEL = 'users.User'
|
||||||
LOGIN_REDIRECT_URL = 'users:redirect'
|
LOGIN_REDIRECT_URL = 'users:redirect'
|
||||||
#LOGIN_URL = 'account_login'
|
|
||||||
WIKI_SIGNUP_URL = 'account_login'
|
|
||||||
WIKI_ACCOUNT_HANDLING = False
|
WIKI_ACCOUNT_HANDLING = False
|
||||||
#WIKI_EDITOR = 'wiki.editors.martor.Martor'
|
WIKI_EDITOR = 'wiki.editors.martor.Martor'
|
||||||
|
|
||||||
# SLUGLIFIER
|
# SLUGLIFIER
|
||||||
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
|
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,11 @@ from django.contrib.admin import ModelAdmin
|
||||||
from martor.widgets import AdminMartorWidget
|
from martor.widgets import AdminMartorWidget
|
||||||
from martor.models import MartorField
|
from martor.models import MartorField
|
||||||
|
|
||||||
from mhackspace.requests.models import UserRequests
|
from mhackspace.requests.models import UserRequest
|
||||||
|
|
||||||
|
|
||||||
@admin.register(UserRequests)
|
@admin.register(UserRequest)
|
||||||
class RequestsAdmin(ModelAdmin):
|
class RequestsAdmin(ModelAdmin):
|
||||||
list_display = ('title', 'description', 'created_date')
|
list_display = ('title', 'acquired', 'description', 'created_date')
|
||||||
# list_filter = ('author', 'categories', 'members_only')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
from mhackspace.requests.models import UserRequests
|
from mhackspace.requests.models import UserRequest
|
||||||
from mhackspace.requests.models import REQUEST_TYPES
|
from mhackspace.requests.models import REQUEST_TYPES
|
||||||
|
|
||||||
|
|
||||||
class UserRequestForm(forms.ModelForm):
|
class UserRequestForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UserRequests
|
model = UserRequest
|
||||||
exclude = ['user', 'created_date']
|
exclude = ['user', 'created_date']
|
||||||
# description = forms.CharField(
|
# description = forms.CharField(
|
||||||
# required=True,
|
# required=True,
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.4 on 2018-01-14 17:30
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('requests', '0007_auto_20170919_2023'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameModel('UserRequests', 'UserRequest'),
|
||||||
|
]
|
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.4 on 2018-01-14 17:50
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('requests', '0008_auto_20180114_1730'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='userrequest',
|
||||||
|
name='acquired',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
|
@ -13,13 +13,14 @@ REQUEST_TYPES = (
|
||||||
(2, 'Training request'))
|
(2, 'Training request'))
|
||||||
|
|
||||||
|
|
||||||
class UserRequests(models.Model):
|
class UserRequest(models.Model):
|
||||||
user = models.ForeignKey(
|
user = models.ForeignKey(
|
||||||
settings.AUTH_USER_MODEL,
|
settings.AUTH_USER_MODEL,
|
||||||
related_name='+'
|
related_name='+'
|
||||||
)
|
)
|
||||||
title = models.CharField(max_length=255, help_text='Whats being requested ?')
|
title = models.CharField(max_length=255, help_text='Whats being requested ?')
|
||||||
request_type = models.IntegerField(choices=REQUEST_TYPES, null=False)
|
request_type = models.IntegerField(choices=REQUEST_TYPES, null=False)
|
||||||
|
acquired = models.BooleanField()
|
||||||
cost = models.DecimalField(
|
cost = models.DecimalField(
|
||||||
max_digits=6,
|
max_digits=6,
|
||||||
decimal_places=2,
|
decimal_places=2,
|
||||||
|
@ -40,12 +41,12 @@ class UserRequests(models.Model):
|
||||||
# comment = models.TextField()
|
# comment = models.TextField()
|
||||||
# created_date = models.DateTimeField(default=timezone.now)
|
# created_date = models.DateTimeField(default=timezone.now)
|
||||||
|
|
||||||
# class Meta:
|
class Meta:
|
||||||
# ordering = ('created_date',)
|
ordering = ('acquired', 'created_date',)
|
||||||
|
|
||||||
|
|
||||||
def send_topic_update_email(sender, instance, **kwargs):
|
def send_topic_update_email(sender, instance, **kwargs):
|
||||||
matrix_message.delay(prefix=' - REQUEST', message=instance.title)
|
matrix_message.delay(prefix=' - REQUEST', message=instance.title)
|
||||||
|
|
||||||
|
|
||||||
post_save.connect(send_topic_update_email, sender=UserRequests)
|
post_save.connect(send_topic_update_email, sender=UserRequest)
|
||||||
|
|
|
@ -2,7 +2,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.core.mail import EmailMessage
|
from django.core.mail import EmailMessage
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from mhackspace.requests.forms import UserRequestForm
|
from mhackspace.requests.forms import UserRequestForm
|
||||||
from mhackspace.requests.models import UserRequests
|
from mhackspace.requests.models import UserRequest
|
||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
from django.views.generic.edit import FormView
|
from django.views.generic.edit import FormView
|
||||||
|
|
||||||
|
@ -23,6 +23,18 @@ class RequestsForm(LoginRequiredMixin, FormView):
|
||||||
|
|
||||||
class RequestsList(LoginRequiredMixin, ListView):
|
class RequestsList(LoginRequiredMixin, ListView):
|
||||||
template_name = 'pages/requests.html'
|
template_name = 'pages/requests.html'
|
||||||
model = UserRequests
|
model = UserRequest
|
||||||
context_object_name = 'requests'
|
context_object_name = 'requests'
|
||||||
paginate_by = 50
|
paginate_by = 50
|
||||||
|
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
new_context = UserRequest.objects.filter(
|
||||||
|
acquired=False,
|
||||||
|
)
|
||||||
|
return new_context
|
||||||
|
|
||||||
|
def get_context_data(self, *args, **kwargs):
|
||||||
|
context = super(RequestsList, self).get_context_data(*args, **kwargs)
|
||||||
|
context['requests_history'] = UserRequest.objects.filter(acquired=True)[:50]
|
||||||
|
return context
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<h3>Active Requests</h3>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -71,6 +72,42 @@
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Completed Requests</h3>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Detail</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for request in requests_history %}
|
||||||
|
<tr>
|
||||||
|
<th scope="row"> {{ forloop.counter }} </th>
|
||||||
|
<td>
|
||||||
|
{{ request.request_type_string }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ request.created_date }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ request.title }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button data-toggle="collapse" data-target="#expand{{forloop.counter}}" class="fa fa-expand ml-auto" ></button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td id="expand{{forloop.counter}}" colspan="5" class="collapse span-table">{{ request.description }}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,8 @@ braintree==3.37.2
|
||||||
django-autofixture==0.12.1
|
django-autofixture==0.12.1
|
||||||
|
|
||||||
git+https://github.com/olymk2/scaffold.git
|
git+https://github.com/olymk2/scaffold.git
|
||||||
#git+git://github.com/olymk2/django-wiki.git
|
git+git://github.com/olymk2/django-wiki.git
|
||||||
git+git://github.com/django-wiki/django-wiki.git
|
#git+git://github.com/django-wiki/django-wiki.git
|
||||||
|
|
||||||
djangorestframework==3.6.3
|
djangorestframework==3.6.3
|
||||||
djangorestframework-jwt
|
djangorestframework-jwt
|
||||||
|
|
Loading…
Reference in New Issue