diff --git a/.drone.yml b/.drone.yml index 41eba50..eec79f2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,7 +16,8 @@ steps: - pip install --user --cache-dir ./cache/pip -r ./requirements/test.txt - python manage.py compilescss - python manage.py collectstatic --no-input - - python manage.py test mhackspace --keepdb --verbosity 2 + - pytest -v +# - python manage.py test mhackspace --keepdb --verbosity 2 - name: publish-stage pull: True diff --git a/config/urls.py b/config/urls.py index 58db4e2..ea6612b 100644 --- a/config/urls.py +++ b/config/urls.py @@ -23,7 +23,7 @@ from mhackspace.blog.sitemaps import PostSitemap, CategorySitemap from mhackspace.feeds.views import FeedViewSet, ArticleViewSet from mhackspace.requests.views import RequestsForm, RequestsList, RequestsDetail, RequestsDetailForm from mhackspace.rfid.views import DeviceViewSet, AuthUserWithDeviceViewSet -from mhackspace.core.views import ChatView, AboutView +from mhackspace.core.views import ChatView, AboutView, StatusView from mhackspace.register.views import RegisterForm from mhackspace.wiki.urls import CustomWikiUrlPatterns @@ -49,6 +49,7 @@ sitemaps = { urlpatterns = [ url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name='home'), + url(r'^status/$', StatusView.as_view(), name='status'), url(r'^about/$', AboutView.as_view(template_name='pages/about.html'), name='about'), url(r'^chat/$', ChatView.as_view(template_name='pages/chat.html'), name='chat'), url(r'^mailing-list/$', TemplateView.as_view(template_name='pages/mailing-list.html'), name='group'), diff --git a/mhackspace/core/views.py b/mhackspace/core/views.py index bb16585..cda0e96 100644 --- a/mhackspace/core/views.py +++ b/mhackspace/core/views.py @@ -1,6 +1,8 @@ +from mhackspace.users.models import Membership from django.views.generic import TemplateView + class ChatView(TemplateView): def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) @@ -12,6 +14,17 @@ class ChatView(TemplateView): return context +class StatusView(TemplateView): + template_name = "partials/status.html" + + def get_context_data(self, *args, **kwargs): + membership_count = Membership.objects.all().count() + context = super().get_context_data(*args, **kwargs) + context["members"] = membership_count + context["atspace"] = membership_count + return context + + class AboutView(TemplateView): def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) diff --git a/mhackspace/subscriptions/payments.py b/mhackspace/subscriptions/payments.py index 487f39d..e0b3e9d 100644 --- a/mhackspace/subscriptions/payments.py +++ b/mhackspace/subscriptions/payments.py @@ -54,7 +54,7 @@ class gocardless_provider: customer = self.client.customers.get(mandate.links.customer) # TODO get the last couple of months not all time payments payments = self.client.payments.list(params={"customer": customer.id}).records - last_payments = None + last_payment = None if len(payments): last_payment = payments[0].charge_date diff --git a/mhackspace/subscriptions/tests/mocks.py b/mhackspace/subscriptions/tests/mocks.py index 5893498..424becf 100644 --- a/mhackspace/subscriptions/tests/mocks.py +++ b/mhackspace/subscriptions/tests/mocks.py @@ -18,6 +18,7 @@ class gocardlessMocks(TestCase): member = Membership() member.user = self.user1 member.payment = '20.00' + member.payment_date = self.date_now member.date = self.date_now member.save() return member @@ -63,9 +64,10 @@ class gocardlessMocks(TestCase): return_value={'status_code': '200'}) def mock_customer_success_responses(self): - ApiCustomersGet = namedtuple('ApiCustomersGet', 'email') + ApiCustomersGet = namedtuple('ApiCustomersGet', 'email, id') self.provider.client.customers.get = Mock( return_value=ApiCustomersGet( + id='1', email='test@test.com') ) diff --git a/mhackspace/templates/partials/status.html b/mhackspace/templates/partials/status.html new file mode 100644 index 0000000..abd3e53 --- /dev/null +++ b/mhackspace/templates/partials/status.html @@ -0,0 +1,4 @@ +
+
{{members}}
+
{{atspace}}
+
diff --git a/mhackspace/users/migrations/0014_membership_has_fob.py b/mhackspace/users/migrations/0014_membership_has_fob.py new file mode 100644 index 0000000..7693d26 --- /dev/null +++ b/mhackspace/users/migrations/0014_membership_has_fob.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.1 on 2019-01-14 19:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0013_increased_rfid_length'), + ] + + operations = [ + migrations.AddField( + model_name='membership', + name='has_fob', + field=models.BooleanField(default=False, help_text='Member has fob access'), + ), + ]