β¦on life, the universe, and everything
jiaaro / django-badges Goto Github PK
View Code? Open in Web Editor NEWAn easy to use django app that provides Foursquare/Stack Overflow style badges
License: GNU General Public License v3.0
An easy to use django app that provides Foursquare/Stack Overflow style badges
License: GNU General Public License v3.0
I've been chasing down a problem with badges not being in my database when I run unit tests. It's related to the registered_badges
dictionary.
The post_syncdb
hook in listeners.py
creates database objects based on MetaBadge
s and populates Badge._badge
with a reference to the model. However, my transaction-wrapped unit tests truncate the database at the beginning and end of each test. Now the database is empty but the Badge
believes it still has an object.
In the end, I've solved it by running this in my setUp
method:
from badges import listeners
from badges.utils import registered_badges
for badge in registered_badges.values():
del badge._badge
listeners.sync_badges_to_db()
My view is that a method like sync_badges_to_db
should always create badges in the database, or maybe there should be a method to force this.
More generally the post_syncdb
hook in listeners
has been causing problems too - in fact, the django documentation for this hook explicitly says that it's not recommended to change the database in this hook: https://docs.djangoproject.com/en/1.7/ref/signals/#post-syncdb
I understand that it's a useful way of making sure the database reflects the MetaBadges, but it feels like magic that is a little bit unexplained. I prefer the current system to when badges were created in __new__
, but I would like it more if badge creation was explicit. Maybe now django 1.7's AppConfig.ready
could be something to look at.
Request Method: | GET |
---|---|
http://0.0.0.0:8000/admin/badges/badge/exam/change/ | |
1.11.5 | |
NoReverseMatch | |
Reverse for 'badge_detail' not found. 'badge_detail' is not a valid view function or pattern name. | |
/usr/local/lib/python3.5/site-packages/django/urls/resolvers.py in _reverse_with_prefix, line 497 | |
/usr/local/bin/python | |
3.5.4 |
Automatic registration, from MetaBadgeMeta does not work, and it is necessary to register manually.
Is it correct?
Need to use something like:
from django.conf.urls import patterns, url, include
instead.
https://github.com/jiaaro/django-badges/blob/master/badges/urls.py#L1
is already obsolete for newer versions of django.
I can not receive the signal.
There are no errors, I see the saving of the BadgeToUser model, but the signal does not come
RemovedInDjango19Warning: Model class badges.models.Badge doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded.
This will no longer be supported in Django 1.9.class Badge(models.Model):
when package installed with pip and urlpatterns += [url(r'^badges/', include(badges.urls)),]
page fails with
TemplateDoesNotExist at /badges/
badges/overview.html
Is it possible to remove badges from user, when check conditions are no longer true?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.