GithubHelp home page GithubHelp logo

pbaranay / django-magic-cards Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 1.0 3.11 MB

A pluggable Django app for the Oracle text of all Magic: the Gathering cards

License: MIT License

Makefile 3.62% Python 89.61% HTML 6.78%

django-magic-cards's People

Contributors

pbaranay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

frost0103q

django-magic-cards's Issues

Foreign Language Names

The mtgjson "extras" includes information about foreign language printings.

Please allow accessing foreign language printing information, like card name and multiverse IDs. I believe this would be a OneToMany from Printing to ForeignPrinting with the fields language, name, multiverse_id and the property image_url.

(http://mtgjson.com/documentation.html)

Card name field is not long enough

class Card(NameMixin, models.Model):
    name = models.CharField(max_length=127, unique=True)

However, R&D gave us "Our Market Research Shows That Players Like Really Long Card Names So We Made this Card to Have the Absolute Longest Card Name Ever Elemental", which has 141 characters.

Traceback:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/async/models.py", line 223, in execute
return atomic(execute)()
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 185, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/async/models.py", line 217, in execute
result = function(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 130, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/magic_cards/management/commands/import_magic_cards.py", line 27, in handle
import_cards(set_codes or Everything)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 185, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/magic_cards/utils/initial_import.py", line 117, in import_cards
parse_data(sets_data, set_codes)
File "/usr/local/lib/python2.7/dist-packages/magic_cards/utils/initial_import.py", line 82, in parse_data
'toughness': toughness,
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 475, in get_or_create
return self._create_object_from_params(lookup, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 505, in _create_object_from_params
obj = self.create(**params)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 399, in create
obj.save(force_insert=True, using=self.db)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 796, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 824, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 908, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 947, in _do_insert
using=using, raw=raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 1045, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 1054, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 110, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
DataError: (1406, "Data too long for column 'name' at row 1")

When importing a card, its list of subtypes should be set, not just added to

Currently, the import function examines a Card's subtypes, gets or creates an appropriate CardSubtype object, and adds a many-to-many linkage for each such CardSubtype. However, we should also take care to delete the many-to-many linkage for any subtypes that have been removed since the last update.

(The same logic applies for supertypes and types.)

Add some search fields to the admin

The models appear in the django admin, but there is no way to search for a specific card in the admin by name (or type/artist/set/whatever). The appropriate fields should be searchable.

Cards are not updated when reimported

Suppose the import is run multiple times, and MTGJSON has updated some cards' data in the interim. Unfortunately, these changes will not be picked up by the import script. This is especially obvious from the fact that, under current conditions, our latest field (loyalty) will not be added to any existing Card objects.

As a side consequence, the initial_import.py file should likely be renamed.

Printings expose bad Unicode data

Under Python 2, admin/magic_cards/printing/ cannot be loaded due to bad Unicode data on a handful of cards. Explore using python_2_unicode_compatible to fix.

Implement @property Card.typeline

A typeline @property on class Card which correctly orders supertypes, types, and subtypes, inserting a dash between types and subtypes if there are subtypes, would be useful, and I think it would be appropriate for this package.

@property
def typeline(self):
    typeline = ''
    if self.supertypes.exists():
        typeline += ' '.join(self.supertypes.values_list('name', flat=True))
        typeline += ' '
    typeline += ' '.join(self.types.values_list('name', flat=True))
    if self.subtypes.exists():
        typeline += ' โ€“ ' + ' '.join(self.subtypes.values_list('name', flat=True))
    return typeline

No idea if there's a correct sorting for any of the types of types, but if there is, it should probably be added to the class Meta in models.py?

Import magic cards command should display progress indicators

Typing ./manage.py import_magic_cards should present more output to the user. Some ideas:

  • Emit how many sets have been found to download.
  • Report when a set has been successfully downloaded.
  • Track when individual cards are downloaded (if doesn't slow things down).
  • Total time.

Split cards?

Split cards appear in your data source separately - i.e., there is an object with name="Cut", and one with name="Ribbons". There's no way to relate them together that I can see. How would you suggest handling card names like "Cut // Ribbons"? (IIRC, Judge Center displayed both halves side by side?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.