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
|
||||
AUTH_USER_MODEL = 'users.User'
|
||||
LOGIN_REDIRECT_URL = 'users:redirect'
|
||||
#LOGIN_URL = 'account_login'
|
||||
WIKI_SIGNUP_URL = 'account_login'
|
||||
WIKI_ACCOUNT_HANDLING = False
|
||||
#WIKI_EDITOR = 'wiki.editors.martor.Martor'
|
||||
WIKI_EDITOR = 'wiki.editors.martor.Martor'
|
||||
|
||||
# SLUGLIFIER
|
||||
AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify'
|
||||
|
||||
|
|
|
@ -5,12 +5,11 @@ from django.contrib.admin import ModelAdmin
|
|||
from martor.widgets import AdminMartorWidget
|
||||
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):
|
||||
list_display = ('title', 'description', 'created_date')
|
||||
# list_filter = ('author', 'categories', 'members_only')
|
||||
list_display = ('title', 'acquired', 'description', 'created_date')
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from django import forms
|
||||
from mhackspace.requests.models import UserRequests
|
||||
from mhackspace.requests.models import UserRequest
|
||||
from mhackspace.requests.models import REQUEST_TYPES
|
||||
|
||||
|
||||
class UserRequestForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = UserRequests
|
||||
model = UserRequest
|
||||
exclude = ['user', 'created_date']
|
||||
# description = forms.CharField(
|
||||
# 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'))
|
||||
|
||||
|
||||
class UserRequests(models.Model):
|
||||
class UserRequest(models.Model):
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
related_name='+'
|
||||
)
|
||||
title = models.CharField(max_length=255, help_text='Whats being requested ?')
|
||||
request_type = models.IntegerField(choices=REQUEST_TYPES, null=False)
|
||||
acquired = models.BooleanField()
|
||||
cost = models.DecimalField(
|
||||
max_digits=6,
|
||||
decimal_places=2,
|
||||
|
@ -40,12 +41,12 @@ class UserRequests(models.Model):
|
|||
# comment = models.TextField()
|
||||
# created_date = models.DateTimeField(default=timezone.now)
|
||||
|
||||
# class Meta:
|
||||
# ordering = ('created_date',)
|
||||
class Meta:
|
||||
ordering = ('acquired', 'created_date',)
|
||||
|
||||
|
||||
def send_topic_update_email(sender, instance, **kwargs):
|
||||
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.contrib import messages
|
||||
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.edit import FormView
|
||||
|
||||
|
@ -23,6 +23,18 @@ class RequestsForm(LoginRequiredMixin, FormView):
|
|||
|
||||
class RequestsList(LoginRequiredMixin, ListView):
|
||||
template_name = 'pages/requests.html'
|
||||
model = UserRequests
|
||||
model = UserRequest
|
||||
context_object_name = 'requests'
|
||||
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>
|
||||
</div>
|
||||
</div>
|
||||
<h3>Active Requests</h3>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -71,6 +72,42 @@
|
|||
|
||||
{% endfor %}
|
||||
</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 %}
|
||||
{% endblock content %}
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ braintree==3.37.2
|
|||
django-autofixture==0.12.1
|
||||
|
||||
git+https://github.com/olymk2/scaffold.git
|
||||
#git+git://github.com/olymk2/django-wiki.git
|
||||
git+git://github.com/django-wiki/django-wiki.git
|
||||
git+git://github.com/olymk2/django-wiki.git
|
||||
#git+git://github.com/django-wiki/django-wiki.git
|
||||
|
||||
djangorestframework==3.6.3
|
||||
djangorestframework-jwt
|
||||
|
|
Loading…
Reference in New Issue