コード例 #1
0
class CardBlock(blocks.StructBlock):
    """Cards with image and text and button(s)."""

    title = blocks.CharBlock(required=True, help_text=tr("Add your title"))
    bg_image = ImageChooserBlock(required=False,
                                 blank=False,
                                 null=True,
                                 on_delete=models.SET_NULL)

    cards = blocks.ListBlock(
        blocks.StructBlock([
            ("image", ImageChooserBlock(required=False)),
            ("title", blocks.CharBlock(required=True, max_length=40)),
            ("text", blocks.TextBlock(required=True, max_length=200)),
            ("button_page", blocks.PageChooserBlock(required=False)),
            (
                "button_url",
                blocks.URLBlock(
                    required=False,
                    help_text=tr(
                        "If the button page above is selected, that will be used first."
                    ),  # noqa
                ),
            ),
        ]))

    class Meta:  # noqa
        template = "streams/card_block.html"
        icon = "placeholder"
        label = tr("Staff Cards")
コード例 #2
0
ファイル: views.py プロジェクト: rasmadeus/rfix
def _guest(req):
    template = get_template('guest.html')
    context = {
        'header': tr('RFIX'),
        'subheader': tr('lightweight bug tracker'),
    }
    return HttpResponse(template.render(context, req))
コード例 #3
0
class TitleAndTextBlock(blocks.StructBlock):
    """Title and text and nothing else."""

    title = blocks.CharBlock(required=True, help_text=tr("Add your title"))
    text = blocks.TextBlock(required=True, help_text=tr("Add additional text"))

    class Meta:  # noqa
        template = "streams/title_and_text_block.html"
        icon = "edit"
        label = tr("Title & Text")
コード例 #4
0
class BillingForm(forms.Form):
    address = forms.ModelChoiceField(
        help_text=tr('Choose your billing address'),
        queryset=Address.objects.all(),
        initial=0)
    customer_message = forms.CharField(
        required=False,
        help_text=tr('Do you want to leave us a message about your order?'),
        widget=forms.Textarea(attrs={
            "rows": 5,
            "cols": 80
        }))
コード例 #5
0
ファイル: views.py プロジェクト: rasmadeus/rfix
def _links_auth(req):
    return {
        'links': (
            {
                'name': tr('Projects'),
                'href': '#',
                'sublinks': (
                    {'name': project.name, 'href': project.get_absolute_url()}
                    for project in Project.objects.all()
                ),
            },
            {'name': tr('Support'), 'href': '/support'},
            {'name': tr('Login'), 'href': '/users/login'},
        )
    }
コード例 #6
0
ファイル: models.py プロジェクト: hufeng03/django-gitcms
class Menu(models.Model):
    name = models.CharField(tr('Name'), max_length=255)
    fake_root = models.ForeignKey(MenuItem)

    def _get_children(self):
        return self.fake_root.children.all()

    children = property(_get_children)
コード例 #7
0
class SupplierSignupForm(SignupForm):
    ## declare here all the extra fields in SupplierUser model WITHOUT
    ## the OneToOneField to User
    ## (N.B: do NOT try to declare Meta class with model=SupplierUser,
    ## it won't work!) ex:
    brand_name = forms.CharField(max_length=100, label=tr("Brand name"))
    first_name = forms.CharField(label=tr('First name'), max_length=30)
    last_name = forms.CharField(label=tr('Last name'), max_length=150)

    # phone_regex = RegexValidator(regex=r"^\+(?:[0-9]●?){6,14}[0-9]$", message=tr("Enter a valid international mobile phone number starting with +(country code)"))
    # mobile_phone = forms.CharField(validators=[phone_regex], label=tr("Mobile phone"), max_length=17)

    def __init__(self, *args, **kwargs):
        SignupForm.__init__(self, *args, **kwargs)

    def clean(self):
        super(SupplierSignupForm, self).clean()

    ## Override the save method to save the extra fields
    ## (otherwise the form will save the User instance only)
    def save(self, request):
        ## Save the User instance and get a reference to it
        user = super(SupplierSignupForm, self).save(request)
        user.first_name = self.cleaned_data['first_name']
        user.last_name = self.cleaned_data['last_name']
        user.is_supplier = True
        user.is_manager = False
        user.save()

        ## Create an instance of your model with the extra fields
        ## then save it.
        ## (N.B: the are already cleaned, but if you want to do some
        ## extra cleaning just override the clean method as usual)
        supplier_user = SupplierUser(
            user=user,
            brand_name=self.cleaned_data['brand_name']
            ## Here add your extra fields from the SupplierUser table
            # supplieruser_fields=self.cleaned_data.get('supplieruser_fields')
        )
        supplier_user.save()

        # Remember to return the User instance (not your custom user,
        # the Django one), otherwise you will get an error when the
        # complete_signup method will try to look at it.
        return supplier_user.user
コード例 #8
0
class CustomerSignupForm(SignupForm):
    ## declare here all the extra fields in CustomerUser model WITHOUT
    ## the OneToOneField to User
    ## (N.B: do NOT try to declare Meta class with model=CustomerUser,
    ## it won't work!)
    first_name = forms.CharField(label=tr('First name'), max_length=30)
    last_name = forms.CharField(label=tr('Last name'), max_length=150)

    ## Call SignupForm.__init__ to make sure you get the extra password fields:
    def __init__(self, *args, **kwargs):
        SignupForm.__init__(self, *args, **kwargs)

    def clean(self):
        super(CustomerSignupForm, self).clean()

    ## Override the save method to save the extra fields
    ## (otherwise the form will save the User instance only)
    def save(self, request):
        ## Save the User instance and get a reference to it
        user = super(CustomerSignupForm, self).save(request)
        user.first_name = self.cleaned_data['first_name']
        user.last_name = self.cleaned_data['last_name']

        user.is_supplier = False
        user.is_manager = False

        user.save()

        ## Create an instance of your model with the extra fields
        ## then save it.
        ## (N.B: the are already cleaned, but if you want to do some
        ## extra cleaning just override the clean method as usual)
        customer_user = CustomerUser(
            user=user,
            ## Here add your extra fields from the SupplierUser table
            # supplieruser_fields=self.cleaned_data.get('supplieruser_fields')
        )
        customer_user.save()

        # Remember to return the User instance (not your custom user,
        # the Django one), otherwise you will get an error when the
        # complete_signup method will try to look at it.
        return customer_user.user
コード例 #9
0
ファイル: views.py プロジェクト: rasmadeus/rfix
    def get_context_data(self, **kwargs):
        context = super(RfixUserDetail, self).get_context_data(**kwargs)

        user = context['rfixuser']

        context['groups'] = (
            {
                'header': tr('Tasks to perform'),
                'tasks': Task.objects.filter(performer=user)
            },
            {
                'header': tr('Tasks to review'),
                'tasks': Task.objects.filter(reviewer=user)
            },
            {
                'header': tr('Tasks to test'),
                'tasks': Task.objects.filter(tester=user)
            },
        )

        return context
コード例 #10
0
ファイル: models.py プロジェクト: vanderheyde/ecm
class GarbageCollector(models.Model):

    AGE_UNIT_CHOICES = (
        (3600 * 24, tr("days")),
        (3600 * 24 * 7, tr("weeks")),
        (3600 * 24 * 7 * 30, tr("months"))
    )

    DATE_FIELD = 'DATE_FIELD'

    model = models.CharField(max_length=255, primary_key=True,
                             validators=[ModelValidator()])
    min_entries_threshold = models.BigIntegerField(default=10000)
    max_age_threshold = models.BigIntegerField()
    age_units = models.BigIntegerField(default=3600 * 24 * 7 * 30, choices=AGE_UNIT_CHOICES)

    def model_admin_display(self):
        return self.model
    model_admin_display.short_description = tr("Database Model")

    def max_age_threshold_admin_display(self):
        max_age_thres = self.max_age_threshold
        age_unit_disp = self.get_age_units_display()
        return '%s %s' % (max_age_thres, age_unit_disp)
    max_age_threshold_admin_display.short_description = tr("Max Age Threshold")

    def get_expiration_date(self):
        return timezone.now() + timedelta(seconds=self.max_age_threshold * self.age_units)

    def get_model(self):
        return extract_model(self.model)

    def model_has_date_field(self):
        model = self.get_model()
        if hasattr(model, self.DATE_FIELD):
            date_field_name = getattr(model, self.DATE_FIELD)
            for field in model._meta.fields:
                if field.name == date_field_name:
                    return True
        return False
コード例 #11
0
def player_contrib_data(request):
    """
    View function URL : '/accounting/contributions/players/data/'
    """
    try:
        params = extract_datatable_params(request)
        REQ = request.GET if request.method == 'GET' else request.POST
        params.from_date = timezone.make_aware(
            datetime.strptime(REQ.get('from_date', None), DATE_PATTERN),
            timezone.get_current_timezone())
        to_date = datetime.strptime(REQ.get('to_date', None), DATE_PATTERN)
        if to_date.hour == 0 and to_date.minute == 0 and to_date.second == 0:
            to_date += timedelta(1)
        params.to_date = timezone.make_aware(to_date,
                                             timezone.get_current_timezone())
    except:
        return HttpResponseBadRequest()

    contributions = player_contributions(since=params.from_date,
                                         until=params.to_date,
                                         order_by=columns[params.column],
                                         ascending=params.asc)
    count = len(contributions[:])
    contributions = contributions[params.first_id:params.last_id]

    contrib_list = []
    for c in contributions:
        if c.username == None:
            contrib_list.append(
                [tr('not associated'),
                 print_float(c.tax_contrib)])
        else:
            contrib_list.append([
                '<a href="%s" class="player">%s</a>' %
                (c.get_absolute_url(), c.username),
                print_float(c.tax_contrib)
            ])

    json_data = {
        "sEcho": params.sEcho,
        "iTotalRecords": count,
        "iTotalDisplayRecords": count,
        "aaData": contrib_list
    }

    return HttpResponse(json.dumps(json_data))
コード例 #12
0
ファイル: contrib.py プロジェクト: Betriebsrat/ecm
def player_contrib_data(request):
    """
    View function URL : '/accounting/contributions/players/data/'
    """
    try:
        params = extract_datatable_params(request)
        REQ = request.GET if request.method == 'GET' else request.POST
        params.from_date = timezone.make_aware(datetime.strptime(REQ.get('from_date', None), DATE_PATTERN), timezone.get_current_timezone())
        to_date = datetime.strptime(REQ.get('to_date', None), DATE_PATTERN)
        if to_date.hour == 0 and to_date.minute == 0 and to_date.second == 0:
            to_date += timedelta(1)
        params.to_date = timezone.make_aware(to_date, timezone.get_current_timezone())
    except:
        return HttpResponseBadRequest()

    contributions = player_contributions(since=params.from_date,
                                         until=params.to_date,
                                         order_by=columns[params.column],
                                         ascending=params.asc)
    count = len(contributions[:])
    contributions = contributions[params.first_id:params.last_id]

    contrib_list = []
    for c in contributions:
        if c.username == None:
            contrib_list.append([
                tr('not associated'),
                print_float(c.tax_contrib)
            ])
        else:
            contrib_list.append([
                '<a href="%s" class="player">%s</a>' % (c.get_absolute_url(),c.username),
                print_float(c.tax_contrib)
            ])

    json_data = {
        "sEcho" : params.sEcho,
        "iTotalRecords" : count,
        "iTotalDisplayRecords" : count,
        "aaData" : contrib_list
    }

    return HttpResponse(json.dumps(json_data))
コード例 #13
0
    def like(self, *args, **kwargs):

        post = get_object_or_404(Post, id=kwargs.get('pk'))

        if self.request.method == 'DELETE':
            like = PostLike.objects.filter(post_id=post.id,
                                           reacted_id=self.request.user.id)

            with transaction.atomic():
                deleted, _ = like.delete()
                if not deleted:
                    return JsonResponse({"message": "Not found"}, status=404)
                Post.objects.filter(id=post.id).update(likes=F('likes') - 1)
        elif self.request.method == 'POST':
            try:
                with transaction.atomic():
                    like, created = PostLike.objects.get_or_create(
                        post_id=post.id, reacted_id=self.request.user.id)

                    if created:
                        Post.objects.filter(id=post.id).update(
                            likes=F('likes') + 1)
                    else:
                        # we can omit this response - depends on arch and client
                        return JsonResponse(
                            {
                                "message":
                                tr("You've already liked this post"),
                            },
                            status=400)

            except IntegrityError:
                # get or create  handles race condition problem
                # with getting already created object
                # but in that case we can be trapped to case where obj removed.
                # Todo a)simple solution, job with synchronous queue for high load likes for whole likes issue
                return JsonResponse({
                    "message": "Please try one more time",
                },
                                    status=429)

        return JsonResponse({"message": "Successfully"})
コード例 #14
0
ファイル: pos.py プロジェクト: vanderheyde/ecm
def get_basic_info(pos, api_row):
    """
    The XML API result of StarbaseList is

    <eveapi version="2">
        <currentTime>2011-04-24 00:24:31</currentTime>
        <result>
            <rowset name="starbases" key="itemID"
                    columns="itemID,typeID,locationID,moonID,state,...">
                <row itemID="1001853458191"
                     typeID="16213"
                     locationID="30002924"
                     moonID="40185540"
                     state="4"
                     stateTimestamp="2011-04-24 01:15:55"
                     onlineTimestamp="2011-04-02 08:14:47"
                     standingOwnerID="1354830081"/>
                [...]
            </rowset>
        </result>
        <cachedUntil>2011-04-24 06:21:31</cachedUntil>
    </eveapi>
    """
    pos.item_id = api_row.itemID
    pos.location_id = api_row.locationID
    pos.moon_id = api_row.moonID
    pos.type_id = api_row.typeID
    pos.state = api_row.state

    pos.location = CelestialObject.objects.get(itemID=pos.location_id).itemName
    if pos.state != 0: #unanchored
        pos.moon = CelestialObject.objects.get(itemID=pos.moon_id).itemName
    else:
        pos.moon = tr('unanchored')

    item = Type.objects.get(pk=pos.type_id)
    pos.type_name = item.typeName
    pos.fuel_type_id = constants.RACE_TO_FUEL[item.raceID]
コード例 #15
0
ファイル: views.py プロジェクト: luispedro/refsweb
def get_doi(request, doi, format):
    '''
    get_doi

    Lookup a reference based on its DOI.
    '''
    if format != 'bibtex+html':
        return _wrong_format(format)
    results = BibTexEntry.objects.filter(doi=doi)
    if not results:
        return render_to_response('notfound.html')
    if len(results) > 1:
        return render_to_response('error.html', {
            'error': tr(u'<p>Sorry mate, this is all very confusing.</p>')
        })
    b = results[0]
    bibvalues = b.__dict__.items()
    return render_to_response('bibtex.html',
        {
            'bibtype' : 'article',
            'bibcode' : 'wikirefs_download',
            'bibentries' : bibvalues,
        })
コード例 #16
0
from django.template.context import RequestContext as Ctx
from django.utils.translation import ugettext as tr

from ecm.utils import db
from ecm.utils import _json as json
from ecm.utils.format import print_time_min
from ecm.apps.hr.models import TitleComposition, Title
from ecm.apps.common.models import ColorThreshold, UpdateDate
from ecm.apps.corp.models import Corporation
from ecm.views.decorators import check_user_access
from ecm.views import datatable_ajax_data, extract_datatable_params, DATATABLES_DEFAULTS
from ecm.apps.hr import NAME as app_prefix

TITLES_COLUMNS = [
    {
        'sTitle': tr('Title Name'),
        'sWidth': '40%',
        'db_field': 'titleName',
    },
    {
        'sTitle': tr('Access Level'),
        'sWidth': '20%',
        'db_field': 'accessLvl',
    },
    {
        'sTitle': tr('Members'),
        'sWidth': '10%',
        'db_field': None,
        'bSortable': False,
    },
    {
コード例 #17
0
 class Meta:  # noqa
     template = "streams/title_and_text_block.html"
     icon = "edit"
     label = tr("Title & Text")
コード例 #18
0
ファイル: mail.py プロジェクト: Betriebsrat/ecm
from django.template.context import RequestContext
from django.shortcuts import render_to_response
from django.http import HttpResponseBadRequest
from django.utils.translation import ugettext as tr
from django.contrib.contenttypes.models import ContentType

from ecm.views.decorators import check_user_access
from ecm.views import extract_datatable_params, datatable_ajax_data, datatable_csv_data
from ecm.plugins.mail.models import Mail, Recipient, MailingList
from ecm.apps.hr.models.member import Member
from ecm.apps.corp.models import Corporation, Alliance
from ecm.views import DATATABLES_DEFAULTS
from ecm.utils.format import print_time_min

COLUMNS = [
    {'sTitle': tr('Sent Date'),    'sWidth': '10%',   'db_field': 'sentDate', },
    {'sTitle': tr('Sender'),       'sWidth': '15%',   'db_field': 'sender', },
    {'sTitle': tr('Recipients'),   'sWidth': '25%',   'bSortable': False},
    {'sTitle': tr('Title'),        'sWidth': '50%',   'db_field': 'title', },
    {'sTitle': tr('id'),           'bVisible': False, 'db_field': 'id', },
]

#------------------------------------------------------------------------------
@check_user_access()
def mail_list(request):
    corps = set()
    alliances = set()
    corp_type = ContentType.objects.get(app_label="corp", model="corporation")
    alliance_type = ContentType.objects.get(app_label="corp", model="alliance")
    for corp in Recipient.objects.filter(content_type=corp_type):
        corps.add(corp.recipient)
コード例 #19
0
ファイル: models.py プロジェクト: vanderheyde/ecm
 def frequency_admin_display(self):
     freq = self.frequency
     frequnits = self.get_frequency_units_display()
     return tr("Every " + str(freq) + " " + str(frequnits))
コード例 #20
0
ファイル: models.py プロジェクト: vanderheyde/ecm
class ScheduledTask(models.Model):

    FREQUENCY_UNIT_CHOICES = (
        (1, tr("seconds")),
        (60, tr("minutes")),
        (3600, tr("hours")),
        (3600 * 24, tr("days")),
        (3600 * 24 * 7, tr("weeks"))
    )

    function = models.CharField(max_length=256, validators=[FunctionValidator()])
    args = models.CharField(max_length=256, default="{}", validators=[ArgsValidator()])
    priority = models.IntegerField(default=0)
    next_execution = models.DateTimeField(auto_now_add=True)
    last_execution = models.DateTimeField(null=True, blank=True)
    frequency = models.IntegerField()
    frequency_units = models.IntegerField(default=3600, choices=FREQUENCY_UNIT_CHOICES)
    is_active = models.BooleanField(default=True)
    is_scheduled = models.BooleanField(default=False)
    is_running = models.BooleanField(default=False)
    is_one_shot = models.BooleanField(default=False)
    is_last_exec_success = models.BooleanField(default=False)

    class Meta:
        verbose_name = tr("scheduled task")
        verbose_name_plural = tr("scheduled tasks")

    def __unicode__(self):
        return force_unicode(self.function)

    def frequency_admin_display(self):
        freq = self.frequency
        frequnits = self.get_frequency_units_display()
        return tr("Every " + str(freq) + " " + str(frequnits))
    frequency_admin_display.short_description = tr("frequency")

    def function_admin_display(self):
        return self.get_function_display()
    function_admin_display.short_description = tr("Function")

    def permalink(self, next_page=None):
        url = "/scheduler/tasks/%d/launch/" % self.id
        if next_page: url += "?next=%s" % next_page
        return url

    def as_html(self, next_page=None):
        return '<a class="task" href="%s">"%s"</a>' % (self.permalink(next_page), tr('Launch'))

    def launch_task_admin_display(self):
        return self.as_html(next_page="/admin/scheduler/scheduledtask/")
    launch_task_admin_display.allow_tags = True
    launch_task_admin_display.short_description = tr("Launch")

    def next_execution_admin_display(self):
        from ecm.utils.format import print_delta
        delta = self.next_execution - timezone.now()
        if delta < timedelta(0):
            delta = timedelta(0)
        return print_delta(delta)
    next_execution_admin_display.short_description = tr("Next execution")

    def get_function(self):
        return extract_function(self.function)

    def get_args(self):
        return extract_args(self.args)

    def run(self):
        try:
            if self.is_running:
                return
            else:
                self.is_running = True
                self.last_execution = timezone.now()
                self.save()

            invalid_function = False
            try:
                func = self.get_function()
            except ValidationError:
                invalid_function = True
                raise
            args = self.get_args()
            func(**args)

            self.is_last_exec_success = True
            # TODO : add listeners handling here
        except:
            # error during the execution of the task
            self.is_last_exec_success = False
            LOG.exception("")
        finally:
            if invalid_function:
                LOG.warning('Task "%s" is obsolete, deleting...' % self.function)
                self.delete()
            else:
                delta = self.frequency * self.frequency_units
                self.next_execution = timezone.now() + timedelta(seconds=delta)
                self.is_running = False
                self.is_scheduled = False
                self.save()
コード例 #21
0
ファイル: __init__.py プロジェクト: Betriebsrat/ecm
DATE_PATTERN = "%Y-%m-%d_%H-%M-%S"

#------------------------------------------------------------------------------
DATATABLES_DEFAULTS = {
    'sPaginationType': 'bootstrap',
    'bProcessing': True,
    'bServerSide': True,
    'bAutoWidth': False,
    'iDisplayLength': 25,
    'bStateSave': True,
    'iCookieDuration': 60 * 60, # 1 hour
    'sDom': '<"row-fluid"<"span5"l><"span7"p>>rt<"row-fluid"<"span5"i><"span7"p>>',
    'fnStateLoadParams': 'function (oSettings, oData) { oData.sFilter = $("#search_text").val(); }',
    'fnStateSaveParams': 'function (oSettings, oData) { $("#search_text").val(oData.sFilter); return true; }',
    'oLanguage': {
        'sLengthMenu': tr('_MENU_ lines per page'),
        'sZeroRecords': tr('Nothing found to display - sorry.'),
        'sInfo': tr('Showing _START_ to _END_ of _TOTAL_ records'),
        'sInfoEmpty': tr('Showing 0 to 0 of 0 records'),
        'sInfoFiltered': tr('(filtered from _MAX_ total records)'),
    },
    'oSaveAsCSV': {
        'sButtonText': tr('Save as CSV'),
        'sButtonClass': 'btn pull-right',
        'sIconClass': 'icon-download-alt',
    },
}

#------------------------------------------------------------------------------
class DatatableParams: pass
def extract_datatable_params(request):
コード例 #22
0
from django.db.models import Q
from django.views.decorators.cache import cache_page
from django.shortcuts import render_to_response
from django.http import HttpResponseBadRequest
from django.template.context import RequestContext as Ctx
from django.utils.translation import ugettext as tr

from ecm.apps.common.models import UpdateDate, ColorThreshold
from ecm.utils.format import print_time_min
from ecm.views import extract_datatable_params, datatable_ajax_data, DATATABLES_DEFAULTS
from ecm.apps.hr.models import TitleMembership, RoleMemberDiff, TitleMemberDiff, Member
from ecm.views.decorators import check_user_access

ACCESS_CHANGES_COLUMNS = [
    {
        'sTitle': tr('Change'),
        'sWidth': '5%',
        'stype': 'string',
    },
    {
        'sTitle': tr('Member'),
        'sWidth': '15%',
        'stype': 'string',
    },
    {
        'sTitle': tr('Title/Role'),
        'sWidth': '50%',
        'stype': 'html',
    },
    {
        'sTitle': tr('Date'),
コード例 #23
0
ファイル: models.py プロジェクト: vanderheyde/ecm
 class Meta:
     verbose_name = tr("Observer")
     verbose_name = tr("Observers")
コード例 #24
0
ファイル: models.py プロジェクト: vanderheyde/ecm
 class Meta:
     verbose_name = tr("Observer spec")
     verbose_name_plural = tr("Observer specs")
コード例 #25
0
ファイル: access.py プロジェクト: Betriebsrat/ecm
from django.db.models import Q
from django.views.decorators.cache import cache_page
from django.shortcuts import render_to_response
from django.http import HttpResponseBadRequest
from django.template.context import RequestContext as Ctx
from django.utils.translation import ugettext as tr

from ecm.apps.common.models import UpdateDate, ColorThreshold
from ecm.utils.format import print_time_min
from ecm.views import extract_datatable_params, datatable_ajax_data, DATATABLES_DEFAULTS
from ecm.apps.hr.models import TitleMembership, RoleMemberDiff, TitleMemberDiff, Member
from ecm.views.decorators import check_user_access

ACCESS_CHANGES_COLUMNS = [
    {'sTitle': tr('Change'),         'sWidth': '5%',    'stype': 'string', },
    {'sTitle': tr('Member'),         'sWidth': '15%',   'stype': 'string', },
    {'sTitle': tr('Title/Role'),     'sWidth': '50%',   'stype': 'html', },
    {'sTitle': tr('Date'),           'sWidth': '25%',   'stype': 'string', },
]

#------------------------------------------------------------------------------
@check_user_access()
def access_changes(request):
    data = {
        'scan_date' : UpdateDate.get_latest(TitleMembership),
        'colorThresholds' : ColorThreshold.as_json(),
        'directorAccessLvl': Member.DIRECTOR_ACCESS_LVL,
        'datatable_defaults': DATATABLES_DEFAULTS,
        'columns' : ACCESS_CHANGES_COLUMNS,
        'sorting': [[3, 'desc']],
コード例 #26
0
ファイル: players.py プロジェクト: Betriebsrat/ecm
from django.contrib.auth.models import User
from django.shortcuts import render_to_response, get_object_or_404
from django.db.models.aggregates import Count
from django.template.context import RequestContext as Ctx
from django.utils.translation import ugettext as tr

from ecm.utils import _json as json
from ecm.views.decorators import check_user_access
from ecm.utils.format import print_time_min
from ecm.apps.hr.models import Member, Recruit
from ecm.apps.common.models import ColorThreshold
from ecm.views import extract_datatable_params, datatable_ajax_data, DATATABLES_DEFAULTS
from ecm.apps.hr.views import get_members, MEMBERS_COLUMNS

PLAYERS_COLUMNS = [
    {'sTitle': tr('Username'),     'sWidth': '30%',   'db_field': 'username', },
    {'sTitle': tr('Admin'),        'sWidth': '10%',   'db_field': 'is_superuser', },
    {'sTitle': tr('EVE Accounts'), 'sWidth': '10%',   'db_field': 'account_count', },
    {'sTitle': tr('Characters'),   'sWidth': '10%',   'db_field': 'char_count', },
    {'sTitle': tr('Groups'),       'sWidth': '10%',   'db_field': 'group_count', },
    {'sTitle': tr('Last Login'),   'sWidth': '15%',   'db_field': 'last_login', },
    {'sTitle': tr('Joined Date'),  'sWidth': '15%',   'db_field': 'date_joined', },
]
#------------------------------------------------------------------------------
@check_user_access()
def player_list(request):
    data = {
        'colorThresholds'     : ColorThreshold.as_json(),
        'player_columns'      : PLAYERS_COLUMNS,
        'datatables_defaults' : DATATABLES_DEFAULTS,
    }
コード例 #27
0
ファイル: __init__.py プロジェクト: Betriebsrat/ecm
#
# EVE Corporation Management is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# EVE Corporation Management. If not, see <http://www.gnu.org/licenses/>.


from ecm.utils.format import print_float
from django.utils.translation import gettext as tr

WALLET_LINK = '<a href="%s" class="wallet" title="%s">%s</a>'
WALLET_JOURNAL_COLUMNS = [
        {'sTitle':tr('Date'),         'sWidth':'14%', 'sType':'string', },
        {'sTitle':tr('Wallet'),       'sWidth':'15%', 'sType':'html', },
        {'sTitle':tr('Operation'),    'sWidth':'10%', 'sType':'string'},
        {'sTitle':tr('From'),         'sWidth':'15%', 'sType':'html', },
        {'sTitle':tr('To'),           'sWidth':'15%', 'sType':'html', 'bSortable':False },
        {'sTitle':tr('Amount'),       'sWidth':'15%', 'sType':'string', },
        {'sTitle':tr('Balance'),      'sWidth':'15%', 'sType':'string', 'sClass':'right', },
        {'sTitle':tr('Reason'),     'bVisible':False, },
        ]

MEMBER_CONTRIB_COLUMNS = [
        {'sTitle':tr('Member'),         'sWidth':'50%', 'sType':'html', },
        {'sTitle':tr('Contributions'),  'sWidth':'50%', 'sType':'html', 'sClass': 'right', },
        ]
PLAYER_CONTRIB_COLUMNS = [
        {'sTitle':tr('Player'),         'sWidth':'50%', 'sType':'html', },
コード例 #28
0
ファイル: forms.py プロジェクト: rasmadeus/rfix
 def add_login_error(self):
     self.add_error('password', tr('Your password or login is invalid'))
コード例 #29
0
ファイル: details.py プロジェクト: Betriebsrat/ecm
        "title" : title,
        "member_count" : title.members.count(),
        "colorThresholds" : ColorThreshold.as_json(),
        'roles_columns': ROLES_COLUMNS,
        'diffs_columns': DIFFS_COLUMNS,
        'datatables_defaults': DATATABLES_DEFAULTS 
    }

    return render_to_response("ecm/hr/titles/title_details.html", data, Ctx(request))




#------------------------------------------------------------------------------
ROLES_COLUMNS = [
    {'sTitle': tr('Role'),           'sWidth': '50%',  'bSortable': False, },
    {'sTitle': tr('Category'),       'sWidth': '30%',  'bSortable': False, },
    {'sTitle': tr('Access Level'),   'sWidth': '20%',  'bSortable': False, },
]
@check_user_access()
@cache_page(3 * 60 * 60) # 3 hours cache
def composition_data(request, title_id):
    try:
        params = extract_datatable_params(request)
    except KeyError:
        return HttpResponseBadRequest()

    title = get_object_or_404(Title, pk=int(title_id))
    query = title.roles.all()

    if params.asc:
コード例 #30
0
ファイル: models.py プロジェクト: vanderheyde/ecm
 class Meta:
     verbose_name = tr("scheduled task")
     verbose_name_plural = tr("scheduled tasks")
コード例 #31
0
 class Meta:  # noqa
     template = "streams/card_block.html"
     icon = "placeholder"
     label = tr("Staff Cards")
コード例 #32
0
ファイル: models.py プロジェクト: vanderheyde/ecm
 def as_html(self, next_page=None):
     return '<a class="task" href="%s">"%s"</a>' % (self.permalink(next_page), tr('Launch'))
コード例 #33
0
ファイル: views.py プロジェクト: rasmadeus/rfix
def _links_guest(req):
    return {
        'links': (
            {'name': tr('Login'), 'href': '/login'},
        )
    }
コード例 #34
0
ファイル: __init__.py プロジェクト: Betriebsrat/ecm
__date__ = "2010-02-03"
__author__ = "diabeteman"

from django.db.models import Q
from django.utils.translation import ugettext as tr

from ecm.apps.hr.models import Member
from ecm.utils.format import print_date
from ecm.utils import db

import logging
logger = logging.getLogger(__name__)

#------------------------------------------------------------------------------
MEMBERS_COLUMNS = [
    {'sTitle': tr('Name'),         'sWidth': '15%',   'db_field': 'name', },
    {'sTitle': tr('Corp'),         'sWidth': '5%',    'db_field': 'corp__corporationName', },
    {'sTitle': tr('Player'),       'sWidth': '15%',   'db_field': 'owner__username', },
    {'sTitle': tr('Access Level'), 'sWidth':  '5%',   'db_field': 'accessLvl', },
    {'sTitle': tr('Last Login'),   'sWidth': '10%',   'db_field': 'lastLogin', },
    {'sTitle': tr('Location'),     'sWidth': '20%',   'db_field': 'location', },
    {'sTitle': tr('Ship'),         'sWidth': '15%',   'db_field': 'ship', },
    {'sTitle': tr('Titles'),       'bVisible': False, 'db_field': None, },
]

def get_members(query, first_id, last_id, search_str=None, sort_by=0, asc=True, for_csv=False):

    query = query.select_related(depth=2) # improve performance

    sort_col = MEMBERS_COLUMNS[sort_by]['db_field']
    # SQL hack for making a case insensitive sort
コード例 #35
0
ファイル: history.py プロジェクト: Betriebsrat/ecm
from django.shortcuts import render_to_response
from django.views.decorators.cache import cache_page
from django.http import HttpResponseBadRequest
from django.utils.text import truncate_words
from django.template.context import RequestContext as Ctx
from django.utils.translation import ugettext as tr

from ecm.utils import db
from ecm.apps.common.models import UpdateDate
from ecm.utils.format import print_time_min
from ecm.views.decorators import check_user_access
from ecm.views import extract_datatable_params, datatable_ajax_data, DATATABLES_DEFAULTS
from ecm.apps.hr.models import Member, MemberDiff

COLUMNS = [
    {'sTitle': tr('In/Out'),   'sWidth': '15%', 'db_field': 'change', 'bSortable': False },
    {'sTitle': tr("Name"),     'sWidth': "30%", 'db_field': 'name', },
    {'sTitle': tr("Nickname"), 'sWidth': "30%", 'db_field': 'nickname', },
    {'sTitle': tr("Date"),     'sWidth': "25%", 'db_field': 'id', }
    
]
#------------------------------------------------------------------------------
@check_user_access()
def history(request):
    defaults = DATATABLES_DEFAULTS.copy()
    defaults['aaSorting'] = [[3, "desc"]]
    data = {
        'scan_date' : UpdateDate.get_latest(Member),
        'ajax_url': '/hr/members/history/data/',
        'datatables_defaults': defaults,
        'columns': COLUMNS,
コード例 #36
0
class ProductCardBlock(blocks.StructBlock):
    """Cards with image and text and button(s)."""

    title = blocks.CharBlock(required=True, help_text=tr("Add your title"))

    bg_image = ImageChooserBlock(required=False,
                                 blank=False,
                                 null=True,
                                 on_delete=models.SET_NULL)

    sort_by = RadioSelectBlock(
        choices=(
            ("no_sort", tr("Don't sort")),
            ("most_recent", tr("Most Recently added")),
            ("best_sellers", tr("Best sellers")),
            ("favorites", tr("Best sellers")),
        ),
        default='no_sort',
        help_text=tr('Choose how you want the products sorted'))

    filters = blocks.StreamBlock(
        [
            ('by_supplier',
             blocks.ChoiceBlock(
                 choices=tuple([(element.pk, element.brand_name)
                                for element in SupplierUser.objects.all()]),
                 help_text=tr(
                     "Choose which producer's products you want to see"),
             )),
            ('by_type',
             blocks.ChoiceBlock(
                 choices=tuple(
                     [(element.pk, element.name)
                      for element in store_models.ProductType.objects.all()]),
                 help_text=tr("Choose which type of product you want to see"),
             )),
            # ('by_labels', blocks.ChoiceBlock(
            #     choices=store_models.ProductLabel.objects.all(),
            #     help_text=tr("Choose which product labels you want to see"),
            # )),
            # ('by_allergens', blocks.ChoiceBlock(
            #     choices=store_models.ProductAllergen.objects.all(),
            #     help_text=tr("Choose which product labels you want to see"),
            # )),
            # ('by_pickup_point', blocks.ChoiceBlock(
            #     choices=store_models.PickupPoint.objects.all(),
            #     help_text=tr("Choose which pickup point products you want to see"),
            # )),
            # ('from_past_orders', blocks.ChoiceBlock(
            #     choices=store_models.PickupPoint.objects.all(),
            #     help_text=tr("Choose which pickup point products you want to see"),
            # )),
        ],
        max_num=1,
        required=False,
    )

    max_cards = blocks.IntegerBlock(
        max_value=6,
        help_text=tr(
            "Number of cards to display on the page section (max. 6)"))

    btn_text = blocks.CharBlock(max_length=30)
    btn_url = blocks.CharBlock(max_length=30, default="products")

    def sort_no_sort(self, products):
        return products

    def sort_most_recent(self, products):
        return sorted(products, key=lambda x: x.id, reverse=True)

    def sort_best_sellers(self, products):
        # Todo: fetch orders, add together the number of sales for each item, store it in a table and sort accordingly
        return sorted(products, key=lambda x: x)

    def sort_favorites(self, products):
        # Todo: fetch orders, add together the number of sales (for the logged in client for each item , store it in a table and sort accordingly
        return sorted(products, key=lambda x: x)

    def filter_by_supplier(self, ctx, products):
        return {
            v
            for v in products
            if v.supplier_id == int(ctx['self']['filters'][0].value)
        }

    def filter_by_type(self, ctx, products):
        return {
            v
            for v in products
            if v.type.pk == int(ctx['self']['filters'][0].value)
        }

    def filter_by_labels(self, ctx, products):
        ## todo(@bmarques): Filter by labels (multiple choice field)
        return {
            v
            for v in products if v.label == ctx['self']['filters']['by_labels']
        }

    def filter_by_allergens(self, ctx, products):
        ## todo(@bmarques): Filter by allergen (multiple choice field)
        return {
            v
            for v in products
            if v.allergens == ctx['self']['filters']['by_allergens']
        }

    def filter_by_pickup_point(self, ctx, products):
        ## @Todo: Filtering products by pickup point is a bit more complicated, let's keep it for later
        return {
            v
            for v in products
            if v.type == ctx['self']['filters']['by_pickup_point']
        }

    # def filter_from_past_orders(self, ctx, products):
    #     ## @Todo: Filtering products from a customer's past orders is a bit more complicated, let's keep it for later
    #     return {v for v in products if v.type == ctx['self']['filters']['by_past_orders']}

    def get_context(self, request, *args, **kwargs):
        context = super().get_context(request, *args, **kwargs)
        ret = store_models.Product.objects.all()
        if len(context['self']['filters']):
            ret = self.__getattribute__(
                'filter_' + context['self']['filters'][0].block_type)(context,
                                                                      ret)
        ret = self.__getattribute__('sort_' + context['self']['sort_by'])(ret)
        context['products'] = ret[:context['self']['max_cards']]
        return context

    class Meta:  # noqa
        template = "streams/product_cards_block.html"
        icon = "placeholder"
        label = tr("Product Cards block")
コード例 #37
0
ファイル: list.py プロジェクト: Betriebsrat/ecm
from django.views.decorators.cache import cache_page
from django.http import HttpResponse, HttpResponseBadRequest
from django.template.context import RequestContext as Ctx
from django.utils.translation import ugettext as tr

from ecm.views import datatable_ajax_data, extract_datatable_params, DATATABLES_DEFAULTS
from ecm.apps.hr.models import Role, RoleType
from ecm.apps.common.models import ColorThreshold
from ecm.views.decorators import check_user_access
from ecm.apps.corp.models import CorpHangar, CorpWallet

import logging
logger = logging.getLogger(__name__)

ROLES_COLUMNS = [
    {'sTitle': tr('Role Name'),      'sWidth': '30%',   'bSortable': False, },
    {'sTitle': tr('Description'),    'sWidth': '55%',   'bSortable': False, },
    {'sTitle': tr('Access Level'),   'sWidth': ' 5%',   'bSortable': False, },
    {'sTitle': tr('Members'),        'sWidth':  '5%',   'bSortable': False, },
    {'sTitle': tr('Titles'),         'sWidth': ' 5%',   'bSortable': False, },
    {'bVisible': False, },
    {'bVisible': False, },
    {'bVisible': False, },
]

#------------------------------------------------------------------------------
@check_user_access()
def roles(request):
    data = {
        'colorThresholds': ColorThreshold.as_json(),
        'role_types': RoleType.objects.all().order_by('id'),
コード例 #38
0
 class Meta:  # noqa
     template = "streams/product_cards_block.html"
     icon = "placeholder"
     label = tr("Product Cards block")
コード例 #39
0
from django.shortcuts import render_to_response, get_object_or_404
from django.db.models.aggregates import Count
from django.template.context import RequestContext as Ctx
from django.utils.translation import ugettext as tr

from ecm.utils import _json as json
from ecm.views.decorators import check_user_access
from ecm.utils.format import print_time_min
from ecm.apps.hr.models import Member, Recruit
from ecm.apps.common.models import ColorThreshold
from ecm.views import extract_datatable_params, datatable_ajax_data, DATATABLES_DEFAULTS
from ecm.apps.hr.views import get_members, MEMBERS_COLUMNS

PLAYERS_COLUMNS = [
    {
        'sTitle': tr('Username'),
        'sWidth': '30%',
        'db_field': 'username',
    },
    {
        'sTitle': tr('Admin'),
        'sWidth': '10%',
        'db_field': 'is_superuser',
    },
    {
        'sTitle': tr('EVE Accounts'),
        'sWidth': '10%',
        'db_field': 'account_count',
    },
    {
        'sTitle': tr('Characters'),
コード例 #40
0
class CardFilterBlock(blocks.StructBlock):
    filter_by = blocks.ChoiceBlock(
        choices=(
            ("no_sort", tr("Don't sort")),
            ("by_producer", tr("Sort by producer")),
            ("by_type", tr("Sort by type")),
            ("by_labels", tr("Sort by label")),
            ("by_allergens", tr("Sort by allergen")),
            ("by_pickup_point", tr("Sort by Pickup point")),
            ("from_past orders",
             tr("Show only products this customer already ordered")),
        ),
        default='no_sort',
        help_text=tr('Choose how you want the products filtered'))

    def products_no_sort(self, ctx, products):
        return products

    def products_by_producer(self, ctx, products):
        return {
            k: v
            for k, v in store_models.Product.objects.all().items()
            if v.supplier == ctx['self']['filters']['by_producer']
        }

    by_producer = blocks.ChoiceBlock(
        choices=SupplierUser.objects.all(),
        help_text=tr("Choose which producer's products you want to see"),
        classname=(
            'wagtailuiplus__choice-handler-target--filter_by '
            'wagtailuiplus__choice-handler-hidden-if--no_sort '
            'wagtailuiplus__choice-handler-hidden-if--by_type '
            'wagtailuiplus__choice-handler-hidden-if--by_label '
            'wagtailuiplus__choice-handler-hidden-if--by_allergens '
            'wagtailuiplus__choice-handler-hidden-if--by_pickup_point '
            'wagtailuiplus__choice-handler-hidden-if--from_past_orders'))

    def products_by_type(self, ctx, products):
        return {
            k: v
            for k, v in store_models.Product.objects.all().items()
            if v.type == ctx['self']['filters']['by_type']
        }

    by_type = blocks.ChoiceBlock(
        choices=store_models.ProductType.objects.all(),
        help_text=tr("Choose which type of product you want to see"),
        classname=(
            'wagtailuiplus__choice-handler-target--filter_by '
            'wagtailuiplus__choice-handler-hidden-if--no_sort '
            'wagtailuiplus__choice-handler-hidden-if--by_producer '
            'wagtailuiplus__choice-handler-hidden-if--by_label '
            'wagtailuiplus__choice-handler-hidden-if--by_allergens '
            'wagtailuiplus__choice-handler-hidden-if--by_pickup_point '
            'wagtailuiplus__choice-handler-hidden-if--from_past_orders'))

    def products_by_labels(self, ctx, products):
        ## todo(@bmarques): Filter by labels (multiple choice field)
        return {
            k: v
            for k, v in store_models.Product.objects.all().items()
            if v.label == ctx['self']['filters']['by_labels']
        }

    by_labels = blocks.ChoiceBlock(
        choices=store_models.ProductLabel.objects.all(),
        help_text=tr("Choose which product labels you want to see"),
        classname=(
            'wagtailuiplus__choice-handler-target--filter_by '
            'wagtailuiplus__choice-handler-hidden-if--no_sort '
            'wagtailuiplus__choice-handler-hidden-if--by_type '
            'wagtailuiplus__choice-handler-hidden-if--by_producer '
            'wagtailuiplus__choice-handler-hidden-if--by_allergens '
            'wagtailuiplus__choice-handler-hidden-if--by_pickup_point '
            'wagtailuiplus__choice-handler-hidden-if--from_past_orders'))

    def products_by_allergens(self, ctx, products):
        ## todo(@bmarques): Filter by allergen (multiple choice field)
        return {
            k: v
            for k, v in store_models.Product.objects.all().items()
            if v.allergens == ctx['self']['filters']['by_allergens']
        }

    by_allergens = blocks.ChoiceBlock(
        choices=store_models.ProductAllergen.objects.all(),
        help_text=tr("Choose which product labels you want to see"),
        classname=(
            'wagtailuiplus__choice-handler-target--filter_by '
            'wagtailuiplus__choice-handler-hidden-if--no_sort '
            'wagtailuiplus__choice-handler-hidden-if--by_type '
            'wagtailuiplus__choice-handler-hidden-if--by_label '
            'wagtailuiplus__choice-handler-hidden-if--producer '
            'wagtailuiplus__choice-handler-hidden-if--by_pickup_point '
            'wagtailuiplus__choice-handler-hidden-if--from_past_orders'))

    def products_by_pickup_point(self, ctx, products):
        ## @Todo: Filtering products by pickup point is a bit more complicated, let's keep it for later
        return {
            k: v
            for k, v in store_models.Product.objects.all().items()
            if v.type == ctx['self']['filters']['by_type']
        }

    by_pickup_point = blocks.ChoiceBlock(
        choices=store_models.PickupPoint.objects.all(),
        help_text=tr("Choose which pickup point products you want to see"),
        classname=(
            'wagtailuiplus__choice-handler-target--filter_by '
            'wagtailuiplus__choice-handler-hidden-if--no_sort '
            'wagtailuiplus__choice-handler-hidden-if--by_type '
            'wagtailuiplus__choice-handler-hidden-if--by_label '
            'wagtailuiplus__choice-handler-hidden-if--by_allergens '
            'wagtailuiplus__choice-handler-hidden-if--by_producer '
            'wagtailuiplus__choice-handler-hidden-if--from_past_orders'))

    def products_from_past_orders(self, ctx, products):
        ## @Todo: Filtering products from a customer's past orders is a bit more complicated, let's keep it for later
        return {
            k: v
            for k, v in store_models.Product.objects.all().items()
            if v.type == ctx['self']['filters']['by_type']
        }

    by_pickup_point = blocks.ChoiceBlock(
        choices=store_models.PickupPoint.objects.all(),
        help_text=tr("Choose which pickup point products you want to see"),
        classname=('wagtailuiplus__choice-handler-target--filter_by '
                   'wagtailuiplus__choice-handler-hidden-if--no_sort '
                   'wagtailuiplus__choice-handler-hidden-if--by_type '
                   'wagtailuiplus__choice-handler-hidden-if--by_label '
                   'wagtailuiplus__choice-handler-hidden-if--by_allergens '
                   'wagtailuiplus__choice-handler-hidden-if--by_producer '
                   'wagtailuiplus__choice-handler-hidden-if--by_pickup_point'))
コード例 #41
0
#------------------------------------------------------------------------------
@check_user_access()
def changes(request):
    data = {
        'scan_date': UpdateDate.get_latest(TitleComposition),
        'columns': DIFFS_COLUMNS,
        'datatables_defaults': DATATABLES_DEFAULTS,
        "colorThresholds": ColorThreshold.as_json(),
    }
    return render_to_response("ecm/hr/titles/changes.html", data, Ctx(request))


#------------------------------------------------------------------------------
DIFFS_COLUMNS = [
    {
        'sTitle': tr('Change'),
        'sWidth': '5%',
        'bSortable': False,
    },
    {
        'sTitle': tr('Title'),
        'sWidth': '10%',
        'bSortable': False,
    },
    {
        'sTitle': tr('Role'),
        'sWidth': '40%',
        'bSortable': False,
    },
    {
        'sTitle': tr('Modification Date'),
コード例 #42
0
ファイル: changes.py プロジェクト: Betriebsrat/ecm

#------------------------------------------------------------------------------
@check_user_access()
def changes(request):
    data = {
        'scan_date' : UpdateDate.get_latest(TitleComposition),
        'columns': DIFFS_COLUMNS,
        'datatables_defaults': DATATABLES_DEFAULTS,
        "colorThresholds" : ColorThreshold.as_json(),
    }
    return render_to_response("ecm/hr/titles/changes.html", data, Ctx(request))

#------------------------------------------------------------------------------
DIFFS_COLUMNS = [
    {'sTitle': tr('Change'),            'sWidth': '5%',   'bSortable': False, },
    {'sTitle': tr('Title'),             'sWidth': '10%',  'bSortable': False, },
    {'sTitle': tr('Role'),              'sWidth': '40%',  'bSortable': False, },
    {'sTitle': tr('Modification Date'), 'sWidth': '25%',  'bSortable': False, },
]
@cache_page(60 * 60) # 1 hour cache
@check_user_access()
def changes_data(request):
    try:
        params = extract_datatable_params(request)
    except:
        return HttpResponseBadRequest()

    titles = TitleCompoDiff.objects.select_related(depth=1).all().order_by("-date")

    count = titles.count()
コード例 #43
0
ファイル: cyno_alts.py プロジェクト: RebelFist/ecm
from ecm.apps.corp.models import Corporation
from ecm.views import DATATABLES_DEFAULTS, datatable_csv_data
from ecm.views.decorators import check_user_access
from ecm.views import extract_datatable_params, datatable_ajax_data
from ecm.apps.hr.models import Member
from ecm.apps.common.models import UpdateDate
from ecm.utils import db, _json as json
from ecm.apps.corp.models import Standing
from ecm.apps.common.models import UrlPermission

logger = logging.getLogger(__name__)

# ------------------------------------------------------------------------------
MEMBERS_COLUMNS = [
    {"sTitle": tr("Name"), "sWidth": "15%", "db_field": "name"},
    {"sTitle": tr("Corp"), "sWidth": "5%", "db_field": "corp__corporationName"},
    {"sTitle": tr("Standing"), "sWidth": "5%"},
    {"sTitle": tr("Player"), "sWidth": "15%", "db_field": "owner__username"},
    {"sTitle": tr("Location"), "sWidth": "20%", "db_field": "location"},
]
# ------------------------------------------------------------------------------
@check_user_access()
def cyno_list(request):
    corps = Corporation.objects.others().order_by("corporationName")
    corps = corps.annotate(member_count=Count("members"))

    data = {
        "scan_date": UpdateDate.get_latest(Member),
        "trusted_corps": corps.filter(member_count__gt=0, is_trusted=True),
        "other_corps": corps.filter(member_count__gt=0, is_trusted=False),
コード例 #44
0
        "title": title,
        "member_count": title.members.count(),
        "colorThresholds": ColorThreshold.as_json(),
        'roles_columns': ROLES_COLUMNS,
        'diffs_columns': DIFFS_COLUMNS,
        'datatables_defaults': DATATABLES_DEFAULTS
    }

    return render_to_response("ecm/hr/titles/title_details.html", data,
                              Ctx(request))


#------------------------------------------------------------------------------
ROLES_COLUMNS = [
    {
        'sTitle': tr('Role'),
        'sWidth': '50%',
        'bSortable': False,
    },
    {
        'sTitle': tr('Category'),
        'sWidth': '30%',
        'bSortable': False,
    },
    {
        'sTitle': tr('Access Level'),
        'sWidth': '20%',
        'bSortable': False,
    },
]
コード例 #45
0
ファイル: list.py プロジェクト: RebelFist/ecm
from django.http import HttpResponseBadRequest
from django.template.context import RequestContext as Ctx
from django.utils.translation import ugettext as tr

from ecm.utils import db
from ecm.utils import _json as json
from ecm.utils.format import print_time_min
from ecm.apps.hr.models import TitleComposition, Title
from ecm.apps.common.models import ColorThreshold, UpdateDate
from ecm.apps.corp.models import Corporation
from ecm.views.decorators import check_user_access
from ecm.views import datatable_ajax_data, extract_datatable_params, DATATABLES_DEFAULTS
from ecm.apps.hr import NAME as app_prefix

TITLES_COLUMNS = [
    {"sTitle": tr("Title Name"), "sWidth": "40%", "db_field": "titleName"},
    {"sTitle": tr("Access Level"), "sWidth": "20%", "db_field": "accessLvl"},
    {"sTitle": tr("Members"), "sWidth": "10%", "db_field": None, "bSortable": False},
    {"sTitle": tr("Role Count"), "sWidth": "10%", "db_field": None, "bSortable": False},
    {"sTitle": tr("Last Modified"), "sWidth": "20%", "db_field": None, "bSortable": False},
]

# ------------------------------------------------------------------------------
@check_user_access()
def titles(request):
    colorThresholds = []
    for c in ColorThreshold.objects.all().order_by("threshold"):
        colorThresholds.append({"threshold": c.threshold, "color": c.color})

    data = {
        "scan_date": UpdateDate.get_latest(TitleComposition),
コード例 #46
0
ファイル: __init__.py プロジェクト: vanderheyde/ecm
DATATABLES_DEFAULTS = {
    'sPaginationType': 'bootstrap',
    'bProcessing': True,
    'bServerSide': True,
    'bAutoWidth': False,
    'iDisplayLength': 25,
    'bStateSave': True,
    'iCookieDuration': 60 * 60,  # 1 hour
    'sDom':
    '<"row-fluid"<"span5"l><"span7"p>>rt<"row-fluid"<"span5"i><"span7"p>>',
    'fnStateLoadParams':
    'function (oSettings, oData) { oData.sFilter = $("#search_text").val(); }',
    'fnStateSaveParams':
    'function (oSettings, oData) { $("#search_text").val(oData.sFilter); return true; }',
    'oLanguage': {
        'sLengthMenu': tr('_MENU_ lines per page'),
        'sZeroRecords': tr('Nothing found to display - sorry.'),
        'sInfo': tr('Showing _START_ to _END_ of _TOTAL_ records'),
        'sInfoEmpty': tr('Showing 0 to 0 of 0 records'),
        'sInfoFiltered': tr('(filtered from _MAX_ total records)'),
    },
    'oSaveAsCSV': {
        'sButtonText': tr('Save as CSV'),
        'sButtonClass': 'btn pull-right',
        'sIconClass': 'icon-download-alt',
    },
}


#------------------------------------------------------------------------------
class DatatableParams:
コード例 #47
0
from ecm.apps.corp.models import Corporation
from ecm.views import DATATABLES_DEFAULTS, datatable_csv_data
from ecm.views.decorators import check_user_access
from ecm.views import extract_datatable_params, datatable_ajax_data
from ecm.apps.hr.models import Member
from ecm.apps.common.models import UpdateDate
from ecm.utils import db, _json as json
from ecm.apps.corp.models import Standing
from ecm.apps.common.models import UrlPermission

logger = logging.getLogger(__name__)

#------------------------------------------------------------------------------
MEMBERS_COLUMNS = [
    {
        'sTitle': tr('Name'),
        'sWidth': '15%',
        'db_field': 'name',
    },
    {
        'sTitle': tr('Corp'),
        'sWidth': '5%',
        'db_field': 'corp__corporationName',
    },
    {
        'sTitle': tr('Standing'),
        'sWidth': '5%',
    },
    {
        'sTitle': tr('Player'),
        'sWidth': '15%',
コード例 #48
0
ファイル: models.py プロジェクト: hufeng03/django-gitcms
 class Meta:
     verbose_name_plural = tr(u'Tags')
コード例 #49
0
 class Meta:
     verbose_name_plural = tr(u'Books')