-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Daabase, Cards stats and images, add card to collection
- Loading branch information
1 parent
bde9234
commit a379805
Showing
33 changed files
with
2,129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory": "cpro/static/bower/" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "cprowebsite", | ||
"version": "0.0.0", | ||
"authors": [ | ||
"db0company <[email protected]>" | ||
], | ||
"description": "Database and community for IdolMaster Cinderella Girls Starlight Stage players.", | ||
"license": "Apache2", | ||
"dependencies": { | ||
"Autolinker.js": "0.15.2", | ||
"CuteForm": "~0.0.3", | ||
"bootstrap": "~3.3.5", | ||
"css-hexagon": "0.0.0", | ||
"github-wiki": "js-github-wiki#*", | ||
"jquery-visible": "1.2.0", | ||
"less": "~2.0.0", | ||
"navbar-variant": "~0.0.0", | ||
"jquery-easing": "*" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.contrib import admin | ||
from cpro import models | ||
|
||
admin.site.register(models.Account) | ||
admin.site.register(models.Event) | ||
admin.site.register(models.Idol) | ||
admin.site.register(models.Card) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from cpro import forms | ||
|
||
def getAccountForm(request, context, collection): | ||
formClass = forms.AccountFormSimple | ||
if 'advanced' in request.GET: | ||
formClass = forms.AccountFormAdvanced | ||
context['advanced'] = True | ||
return formClass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.db.models import Q | ||
|
||
def filterCards(queryset, parameters, request): | ||
if request.user.is_authenticated(): | ||
request.user.all_accounts = request.user.accounts.all() | ||
accounts_pks = ','.join([str(account.pk) for account in request.user.all_accounts]) | ||
if accounts_pks: | ||
queryset = queryset.extra(select={ | ||
'total_owned': 'SELECT COUNT(*) FROM cpro_ownedcard WHERE card_id = cpro_card.id AND account_id IN ({})'.format(accounts_pks), | ||
}) | ||
if 'search' in parameters and parameters['search']: | ||
terms = parameters['search'].split(' ') | ||
for term in terms: | ||
queryset = queryset.filter(Q(name__icontains=term) | ||
| Q(types_string__icontains=term) | ||
) | ||
if 'i_rarity' in parameters and parameters['i_rarity']: | ||
queryset = queryset.filter(i_rarity=parameters['i_rarity']) | ||
if 'type' in parameters and parameters['type']: | ||
queryset = queryset.filter(idol__i_type=parameters['type']) | ||
if 'is_event' in parameters and parameters['is_event']: | ||
if parameters['is_event'] == '2': | ||
queryset = queryset.filter(event__isnull=False) | ||
elif parameters['is_event'] == '3': | ||
queryset = queryset.filter(event__isnull=True) | ||
if 'is_limited' in parameters and parameters['is_limited']: | ||
if parameters['is_limited'] == '2': | ||
queryset = queryset.filter(is_limited=True) | ||
elif parameters['is_limited'] == '3': | ||
queryset = queryset.filter(is_limited=False) | ||
if 'has_art' in parameters and parameters['has_art']: | ||
if parameters['has_art'] == '2': | ||
queryset = queryset.filter(art__isnull=False).exclude(art='') | ||
elif parameters['has_art'] == '3': | ||
queryset = queryset.filter(Q(art__isnull=True) | Q(art='')) | ||
if 'i_skill' in parameters and parameters['i_skill']: | ||
queryset = queryset.filter(i_skill=parameters['i_skill']) | ||
return queryset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
from django.utils.translation import ugettext_lazy as _, string_concat | ||
from django.db.models.fields import BLANK_CHOICE_DASH | ||
from django import forms | ||
from cpro import models | ||
|
||
class FormWithRequest(forms.ModelForm): | ||
def __init__(self, *args, **kwargs): | ||
self.request = kwargs.pop('request', None) | ||
self.is_creating = not hasattr(self, 'instance') or not self.instance.pk | ||
super(FormWithRequest, self).__init__(*args, **kwargs) | ||
# Fix optional fields | ||
if hasattr(self.Meta, 'optional_fields'): | ||
for field in self.Meta.optional_fields: | ||
if field in self.fields: | ||
self.fields[field].required = False | ||
# Fix dates inputs | ||
if hasattr(self.Meta, 'date_fields'): | ||
for field in self.Meta.date_fields: | ||
if field in self.fields: | ||
self.fields[field] = date_input(self.fields[field]) | ||
|
||
def save(self, commit=True): | ||
instance = super(FormWithRequest, self).save(commit=False) | ||
# Fix empty strings to None | ||
for field in self.fields.keys(): | ||
if (hasattr(instance, field) | ||
and (type(getattr(instance, field)) == unicode or type(getattr(instance, field)) == str) | ||
and getattr(instance, field) == ''): | ||
setattr(instance, field, None) | ||
if commit: | ||
instance.save() | ||
return instance | ||
|
||
class FormSaveOwnerOnCreation(FormWithRequest): | ||
def save(self, commit=True): | ||
instance = super(FormSaveOwnerOnCreation, self).save(commit=False) | ||
if self.is_creating: | ||
instance.owner = self.request.user | ||
if commit: | ||
instance.save() | ||
return instance | ||
|
||
class DateInput(forms.DateInput): | ||
input_type = 'date' | ||
|
||
def date_input(field): | ||
field.widget = DateInput() | ||
field.widget.attrs.update({ | ||
'class': 'calendar-widget', | ||
'data-role': 'data', | ||
}) | ||
return field | ||
|
||
############################################################ | ||
# Account | ||
|
||
class _AccountForm(FormWithRequest): | ||
def __init__(self, *args, **kwargs): | ||
super(_AccountForm, self).__init__(*args, **kwargs) | ||
if 'starter' in self.fields: | ||
self.fields['starter'].queryset = models.Card.objects.filter(pk__in=[100001, 200001, 300001]) | ||
self.fields['starter'].initial = 100001 | ||
|
||
class AccountFormSimple(_AccountForm): | ||
class Meta: | ||
model = models.Account | ||
fields = ('game_id', 'level', 'starter') | ||
optional_fields = ('game_id', 'level') | ||
|
||
class AccountFormAdvanced(_AccountForm): | ||
class Meta: | ||
model = models.Account | ||
fields = ('nickname', 'game_id', 'level', 'accept_friend_requests', 'device', 'play_with', 'os', 'center', 'starter', 'start_date', 'producer_rank') | ||
optional_fields = ('nickname', 'game_id', 'level', 'accept_friend_requests', 'device', 'play_with', 'os', 'center', 'start_date', 'producer_rank') | ||
date_fields = ('start_date', ) | ||
|
||
############################################################ | ||
# Idol | ||
|
||
class IdolForm(FormSaveOwnerOnCreation): | ||
class Meta: | ||
model = models.Idol | ||
fields = ('name', 'japanese_name', 'i_type', 'age', 'birthday', 'height', 'weight', 'i_blood_type', 'i_writing_hand', 'bust', 'waist', 'hips', 'i_astrological_sign', 'hometown', 'romaji_hometown', 'hobbies', 'description', 'CV', 'romaji_CV', 'image', 'signature') | ||
optional_fields = ('japanese_name', 'i_type', 'age', 'birthday', 'height', 'weight', 'i_blood_type', 'i_writing_hand', 'bust', 'waist', 'hips', 'i_astrological_sign', 'hometown', 'romaji_hometown', 'hobbies', 'description', 'CV', 'romaji_CV', 'signature') | ||
date_fields = ('birthday', ) | ||
|
||
############################################################ | ||
# Event | ||
|
||
class EventForm(FormSaveOwnerOnCreation): | ||
beginning = forms.DateField(label=_('Beginning')) | ||
end = forms.DateField(label=_('End')) | ||
|
||
class Meta: | ||
model = models.Event | ||
fields = ('name', 'translated_name', 'image', 'beginning', 'end', 't1_points', 't1_rank', 't2_points', 't2_rank', 't3_points', 't3_rank', 't4_points', 't4_rank', 't5_points', 't5_rank') | ||
optional_fields = ('translated_name', 't1_points', 't1_rank', 't2_points', 't2_rank', 't3_points', 't3_rank', 't4_points', 't4_rank', 't5_points', 't5_rank') | ||
date_fields = ('beginning', 'end') | ||
|
||
############################################################ | ||
# Card | ||
|
||
class CardForm(FormSaveOwnerOnCreation): | ||
class Meta: | ||
model = models.Card | ||
fields = ('id', 'id_awakened', 'idol', 'i_rarity', 'release_date', 'event', 'is_limited', 'title', 'translated_title', 'image', 'image_awakened', 'art', 'art_awakened', 'transparent', 'transparent_awakened', 'icon', 'icon_awakened', 'puchi', 'puchi_awakened', 'hp_min', 'hp_max', 'hp_awakened_min', 'hp_awakened_max', 'vocal_min', 'vocal_max', 'vocal_awakened_min', 'vocal_awakened_max', 'dance_min', 'dance_max', 'dance_awakened_min', 'dance_awakened_max', 'visual_min', 'visual_max', 'visual_awakened_min', 'visual_awakened_max', 'skill_name', 'translated_skill_name', 'i_skill', 'trigger_value', 'trigger_chance_min', 'trigger_chance_max', 'skill_duration_min', 'skill_duration_max', 'skill_value', 'skill_value2') | ||
optional_fields = ('id_awakened', 'release_date', 'event', 'title', 'translated_title', 'image_awakened', 'art', 'art_awakened', 'transparent', 'transparent_awakened', 'icon', 'icon_awakened', 'puchi', 'puchi_awakened', 'hp_min', 'hp_max', 'hp_awakened_min', 'hp_awakened_max', 'vocal_min', 'vocal_max', 'vocal_awakened_min', 'vocal_awakened_max', 'dance_min', 'dance_max', 'dance_awakened_min', 'dance_awakened_max', 'visual_min', 'visual_max', 'visual_awakened_min', 'visual_awakened_max', 'skill_name', 'translated_skill_name', 'i_skill', 'trigger_value', 'trigger_chance_min', 'trigger_chance_max', 'skill_duration_min', 'skill_duration_max', 'skill_value', 'skill_value2') | ||
date_fields = ('release_date', ) | ||
|
||
class FilterCards(FormWithRequest): | ||
search = forms.CharField(required=False) | ||
type = forms.ChoiceField(choices=BLANK_CHOICE_DASH + models.TYPE_CHOICES, required=False, label=_('Type')) | ||
is_event = forms.NullBooleanField(required=False, initial=None, label=_('Event')) | ||
is_limited = forms.NullBooleanField(required=False, initial=None, label=_('Limited')) | ||
has_art = forms.NullBooleanField(required=False, initial=None, label=_('Art')) | ||
ordering = forms.ChoiceField(choices=[ | ||
('release_date', _('Release Date')), | ||
('id', _('ID')), | ||
('i_rarity', _('Rarity')), | ||
('vocal_max', _('Vocal')), | ||
('vocal_awakened_max', string_concat(_('Vocal'), ' (', _('Awakened'), ')')), | ||
('dance_max', _('Dance')), | ||
('dance_awakened_max', string_concat(_('Dance'), ' (', _('Awakened'), ')')), | ||
('visual_max', _('Visual')), | ||
('visual_awakened_max', string_concat(_('Visual'), ' (', _('Awakened'), ')')), | ||
('hp_max', _('HP')), | ||
('hp_awakened_max', string_concat(_('HP'), ' (', _('Awakened'), ')')), | ||
], initial='level', required=False) | ||
reverse_order = forms.BooleanField(initial=True, required=False) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(FilterCards, self).__init__(*args, **kwargs) | ||
|
||
class Meta: | ||
model = models.Card | ||
fields = ('search', 'i_rarity', 'type', 'is_event', 'is_limited', 'has_art', 'i_skill', 'ordering', 'reverse_order') | ||
optional_fields = ('i_skill', 'i_rarity') | ||
|
||
############################################################ | ||
# Owned Card | ||
|
||
class EditOwnedCardForm(FormWithRequest): | ||
class Meta: | ||
model = models.OwnedCard | ||
fields = ('awakened', 'max_bonded', 'max_leveled', 'star_rank', 'skill_level') | ||
date_fields = ('obtained_date', ) |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import time | ||
from django.core.management.base import BaseCommand, CommandError | ||
from django.utils import timezone | ||
from django.conf import settings as django_settings | ||
from web.tools import totalDonators | ||
from cpro import models | ||
|
||
def generate_settings(): | ||
|
||
print 'Get total donators' | ||
total_donators = totalDonators() | ||
|
||
print 'Get the latest news' | ||
try: | ||
current_events = models.Event.objects.get(end__lte=timezone.now()) | ||
latest_news = [{ | ||
'title': event.name, | ||
'image': event.image_url, | ||
'url': event.item_url, | ||
} for event in current_events] | ||
except: | ||
latest_news = [] | ||
|
||
print 'Get the characters' | ||
all_idols = models.Idol.objects.all().order_by('name') | ||
favorite_characters = [( | ||
idol.pk, | ||
idol.name, | ||
idol.image_url, | ||
) for idol in all_idols] | ||
|
||
print 'Get max stats' | ||
stats = { | ||
'hp_max': None, | ||
'hp_awakened_max': None, | ||
'vocal_max': None, | ||
'vocal_awakened_max': None, | ||
'dance_max': None, | ||
'dance_awakened_max': None, | ||
'visual_max': None, | ||
'visual_awakened_max': None, | ||
'overall_max_': None, | ||
'overall_awakened_max_': None, | ||
} | ||
for stat in stats.keys(): | ||
max_stats = models.Card.objects.all().extra(select={ | ||
'overall_max_': 'vocal_max + dance_max + visual_max', | ||
'overall_awakened_max_': 'vocal_awakened_max + dance_awakened_max + visual_awakened_max', | ||
}).order_by('-' + stat)[0] | ||
stats[stat] = getattr(max_stats, stat) | ||
stats['overall_max'] = stats['overall_max_'] | ||
del(stats['overall_max_']) | ||
stats['overall_awakened_max'] = stats['overall_awakened_max_'] | ||
del(stats['overall_awakened_max_']) | ||
|
||
print 'Save generated settings' | ||
s = u'\ | ||
import datetime\n\ | ||
TOTAL_DONATORS = ' + unicode(total_donators) + u'\n\ | ||
LATEST_NEWS = ' + unicode(latest_news) + u'\n\ | ||
FAVORITE_CHARACTERS = ' + unicode(favorite_characters) + u'\n\ | ||
MAX_STATS = ' + unicode(stats) + u'\n\ | ||
GENERATED_DATE = datetime.datetime.fromtimestamp(' + unicode(time.time()) + u')\n\ | ||
' | ||
print s | ||
with open(django_settings.BASE_DIR + '/' + django_settings.SITE + '_project/generated_settings.py', 'w') as f: | ||
print >> f, s | ||
f.close() | ||
|
||
class Command(BaseCommand): | ||
can_import_settings = True | ||
|
||
def handle(self, *args, **options): | ||
generate_settings() |
Oops, something went wrong.