Ejemplo n.º 1
0
class ResponseTable(tables.Table):
    '''
    skeleton for the questionnaire table
    '''

    edit = tables.TemplateColumn(
        '<a style="color:#1abc9c;" class="far fa-edit fa-lg" href="?id={{record.id}}"></a>',
        verbose_name='')
    date = tables.DateTimeColumn(format='Y-m-d H:m:s')
    question = tables.Column()
    score = tables.Column()

    class Meta:
        exclude = ('user', )
        attrs = {
            'class': 'table table-striped table-hover',
        }
        template_name = 'django_tables2/bootstrap.html'
Ejemplo n.º 2
0
class VersionsUsageTable(tables.Table):
    userid = tables.Column(accessor='request.userid', verbose_name='UserID')
    nextversion = tables.Column(verbose_name='Current Version')
    last_update = tables.DateTimeColumn(accessor='request.created',
                                        order_by='-request__created',
                                        verbose_name='Last update')
    ip = tables.Column(accessor='request.ip')
    platform = tables.Column(accessor='request.os.platform')

    class Meta:
        model = AppRequest
        orderable = False
        attrs = {
            'class':
            'paleblue table table-striped table-bordered table-hover table-condensed',
            'id': 'usage-table'
        }
        fields = ('userid', 'nextversion', 'last_update', 'ip', 'platform')
Ejemplo n.º 3
0
class CommandeTable(tables.Table):
    client = tables.LinkColumn("utilisateurs:user_profile",
                               text=lambda record: record.colis.client,
                               args=[A("colis__client__id")])
    driver = tables.LinkColumn("utilisateurs:user_profile",
                               text=lambda record: record.driver,
                               args=[A("driver__id")])
    etat = tables.Column(accessor="getEtatLibelle")
    created_at = tables.DateTimeColumn(format='d/m/Y')
    numero_commande = tables.LinkColumn("commandes:commande_view",
                                        args=[A("id")])

    actions = TemplateColumn(
        template_name="commandes/includes/commande_actions.html",
        attrs={"td": {
            "class": "text-right"
        }})

    class Meta:
        model = Commandes
        sequence = ('id', 'created_at', 'numero_commande', 'price',
                    'commission', 'client', 'etat', 'driver', 'actions')

        exclude = {
            'colis', 'accepted', 'status', 'observation', 'insurance',
            'updated_at', 'date_depot', 'date_reception', 'city_depart',
            'city_arrive', 'package', 'agent'
        }
        template_name = "django_tables2/bootstrap.html"
        attrs = {
            "th": {
                "_ordering": {
                    "orderable": "sortable",  # Instead of `orderable`
                    "ascending": "ascend",  # Instead of `asc`
                    "descending": "descend"  # Instead of `desc`
                }
            }
        }

    def order_created_at(self, queryset, is_descending):
        queryset = queryset.annotate(length=Length("created_at")).order_by(
            ("-" if is_descending else "") + "length")
        return (queryset, True)
Ejemplo n.º 4
0
class InformationPackageTable(tables.Table):

    from django_tables2.utils import A
    area = "sip2aip"

    identifier = tables.Column(verbose_name='Identifier')
    last_task = tables.Column(verbose_name='Last task')
    statusprocess = tables.Column(verbose_name='Outcome')
    last_change = tables.DateTimeColumn(format="d.m.Y H:i:s",
                                        verbose_name='Last change')
    uuid = tables.LinkColumn('%s:working_area' % area,
                             kwargs={
                                 'section': area,
                                 'uuid': A('uuid')
                             },
                             verbose_name='Process ID')
    packagename = tables.LinkColumn('%s:ip_detail' % area,
                                    kwargs={'pk': A('pk')},
                                    verbose_name='Package name')

    class Meta:
        model = InformationPackage
        fields = ('packagename', 'uuid', 'identifier', 'last_change',
                  'last_task', 'statusprocess')
        attrs = {'class': 'table table-striped table-bordered table-condensed'}
        row_attrs = {'data-id': lambda record: record.pk}

    @staticmethod
    def render_statusprocess(value):
        if value == "Success":
            return mark_safe(
                'Success <span class="glyphicon glyphicon-ok-sign" aria-hidden="true" style="color:green"/>'
            )
        elif value == "Error":
            return mark_safe(
                'Error <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true" style="color:#91170A"/>'
            )
        elif value == "Warning":
            return mark_safe(
                'Warning <span class="glyphicon glyphicon-warning-sign" aria-hidden="true" style="color:#F6A50B"/>'
            )
        else:
            return value
Ejemplo n.º 5
0
class ObjectJournalTable(BaseTable):
    """
    Used for displaying a set of JournalEntries within the context of a single object.
    """
    created = tables.DateTimeColumn(
        linkify=True,
        format=settings.SHORT_DATETIME_FORMAT
    )
    kind = ChoiceFieldColumn()
    comments = tables.TemplateColumn(
        template_code='{% load helpers %}{{ value|render_markdown|truncatewords_html:50 }}'
    )
    actions = ButtonsColumn(
        model=JournalEntry
    )

    class Meta(BaseTable.Meta):
        model = JournalEntry
        fields = ('created', 'created_by', 'kind', 'comments', 'actions')
Ejemplo n.º 6
0
class WorkflowTable(tables.Table):
    name = tables.Column(verbose_name=str('Name'))
    description_text = tables.Column(empty_values=[],
                                     verbose_name=str('Description'))
    nrows_cols = tables.Column(empty_values=[],
                               verbose_name=str('Rows/Columns'),
                               default='No data')
    modified = tables.DateTimeColumn(verbose_name='Last modified')

    def __init__(self, data, *args, **kwargs):
        table_id = kwargs.pop('id')

        super(WorkflowTable, self).__init__(data, *args, **kwargs)
        # If an ID was given, pass it on to the table attrs.
        if table_id:
            self.attrs['id'] = table_id

    def render_name(self, record):
        return format_html("""<a href="{0}">{1}</a>""".format(
            reverse('workflow:detail', kwargs={'pk': record['id']}),
            record['name']))

    def render_nrows_cols(self, record):
        if record['nrows'] == 0 and record['ncols'] == 0:
            return "No data"

        return format_html("{0}/{1}".format(record['nrows'], record['ncols']))

    class Meta:
        model = Workflow

        fields = ('name', 'description_text', 'nrows_cols', 'modified')

        sequence = ('name', 'description_text', 'nrows_cols', 'modified')

        exclude = ('user', 'attributes', 'nrows', 'ncols', 'column_names',
                   'column_types', 'column_unique', 'query_builder_ops',
                   'data_frame_table_name')

        attrs = {
            'class': 'table display table-bordered',
            'id': 'workflow-table'
        }
Ejemplo n.º 7
0
class ManipulateMethodsTable(tables.Table):
    class Meta:
        attrs = {
            'class': 'paleblue',
            'orderable': 'False',
        }

    name = tables.Column(verbose_name=('Name'), accessor='name')
    method_info = tables.Column(verbose_name=('Method info'))
    date_published = tables.DateTimeColumn(verbose_name=('Date published'),
                                           accessor='timestamp')
    submitter = tables.Column(verbose_name=('Submitter'),
                              accessor='submitter.all')
    subtracks = tables.Column(verbose_name=('Submitted to'),
                              accessor='subtrack')
    publishable = tables.BooleanColumn(verbose_name=('Public'),
                                       accessor='publishable')
    #http://stackoverflow.com/a/10860711/5615276
    selection = tables.CheckBoxColumn(verbose_name=('Select'), accessor='pk')
Ejemplo n.º 8
0
class GameTable(tables.Table):
    counter = tables.Column(empty_values=(), verbose_name="#", linkify=('atttp:game_detail', {'pk': tables.A('pk')}))
    datum = tables.DateTimeColumn(format="d/m/Y", verbose_name='Datum')
    igralca = tables.Column(accessor='players_string2', verbose_name='Igralca')
    niz_1 = tables.Column(verbose_name='1. niz', accessor='gamehead')
    niz_2 = tables.Column(verbose_name='2. niz', accessor='gamehead')
    niz_3 = tables.Column(verbose_name='3. niz', accessor='gamehead')
    igrisce = tables.Column(accessor="igrisce", verbose_name='Igrišče')

    #initialize row counter
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.order_by=('datum', )
        self.orderable = False
        self.counter = itertools.count()
        next(self.counter) #start with 1
    
    def render_counter(self):
        return "%d" % next(self.counter)

    #render game sets into columns from GameDetail
    def render_niz_1(self, value, record):
        return get_niz_data(record.id, 1)
    
    def render_niz_2(self, value, record):
        return get_niz_data(record.id, 2)
    
    def render_niz_3(self, value, record):
        return get_niz_data(record.id, 3)

    class Meta:
        model = GameHead
        template_name = template
        fields = ['counter',
                'datum',
                'igralca',
                'niz_1',
                'niz_2',
                'niz_3',
                'igrisce']
        attrs = {"class": "table table-hover",
                "style": "white-space:nowrap"}
Ejemplo n.º 9
0
class MealsListTable(tables.Table):
    change = tables.TemplateColumn(
        "<a href='{% url 'meal_detail' record.id %}'>Modify</a> ",
        verbose_name='Actions',
        orderable=False)
    checkin = tables.TemplateColumn(
        "<a href='{% url 'meal_checkin' record.id %}'>Check-in hacker</a> ",
        verbose_name='Check-in',
        orderable=False)
    starts = tables.DateColumn(accessor='starts',
                               verbose_name='Starts',
                               format='d/m G:i')
    ends = tables.DateTimeColumn(accessor='ends',
                                 verbose_name='Ends',
                                 format='d/m G:i')
    eaten = tables.Column(accessor='eaten',
                          verbose_name='Total rations served')
    times = tables.Column(accessor='times', verbose_name='Rations/hacker')
    opened = tables.Column(accessor='opened', verbose_name='Active')

    def before_render(self, request):
        if not request.user.is_organizer:
            self.columns.hide('opened')
            self.columns.hide('change')
            self.columns.hide('ends')
            self.columns.hide('starts')

    class Meta:
        model = Meal
        attrs = {'class': 'table table-hover'}
        template = 'templates/meals_list.html'
        fields = [
            'name',
            'kind',
            'opened',
            'eaten',
            'times',
            'starts',
            'ends',
        ]
        empty_text = 'No meals available'
        order_by = '-starts'
Ejemplo n.º 10
0
class AlarmHistoryTable(tables.Table):
    """Table for presenting history of one alarm """
    # alarm = tables.Column(accessor=tables.A('alarm.tag'), verbose_name='Alarm')
    # severity = tables.Column(accessor=tables.A('alarm.severity'), verbose_name='Severity')
    date = tables.DateTimeColumn(verbose_name='Date/Time')
    event = tables.Column(verbose_name='Event',
                          accessor=tables.A('comment'),
                          orderable=False)

    def render_date(self, value, table):
        return str(parse_datetime(value)).split('+')[0]

    class Meta:
        template_name = 'django_tables2/bootstrap.html'
        sequence = (
            'date',
            'event',
        )
        # attrs = {'class': 'table'}
        row_attrs = {'class': lambda record: history_row_class(record)}
Ejemplo n.º 11
0
class ObjectChangeTable(BaseTable):
    time = tables.DateTimeColumn(linkify=True,
                                 format=settings.SHORT_DATETIME_FORMAT)
    action = ChoiceFieldColumn()
    changed_object_type = tables.Column(verbose_name="Type")
    object_repr = tables.TemplateColumn(template_code=OBJECTCHANGE_OBJECT,
                                        verbose_name="Object")
    request_id = tables.TemplateColumn(template_code=OBJECTCHANGE_REQUEST_ID,
                                       verbose_name="Request ID")

    class Meta(BaseTable.Meta):
        model = ObjectChange
        fields = (
            "time",
            "user_name",
            "action",
            "changed_object_type",
            "object_repr",
            "request_id",
        )
Ejemplo n.º 12
0
class ProcessedMessagesTable(tables.Table):

    message = tables.Column(verbose_name="Message")
    message_type = tables.Column("Type")
    processed_at = tables.DateTimeColumn(verbose_name="Processed at")

    def render_message(self, record):

        serialized_m = json.dumps(record.message)
        #rex = re.compile('\\r|\\n')
        #re.sub(rex,'',aoi)

        return mark_safe('<a href="#" class="show-message-modal">{1} <span class="table-rowid-span">{2}</span><script type="application/json">{0}</script></a>'.\
            format(serialized_m, (record.message)['title'],'- %s'%(record.message)['others'].get('draft_title') if (record.message)['others'].get('draft_title') else ''))

    class Meta:
        model = ProcessedMessages
        fields = ['message', 'message_type', 'processed_at']
        empty_text = "There are no Processed Messages"
        attrs = {'style': 'width: 100%'}
Ejemplo n.º 13
0
class FailedSMSMessagesTable_Admin(tables.Table):

    sms_pickled_data = tables.Column(verbose_name='Message')
    retries = tables.Column(verbose_name="Retries")
    reason = tables.Column(verbose_name="Reason")
    owned_by = tables.Column(verbose_name="Owner")

    def render_sms_pickled_data(self, record):
        return format_html('<span data-tooltip aria-haspopup="true" class="has-tip" data-disable-hover="false"'+
                            'tabindex=1 title="{}">SMS</span> from {} to {}',record.sms_pickled_data[1],\
                            record.sms_pickled_data[0], record.sms_pickled_data[2]
                           )

    created = tables.DateTimeColumn(verbose_name='Failed')

    class Meta:
        model = FailedSMSMessage
        fields = ('sms_pickled_data', 'reason', 'retries', 'owned_by',
                  'created')
        empty_text = "There are no Failed SMS Messages to display"
        attrs = {'style': 'width: 100%'}
Ejemplo n.º 14
0
class ViewTable(tables.Table):
    """
    Table to display the set of views handled in a workflow
    """
    name = tables.Column(verbose_name=_('Name'))
    description_text = tables.Column(empty_values=[],
                                     verbose_name=_('Description'))
    modified = tables.DateTimeColumn(verbose_name=_('Modified'))
    operations = OperationsColumn(
        verbose_name=_('Operations'),
        template_file='table/includes/partial_view_operations.html',
        template_context=lambda record: {'id': record['id']})

    class Meta:
        """
        Select the model and specify fields, sequence and attributes
        """
        model = View
        fields = ('name', 'description_text', 'modified', 'operations')
        sequence = ('name', 'description_text', 'modified', 'operations')
        attrs = {'class': 'table display table-bordered', 'id': 'view-table'}
Ejemplo n.º 15
0
class ReportsTable(tables.Table):
    review = tables.TemplateColumn(
        template_name="patients/_review_btn.html",
        verbose_name="Actions",
        orderable=False,
    )
    diagnosed_date = tables.DateTimeColumn(format='d/M/Y')

    class Meta:
        model = Report
        template_name = "django_tables2/bootstrap4.html"
        fields = (
            "id",
            "diagnosed_date",
            "detected_state",
            "detected_city",
            "age",
            "gender",
            "current_status",
        )
        attrs = {"class": "table table-responsive"}
Ejemplo n.º 16
0
class _Generic(tables.Table):
    '''
    skeleton for the metric table; all the model specific fields will
    be passed by `extra_columns`
    '''

    edit = tables.TemplateColumn(
        '<a style="color:#1abc9c;" class="far fa-edit fa-lg" href="?activity={{record.activity}}&id={{record.id}}"></a>',
        verbose_name='')
    delete = tables.TemplateColumn(
        '<a style="color:#c7254e;" class="far fa-trash-alt fa-lg" href="?activity={{record.activity}}&id={{record.id}}&delete"></a>',
        verbose_name='')
    time_stamp = tables.DateTimeColumn(format='Y-m-d H:i:s')

    class Meta:
        order_by = '-time_stamp'
        exclude = ('user', )
        attrs = {
            'class': 'table table-striped table-hover',
        }
        template_name = 'django_tables2/bootstrap.html'
Ejemplo n.º 17
0
class ObjectChangeTable(BaseTable):
    time = tables.DateTimeColumn(
        linkify=True,
        format=settings.SHORT_DATETIME_FORMAT
    )
    action = ChoiceFieldColumn()
    changed_object_type = ContentTypeColumn(
        verbose_name='Type'
    )
    object_repr = tables.TemplateColumn(
        template_code=OBJECTCHANGE_OBJECT,
        verbose_name='Object'
    )
    request_id = tables.TemplateColumn(
        template_code=OBJECTCHANGE_REQUEST_ID,
        verbose_name='Request ID'
    )

    class Meta(BaseTable.Meta):
        model = ObjectChange
        fields = ('time', 'user_name', 'action', 'changed_object_type', 'object_repr', 'request_id')
Ejemplo n.º 18
0
class CompanyTable(tables.Table):
    id = tables.LinkColumn(viewname='edit_company',
                           args=[A('pk')],
                           verbose_name="편집")
    name = tables.LinkColumn(viewname='classroom_list',
                             args=[A('id')],
                             verbose_name="학교",
                             accessor=NAME)
    field_of = tables.Column(verbose_name="전공", accessor=FIELD)
    term = tables.Column(verbose_name="학기", accessor=TERM)
    date = tables.DateTimeColumn(verbose_name="날짜", format="Y-m-d H:i")
    sheet_name = tables.Column(verbose_name="google sheet name",
                               accessor="sheet_name")

    def __init__(self, *args, **kwargs):
        super(CompanyTable, self).__init__(*args, **kwargs)

    class Meta:
        model = CompanyInfo
        fields = ["id", NAME, FIELD, TERM, DATE, "sheet_name"]
        template = 'django_tables2/bootstrap.html'
Ejemplo n.º 19
0
class PatientsTable(tables.Table):
    detail = tables.TemplateColumn(
        template_name="patients/_show_patient_details_btn.html",
        verbose_name="Details",
        orderable=False,
    )
    diagnosed_date = tables.DateTimeColumn(format='d/M/Y')

    class Meta:
        model = Patient
        template_name = "django_tables2/bootstrap4.html"
        fields = (
            "id",
            "diagnosed_date",
            "detected_state",
            "detected_city",
            "age",
            "gender",
            "current_status",
        )
        attrs = {"class": "table table-responsive"}
        order_by = "-id"
Ejemplo n.º 20
0
class RNASeqStudyTable(tables.Table):
    """
    Table that is displayed in the study list view
    """
    name = tables.LinkColumn("study_detail",
                             args=[A('id')],
                             text=lambda record: record.name,
                             verbose_name="Study Name",
                             order_by="name")
    description = tables.Column(accessor="description",
                                verbose_name="Description",
                                order_by="description")
    phenotypes = tables.Column(accessor="rna_count",
                               verbose_name="#RNASeqs",
                               order_by="rnaseq")
    update_date = tables.DateTimeColumn(accessor="update_date",
                                        verbose_name="Date Added",
                                        order_by="update_date",
                                        format="M/d/Y")

    class Meta:
        attrs = {"class": "striped", "is_rnaseq": True}
Ejemplo n.º 21
0
class ProjectTable(tables.Table):
    title = tables.Column(accessor='title', verbose_name='Title', linkify=True)
    manager = tables.Column(accessor='manager', verbose_name='Manager')
    open_tickets = tables.Column(accessor='open_tickets',
                                 verbose_name='Open Tickets')
    created_on = tables.DateTimeColumn(
        accessor='created_on',
        verbose_name='Created',
        format='m/d/y',
        order_by='-created_on')  # format='M d, Y' for old version

    class Meta:
        model = models.Project
        fields = (
            'title', 'description', 'manager', 'created_on', 'open_tickets'
        )  # including project_tickets__count in this tuple works too, but allows less customization
        sequence = ('title', '...', 'created_on')
        template_name = 'django_tables2/bootstrap4.html'
        attrs = {
            'class': "table table-striped table-bordered table-hover table-sm"
        }
        order_by = 'created_on'
Ejemplo n.º 22
0
class AutoApprovedTable(EditorQueueTable):
    addon_name = tables.Column(verbose_name=_(u'Add-on'), accessor='name')
    # Override empty_values for flags so that they can be displayed even if the
    # model does not have a flags attribute.
    flags = tables.Column(verbose_name=_(u'Flags'),
                          empty_values=(),
                          orderable=False)
    last_human_review = tables.DateTimeColumn(
        verbose_name=_(u'Last Review'),
        accessor='addonapprovalscounter.last_human_review')
    weight = tables.Column(
        verbose_name=_(u'Weight'),
        accessor='_current_version.autoapprovalsummary.weight')

    class Meta(EditorQueueTable.Meta):
        fields = ('addon_name', 'flags', 'last_human_review', 'weight')
        # Exclude base fields EditorQueueTable has that we don't want.
        exclude = (
            'addon_type_id',
            'waiting_time_min',
        )
        orderable = False

    def render_flags(self, record):
        return super(AutoApprovedTable,
                     self).render_flags(record.current_version)

    def render_addon_name(self, record, url=None):
        if url is None:
            url = reverse('editors.review', args=[record.slug])
        return u'<a href="%s">%s <em>%s</em></a>' % (
            url, jinja2.escape(
                record.name), jinja2.escape(record.current_version))

    def render_last_human_review(self, value):
        return naturaltime(value) if value else ''

    render_last_content_review = render_last_human_review
Ejemplo n.º 23
0
class JobResultTable(BaseTable):
    pk = ToggleColumn()
    obj_type = tables.Column(verbose_name="Object Type",
                             accessor="obj_type.name")
    name = tables.Column(linkify=job_creator_link)
    created = tables.DateTimeColumn(linkify=True,
                                    format=settings.SHORT_DATETIME_FORMAT)
    status = tables.TemplateColumn(
        template_code=
        "{% include 'extras/inc/job_label.html' with result=record %}", )
    data = tables.TemplateColumn(
        """
        <label class="label label-success">{{ value.total.success }}</label>
        <label class="label label-info">{{ value.total.info }}</label>
        <label class="label label-warning">{{ value.total.warning }}</label>
        <label class="label label-danger">{{ value.total.failure }}</label>
        """,
        verbose_name="Results",
        orderable=False,
        attrs={"td": {
            "class": "text-nowrap report-stats"
        }},
    )

    class Meta(BaseTable.Meta):
        model = JobResult
        fields = (
            "pk",
            "created",
            "obj_type",
            "name",
            "duration",
            "completed",
            "user",
            "status",
            "data",
        )
        default_columns = ("pk", "created", "name", "user", "status", "data")
Ejemplo n.º 24
0
class JobLogEntryTable(BaseTable):
    created = tables.DateTimeColumn(verbose_name="Time",
                                    format="Y-m-d H:i:s.u")
    grouping = tables.Column()
    log_level = tables.Column(
        verbose_name="Level",
        attrs={"td": {
            "class": "text-nowrap report-stats"
        }},
    )
    log_object = tables.Column(verbose_name="Object", linkify=log_object_link)
    message = tables.Column(attrs={"td": {"class": "rendered-markdown"}}, )

    def render_log_level(self, value):
        log_level = value.lower()
        # The css is label-danger for failure items.
        if log_level == "failure":
            log_level = "danger"

        return format_html('<label class="label label-{}">{}</label>',
                           log_level, value)

    def render_message(self, value):
        return render_markdown(value)

    class Meta(BaseTable.Meta):
        model = JobLogEntry
        fields = ("created", "grouping", "log_level", "log_object", "message")
        default_columns = ("created", "grouping", "log_level", "log_object",
                           "message")
        row_attrs = {
            "class": log_entry_color_css,
            "data-name": lambda record: record.log_level,
        }
        attrs = {
            "class": "table table-hover table-headings",
            "id": "logs",
        }
Ejemplo n.º 25
0
class SuiteTable(LavaTable):
    """
    Details of the test sets or test cases in a test suite
    """

    name = tables.Column()
    test_set = tables.Column(verbose_name="Test Set")
    result = tables.Column()
    measurement = tables.Column()
    units = tables.Column()
    logged = tables.DateTimeColumn()

    def render_name(self, record):
        return mark_safe(
            '<a href="%s">%s</a>' % (record.get_absolute_url(), record.name)
        )

    def render_result(self, record):
        code = record.result_code
        if code == "pass":
            icon = "ok"
        elif code == "fail":
            icon = "remove"
        else:
            icon = "minus"
        return mark_safe(
            '<a href="%s"><span class="glyphicon glyphicon-%s"></span> %s</a>'
            % (record.get_absolute_url(), icon, code)
        )

    def render_test_set(self, record):
        return mark_safe(
            '<a href="%s">%s</a>'
            % (record.test_set.get_absolute_url(), record.test_set.name)
        )

    class Meta(LavaTable.Meta):
        searches = {"name": "contains"}
Ejemplo n.º 26
0
class SubscriptionsTable(tables.Table):
    # if the name of the 'check' column is ever changed, be sure to update the JavaScript in the template where this view
    # is displayed to reflect the new column name
    check = tables.CheckBoxColumn(
        accessor='pk',
        attrs={"th__input": {
            "onclick": "toggle(this)"
        }},
        orderable=False)
    title = tables.Column(accessor='title', verbose_name='Title', linkify=True)
    team = tables.Column(accessor='team', verbose_name='Team', linkify=True)
    project = tables.Column(accessor='project',
                            verbose_name='Project',
                            linkify=True)
    last_updated_on = tables.DateTimeColumn(accessor='last_updated_on',
                                            verbose_name='Updated',
                                            format='m/d/y',
                                            order_by='-last_updated_on')

    # unsub = tables.Column(
    #     accessor='title',
    #     verbose_name='',
    #     linkify=('tracker:unsubscribe_ticket', {'team_slug': tables.A('team__slug'), 'pk': tables.A('pk')}),
    #     orderable=False
    # )

    # def render_unsub(self, value):
    #     return "Unsubscribe"

    class Meta:
        model = models.Ticket
        fields = ('title', 'team', 'project')
        sequence = ('check', '...', 'last_updated_on')
        template_name = 'django_tables2/bootstrap4.html'
        attrs = {
            'class': "table table-striped table-bordered table-hover table-sm"
        }
        order_by = 'team'
Ejemplo n.º 27
0
class EventsTable(tables.Table):
    created_at = tables.DateTimeColumn(format='H:i',
                                       default='n/a',
                                       verbose_name=_('time'))
    get_full_event = tables.Column(_('event'), order_by='amount')
    get_full_name = tables.Column(_('client'),
                                  order_by=("client__account__first_name",
                                            "client__account__last_name"))

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.counter = itertools.count(start=1)

    def render_id(self):
        return f'{next(self.counter)}'

    @staticmethod
    def get_checkbox(value):
        if value:
            value = '<div class="table__check"><span class="icon--check"></span></div>'
        else:
            value = '<div class="table__check table--check-switchedoff"><span class="icon--check"></span></div>'
        return format_html(value)

    def render_event(self, value):
        return self.get_checkbox(value)

    def render_is_deposited(self, value):
        return self.get_checkbox(value)

    def render_is_vip(self, value):
        return self.get_checkbox(value)

    class Meta:
        model = Event
        template_name = "django_tables2/no_bootstrap.html"
        fields = ('created_at', 'get_full_event', 'get_full_name')
Ejemplo n.º 28
0
class DraftStandardMessagesTable(tables.Table):

    title = tables.Column(verbose_name="Title")
    recipients = tables.Column(verbose_name=_("Recipients"))
    last_modified = tables.DateTimeColumn(verbose_name="Last Edited")
    sms_sender = tables.Column(verbose_name="Sender")
    table_model_action = tables.LinkColumn(verbose_name="", \
                                           text=mark_safe('<span class="button small warning">Edit</span>'), \
                                           args=[A('pk')])

    def render_recipients(self, record):
        if record.recipients:
            if record.recipients.count() > 3:
                #return mark_safe('{} <span class="and-more">and more</span>'.format(", ".join(t.first_name for t in record.contacts.all()[0:2])))

                return mark_safe((format_html_join(', ', '<span>{} {}</span>',\
                                         ((t.first_name,t.last_name) for t in record.recipients.all()[0:3])
                                         ))+'<span class="and-more"> and more</span>')

            return format_html_join(', ', '<span>{} {}</span>',\
                                     ((t.first_name,t.last_name) for t in record.recipients.all())
                                    )

    def render_title(self, record):
        if record.title:
            return format_html('<span data-tooltip aria-haspopup="true" class="has-tip" data-disable-hover="false" tabindex=1 title="{}">{}</span>',\
                               record.__str__(),
                               #nltk.sent_tokenize(record.title)[0:5].join(" ")
                               text_2_wordlist(record.title, 3)
                               )

    class Meta:
        model = StandardMessaging
        fields = ('title', 'recipients', 'sms_sender', 'last_modified',
                  'table_model_action')
        empty_text = "There are no Draft Standard Messages to display"
        attrs = {'style': 'width: 100%'}
Ejemplo n.º 29
0
class ReclamationTable(tables.Table):
    etat = TemplateColumn(
        template_name="commandes/includes/reclamation_traitement.html",
        attrs={"td": {
            "class": ""
        }})
    actions = TemplateColumn(
        template_name="commandes/includes/reclamation_actions.html",
        attrs={"td": {
            "class": ""
        }})
    created_at = tables.DateTimeColumn(format='d/m/Y')

    commande = tables.LinkColumn("commandes:commande_view",
                                 text=lambda record: record.commande,
                                 args=[A("commande__id")])

    class Meta:
        model = Reclamations
        sequence = ('id', 'created_at', 'commande', 'type', 'observation',
                    'image', 'etat', 'actions')
        exclude = ['updated_at']
        template_name = "django_tables2/bootstrap.html"
        attrs = {
            "th": {
                "_ordering": {
                    "orderable": "sortable",  # Instead of `orderable`
                    "ascending": "ascend",  # Instead of `asc`
                    "descending": "descend"  # Instead of `desc`
                }
            }
        }

        def render_etat(self, value, record):
            return format_html("<b>{} {}</b>", value,
                               record.reclamationHandler.all)
Ejemplo n.º 30
0
class FailedEmailMessagesTable(tables.Table):

    record_action = tables.LinkColumn(verbose_name="", \
                                       text=mark_safe('<span class="button small">Retry</span>'), \
                                       args=[A('pk')])

    email_pickled_data = tables.Column(verbose_name='Message')
    retries = tables.Column(verbose_name="Retries")
    reason = tables.Column(verbose_name="Reason")

    created = tables.DateTimeColumn(verbose_name='Failed')

    def render_email_pickled_data(self, record):
        return format_html('<span data-tooltip aria-haspopup="true" class="has-tip" data-disable-hover="false"'+
                            'tabindex=1 title="{}">Email</span> from {} to {}',record.email_pickled_data[0][1],\
                            record.email_pickled_data[1], record.sms_pickled_data[0][2]
                           )

    class Meta:
        model = FailedEmailMessage
        fields = ('email_pickled_data', 'reason', 'retries', 'created',
                  'record_action')
        empty_text = "There are no Failed Email Messages to display"
        attrs = {'style': 'width: 100%'}