Esempio n. 1
0
def Town(request):
    try:
        guild = GuildDB.objects.get(pk=request.user.id)
    except ObjectDoesNotExist:
        response = render_to_response('play/mercenaries_new.tpl', {}, context_instance=RequestContext(request))
        if 'text/html' in response['Content-Type']:
            response.content = short(response.content)
        return response
    
    response = render_to_response('play/town_home.tpl', {}, context_instance=RequestContext(request))
    if 'text/html' in response['Content-Type']:
        response.content = short(response.content)
    return response
Esempio n. 2
0
 def process_response(self, request, response):
     "Process response"
     if "text/html" in response["Content-Type"]:
         response.content = short(response.content)
     if settings.HARDTREE_MINIFY_JSON and settings.HARDTREE_RESPONSE_FORMATS["json"] in response["Content-Type"]:
         response.content = _minify_json(response.content)
     return response
def occurrences_to_json(request, occurrences, user):
    occ_list = []
    for occ in occurrences:
        original_id = occ.id
        occ_list.append({
            'id':
            encode_occurrence(occ),
            'title':
            occ.title,
            'start':
            occ.start.isoformat(),
            'end':
            occ.end.isoformat(),
            'recurring':
            bool(occ.event.rule),
            'persisted':
            bool(original_id),
            'description':
            occ.description.replace('\n', '\\n'),
            'allDay':
            False,
            'cancelled':
            occ.cancelled,
            'event_options':
            short(
                render_to_string("myagenda/event_options_wrapper.html",
                                 {'occ': occ},
                                 context_instance=RequestContext(request))),
        })

    return simplejson.dumps(occ_list)
Esempio n. 4
0
def LoginPage(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect("/play/mercenaries/")
    response = render_to_response('play/play_login.tpl', {}, context_instance=RequestContext(request))
    if 'text/html' in response['Content-Type']:
        response.content = short(response.content)
    return response
Esempio n. 5
0
def addmonster(request):
    d = Dungeon()
    d.load(int(request.POST["did"]))
    d.addmon(request.POST["data"])
    d.save()
    monster_infos = []
    for i in MonsterDB.objects.all():
        mon = {}
        mon["id"] = "%d" % i.mid
        mon["name"] = i.name
        monster_infos.append(mon)
    ailist = []
    for i in actmode.actionmodelist:
        ai = {}
        ai["id"] = "%d" % i.id
        ai["name"] = i.name
        ailist.append(ai)
    skill_list = []
    for i in skills.skilllist:
        sk = {}
        sk["id"] = "%d" % i.id
        sk["name"] = i.name
        skill_list.append(sk)
    response = render_to_response('dungeonmod_basic.tpl', {"did":request.POST["did"], "name":d.name, "minfo":monster_infos, "ailist":ailist, "sk":skill_list, "data":d.data}, context_instance=RequestContext(request))
    if 'text/html' in response['Content-Type']:
        response.content = short(response.content)
    return response
Esempio n. 6
0
 def process_response(self, request, response):
     """Process response"""
     if 'text/html' in response['Content-Type']:
         response.content = short(response.content)
     if settings.ANAF_MINIFY_JSON and settings.ANAF_RESPONSE_FORMATS['json'] in response['Content-Type']:
         response.content = _minify_json(response.content)
     return response
Esempio n. 7
0
 def process_response(self, request, response):
     if 'text/html' in response['Content-Type']:
         response.content = short(response.content)
         # Mixed MathML + HTML contents needs this content
         # type otherwise Firefox won't render the MathML
         if hasattr(response,'xhtml') or settings.FORCE_XHTML:
             response["Content-Type"] = "application/xhtml+xml; charset=utf-8"
     return response
Esempio n. 8
0
 def process_response(self, request, response):
     "Process response"
     if 'text/html' in response['Content-Type']:
         response.content = short(response.content)
     if settings.HARDTREE_MINIFY_JSON and settings.HARDTREE_RESPONSE_FORMATS[
             'json'] in response['Content-Type']:
         response.content = _minify_json(response.content)
     return response
Esempio n. 9
0
def testbattle(request, teamid1, teamid2):
    team1 = Dungeon().load(int(teamid1)).generateTeam()
    team2 = Dungeon().load(int(teamid2)).generateTeam()
    # AI
    be = BattleEngine(maxturn=200, action_spd=100)
    rec = be.battle(team1, team2)
    response = render_to_response('battlelog.tpl', {'log':rec})
    if 'text/html' in response['Content-Type']:
        response.content = short(response.content)
    return response
Esempio n. 10
0
class InstitutionAdmin(BodyAdmin):

    list_filter = ("institution_type", )

    def get_urls(self):
        from django.conf.urls.defaults import patterns, url

        def wrap(view):
            def wrapper(*args, **kwargs):
                return self.admin_site.admin_view(view)(*args, **kwargs)

            return update_wrapper(wrapper, view)

        info = self.model._meta.app_label, self.model._meta.module_name
        return patterns(
            '',
            url(r'^(.+)/move-(up)/$',
                wrap(self.move_view),
                name='%s_%s_move_up' % info),
            url(r'^(.+)/move-(down)/$',
                wrap(self.move_view),
                name='%s_%s_move_down' % info),
        ) + super(InstitutionAdmin, self).get_urls()

    def move_view(self, request, object_id, direction):
        obj = get_object_or_404(self.model, pk=unquote(object_id))
        if direction == 'up':
            obj.move_up()
        else:
            obj.move_down()
        return HttpResponseRedirect('../../')

    link_html = short("""
        <a href="../../%(app_label)s/%(module_name)s/%(object_id)s/move-up/">UP</a> |
        <a href="../../%(app_label)s/%(module_name)s/%(object_id)s/move-down/">DOWN</a> (%(position)s)
        """)

    def move_up_down_links(self, obj):
        return self.link_html % {
            'app_label': self.model._meta.app_label,
            'module_name': self.model._meta.module_name,
            'object_id': obj.id,
            'position': obj.position,
        }

    move_up_down_links.allow_tags = True
    move_up_down_links.short_description = _(u'Move')

    inlines = [InstitutionResourceInline, InstitutionChargeInline]
    list_display = (
        'name',
        'institution_type',
        'move_up_down_links',
    )
Esempio n. 11
0
def showdungeon(request):
    dungeon_infos = []
    for i in DungeonDB.objects.all():
        dun = {}
        dun["id"] = i.id
        dun["name"] = i.name
        dun["monsters"] = ""
        dungeon_infos.append(dun)
        dun["resetby"] = i.resetbybattle
    response = render_to_response('dungeonshow.tpl', {"dlist":dungeon_infos}, context_instance=RequestContext(request))
    if 'text/html' in response['Content-Type']:
        response.content = short(response.content)
    return response
Esempio n. 12
0
    def move_up_down_links(self, obj):
        link_html = short("""
            <a href="../../%(app_label)s/%(module_name)s/%(object_id)s/move-up/%(query_string)s">
                <img src="%(STATIC_URL)sordered_model/arrow-up.gif" alt="Move up" />
            </a>
            <a href="../../%(app_label)s/%(module_name)s/%(object_id)s/move-down/%(query_string)s">
                <img src="%(STATIC_URL)sordered_model/arrow-down.gif" alt="Move down" />
            </a>""")

        return link_html % {
            'app_label': self.model._meta.app_label,
            'module_name': self.model._meta.module_name,
            'object_id': obj.id,
            'STATIC_URL': settings.STATIC_URL,
            'query_string': self.request_query_string
        }
Esempio n. 13
0
class OrderedModelAdmin(admin.ModelAdmin):
    def get_urls(self):
        from django.conf.urls.defaults import patterns, url

        def wrap(view):
            def wrapper(*args, **kwargs):
                return self.admin_site.admin_view(view)(*args, **kwargs)

            return update_wrapper(wrapper, view)

        info = self.model._meta.app_label, self.model._meta.module_name
        return patterns(
            '',
            url(r'^(.+)/move-(up)/$',
                wrap(self.move_view),
                name='%s_%s_move_up' % info),
            url(r'^(.+)/move-(down)/$',
                wrap(self.move_view),
                name='%s_%s_move_down' % info),
        ) + super(OrderedModelAdmin, self).get_urls()

    def move_view(self, request, object_id, direction):
        obj = get_object_or_404(self.model, pk=unquote(object_id))
        if direction == 'up':
            obj.move_up()
        else:
            obj.move_down()
        return HttpResponseRedirect('../../')

    link_html = short("""
        <a href="../../%(app_label)s/%(module_name)s/%(object_id)s/move-up/">
            <img src="%(STATIC_URL)sordered_model/arrow-up.gif" alt="Move up" />
        </a>
        <a href="../../%(app_label)s/%(module_name)s/%(object_id)s/move-down/">
            <img src="%(STATIC_URL)sordered_model/arrow-down.gif" alt="Move down" />
        </a>""")

    def move_up_down_links(self, obj):
        return self.link_html % {
            'app_label': self.model._meta.app_label,
            'module_name': self.model._meta.module_name,
            'object_id': obj.id,
            'STATIC_URL': settings.STATIC_URL,
        }

    move_up_down_links.allow_tags = True
    move_up_down_links.short_description = _(u'Move')
Esempio n. 14
0
 def mw_response_stripSpaces(request, response):
     from django.utils.html import strip_spaces_between_tags as short
     
     if 'text/html' in response['Content-Type']: 
         response.content = short(response.content) 
         return response
Esempio n. 15
0
 def process_response(self, request, response):
     if 'text/html' in response['Content-Type']:
         response.content = short(response.content)
     return response
 def process_response(self, request, response, ):
     response_KEY = response.get('Content-Type', None, )
     if response_KEY and 'text/html' in response_KEY:  # 'text/html' in response['Content-Type']:
                                                       # response_content_type == 'text/html':
         response.content = short(response.content, )
     return response
def occurrences_to_html(request, occurences, user):
    return short(
        render_to_string('myagenda/event_list.html',
                         {'occurences': occurences},
                         context_instance=RequestContext(request)))
 def process_response(self, request, response):
     if 'text/html' in response['Content-Type']:
         response.content = short(response.content)
     return response