Exemple #1
0
class MessageManager(ObjectsManager):
    manager_name = u"news_manager"
    manager_verbose_name = u"اخبار"
    filter_form = NewsFilterForm
    actions = [
        AddAction(NewsForm, save_def=save_news),
        EditAction(NewsForm),
        ShowAction(NewsShowForm, height='350'),
        DeleteAction(),
    ]

    def get_all_data(self):
        return News.objects.filter()

    def get_columns(self):
        columns = [
            ManagerColumn('title', u"عنوان", 7),
            ManagerColumn('body', u"متن", 20, True),
            ManagerColumn('created_on', u"تاریخ ایجاد", 3),
            ManagerColumn('publish_date', u"تاریخ انتشار", 3),
        ]
        return columns

    def get_body(self, obj):
        body = obj.body.replace('\r\n', ' ').replace('\n\r', ' ').replace(
            '\r', ' ').replace('\n', ' ')
        if len(body) > 45:
            body = body[:45] + ' ...'
        return body
Exemple #2
0
class ConfirmedInventionManager(ObjectsManager):
    manager_name = u"confirmed_inventions"
    manager_verbose_name = u"مشاهده اختراعات تاییدشده"
    filter_form = InventionForm
    actions = [ShowAction(InventionActionForm)]
    filter_handlers = (
        ('cluster', '', 'cluster_member__cluster'),
        ('title', 'str'),
        ('registration_number', 'this'),
        ('registration_date', 'pdate'),
        ('participation', 'this'),
    )

    def get_all_data(self):
        return Invention.objects.filter()

    def get_columns(self):
        columns = [
            ManagerColumn('title', u"عنوان اختراع", '30'),
            ManagerColumn('registration_number', u"شماره ثبت", '10'),
            ManagerColumn('registration_date', u"تاریخ ثبت", '10'),
            ManagerColumn('participation', u"شماره ثبت", '10'),
            ManagerColumn('cluster_member', u"عضو خوشه", '10'),
            ManagerColumn('cluster', u"خوشه مربوطه", '10', True),
        ]
        return columns

    def get_cluster(self, data):
        return unicode(data.cluster_member.cluster)

    def can_view(self):
        if PermissionController.is_member(self.http_request.user):
            return True
        return False
Exemple #3
0
class ContactManager(ObjectsManager):
    manager_name = u"contact_manager"
    manager_verbose_name = u"تماس ها"
    filter_form = ContactFilterForm
    actions = [
        DeleteAction(),
        ShowAction(ContactShowForm, height='350'),
    ]

    def get_all_data(self):
        return ContactUs.objects.filter()

    def get_columns(self):
        columns = [
            ManagerColumn('title', u"عنوان", 7),
            ManagerColumn('body', u"متن", 20, True),
            ManagerColumn('email', u"پست الکترونیک", 7),
            ManagerColumn('created_on', u"تاریخ ایجاد", 3),
        ]
        return columns

    def get_body(self, obj):
        body = obj.body.replace('\r\n', ' ').replace('\n\r', ' ').replace(
            '\r', ' ').replace('\n', ' ')
        if len(body) > 45:
            body = body[:45] + ' ...'
        return body
class ClusterManager(ObjectsManager):
    manager_name = u"clusters"
    manager_verbose_name = u"مدیریت خوشه ها"
    filter_form = ClusterForm
    actions = [
        ShowAction(ClusterActionForm, height='300'),
        EditClusterAction(),
        ClusterConfirmAction(),
        DeleteAction()
    ]

    filter_handlers = (
        ('name', 'str'),
        ('domains', 'm2m'),
        ('institute', 'str'),
        ('head', 'm2o'),
        ('degree', 'this'),
        ('members', '', 'members__in'),
        ('confirmed', 'null_bool', 'head__is_confirmed'),
    )

    def get_all_data(self):
        return Cluster.objects.filter()

    def get_columns(self):
        columns = [
            ManagerColumn('name', u"نام خوشه", '10'),
            ManagerColumn('domains', u"حوزه فعالیت", '10', True),
            ManagerColumn('institute', u"دانشگاه / موسسه", '10'),
            ManagerColumn('head', u"سر خوشه", '10'),
            ManagerColumn('users', u"اعضا", '11', True, True),
            ManagerColumn('created_on', u"تاریخ ثبت", '10'),
            ManagerColumn('confirm', u"تاییدشده", '10', True),
            ManagerColumn('degree', u"درجه", '10'),
        ]
        return columns

    def get_domains(self, data):
        return u', '.join([unicode(d) for d in data.domains.filter()])

    def get_users(self, data):
        res = u"""<ol>"""
        for item in data.get_members_and_links():
            if item[1]:
                res += u"""<li><a onClick="MyWindow=window.open('%s','جزئیات عضو',width=800,height=600); return false;"href='#' class="jqgrid-a">%s</a></li>""" % (
                    item[1], item[0])
            else:
                res += u"""<li>%s (عدم ثبت نام)</li>""" % (item[0])

        res += u"""</ol>"""
        return res

    def get_confirm(self, data):
        return data.head.is_confirmed

    def can_view(self):
        if PermissionController.is_admin(self.http_request.user):
            return True
        return False
Exemple #5
0
class FeedbackManager(ObjectsManager):
    manager_name = u"feedback_manager"
    manager_verbose_name = u"مشاهده نظرات و پیشنهادات"
    filter_form = FeedbackFilterForm
    actions = [
        DeleteAction(),
        ShowAction(FeedbackShowForm, height='350'),
    ]

    def get_all_data(self):
        return Feedback.objects.filter()

    def get_columns(self):
        columns = [
            ManagerColumn('title', u"عنوان", 7),
            ManagerColumn('body', u"متن", 20, True),
            ManagerColumn('creator', u"ایجادکننده", 3),
            ManagerColumn('created_on', u"تاریخ ایجاد", 3),
            ManagerColumn('feeder', u"پیشنهاددهنده", 3, True, True),
            ManagerColumn('cluster_feeder', u"خوشه پیشنهاددهنده", 5, True,
                          True),
        ]
        return columns

    def get_body(self, obj):
        body = obj.body.replace('\r\n', ' ').replace('\n\r', ' ').replace(
            '\r', ' ').replace('\n', ' ')
        if len(body) > 45:
            body = body[:45] + ' ...'
        return body

    def get_feeder(self, data):
        from cluster.account.account.models import Member

        try:
            link = u"/members/actions/?t=action&n=edit_member&i=%s" % data.creator.member.id
            return u"""<a onClick="MyWindow=window.open('%s','خوشه/فرد',width=800,height=600); return false;"href='#' class="jqgrid-a">%s</a>""" % (
                link, unicode(data.creator.member))
        except Member.DoesNotExist:
            return None

    def get_cluster_feeder(self, data):
        from cluster.account.account.models import Member, Cluster

        try:
            if data.creator.member.cluster:
                link = u"/clusters/actions/?t=action&n=edit_cluster&i=%s" % data.creator.member.cluster.id
                return u"""<a onClick="MyWindow=window.open('%s','خوشه/فرد',width=800,height=600); return false;"href='#' class="jqgrid-a">%s</a>""" % (
                    link, unicode(data.creator.member.cluster))
        except (Member.DoesNotExist, Cluster.DoesNotExist):
            return None
Exemple #6
0
class NoClusterMemberManager(MemberManager):
    manager_name = u"no_cluster_members"
    manager_verbose_name = u"مدیریت  افراد بدون خوشه"
    filter_form = NoClusterMemberActionForm

    actions = [
        ShowAction(MemberActionForm),
        DeleteAction(),
        ConfirmAction('is_confirmed', on_change_event=member_confirm_change)
    ]

    def get_all_data(self):
        return Member.objects.filter(cluster__isnull=True)

    def get_full_name(self, data):
        link = u"/members/actions/?t=action&n=edit_member&i=%s" % data.id
        return u"""<a onClick="MyWindow=window.open('%s','خوشه/فرد',width=800,height=600); return false;"href='#' class="jqgrid-a">%s</a>""" % (
            link, unicode(data.user))

    def get_columns(self):
        columns = [
            ManagerColumn('full_name', u"نام و نام خانوادگی", '200', True,
                          True),
            ManagerColumn('cluster', u"خوشه", '150', True, True),
            ManagerColumn('gender', u"جنسیت", '40'),
            ManagerColumn('national_code', u"کد ملی", '80'),
            ManagerColumn('birth_date', u"تاریخ تولد", '80'),
            ManagerColumn('residence_city', u"شهر محل اقامت", '80'),
            ManagerColumn('mobile', u"تلفن همراه", '70', True, True),
            ManagerColumn('military_status', u"وضعیت نظام وظیفه", '80'),
            ManagerColumn('foundation_of_elites', u"عضویت در بنیاد ملی نخبگان",
                          '80'),
            ManagerColumn('created_on', u"تاریخ ثبت نام", '80'),
            ManagerColumn('is_confirmed', u"تایید شده", '60'),
            ManagerColumn('last_uni', u"آخرین محل تحصیل", '80', True),
            ManagerColumn('last_end_year', u"سال فارغ التحصیلی", '80', True),
            ManagerColumn('last_field', u"رشته تحصیلی", '80', True),
            ManagerColumn('last_orientation', u"گرایش", '80', True),
        ]
        return columns

    filter_handlers = (
        ('first_name', 'str', 'user__first_name'),
        ('last_name', 'str', 'user__last_name'),
        ('national_code', 'this'),
        ('military_status', 'this'),
        ('foundation_of_elites', 'null_bool'),
    )
Exemple #7
0
class LinkManager(ObjectsManager):
    manager_name = u"links_manager"
    manager_verbose_name = u"لینک ها"
    filter_form = LinkFilterForm
    actions = [
        AddAction(LinkForm),
        EditAction(LinkForm),
        ShowAction(LinkShowForm, height='350'),
        DeleteAction(),
    ]

    def get_all_data(self):
        return Link.objects.filter()

    def get_columns(self):
        columns = [
            ManagerColumn('title', u"عنوان", 12),
            ManagerColumn('url', u"لینک", 12),
            ManagerColumn('order', u"ترتیب نمایش", 3),
            ManagerColumn('created_on', u"تاریخ ایجاد", 4),
        ]
        return columns
class SupervisorManager(ObjectsManager):
    manager_name = u"supervisors_management"
    manager_verbose_name = u"ناظران"
    filter_form = SupervisorFilterForm

    actions = [
        AddAction(SupervisorForm),
        EditAction(SupervisorForm),
        ShowAction(SupervisorForm),
        DeleteAction()
    ]

    def get_all_data(self):
        return Supervisor.objects.filter()

    def get_columns(self):
        columns = [
            ManagerColumn('full_name', u"نام و نام خانوادگی", '30', True),
            ManagerColumn('email', u"پست الکترونیک", '10', True),
            ManagerColumn('username', u"نام کاربری", '10', True),
            ManagerColumn('mobile', u"تلفن همراه", '10'),
        ]
        return columns

    def get_full_name(self, data):
        return unicode(data)

    def get_email(self, data):
        return unicode(data.user.email)

    def get_username(self, data):
        return unicode(data.user.username)

    def can_view(self):
        if PermissionController.is_admin(self.http_request.user):
            return True
        return False
Exemple #9
0
class ArbiterManager(ObjectsManager):
    manager_name = u"arbiters_management"
    manager_verbose_name = u"داوران"
    filter_form = ArbiterFilterForm

    actions = [AddAction(ArbiterForm, save_def=arbiter_save), EditAction(AdminEditArbiter), ShowAction(AdminEditArbiter), DeleteAction(),
               ConfirmAction('is_confirmed'), ArbiterInvitationAction()]

    def get_all_data(self):
        return Arbiter.objects.filter(invited=False)

    def get_columns(self):
        columns = [
            ManagerColumn('full_name', u"نام و نام خانوادگی", '30', True),
            ManagerColumn('gender', u"جنسیت", '10'),
            ManagerColumn('national_code', u"کد ملی", '10'),
            ManagerColumn('birth_date', u"تاریخ تولد", '10'),
            ManagerColumn('workplace', u"نام محل کار", '10'),
            # ManagerColumn('field', u"رشته", '10'),
            ManagerColumn('domains', u"حوزه های مورد علاقه", '30', True),
            ManagerColumn('created_on', u"تاریخ ثبت نام", '10'),
            ManagerColumn('is_confirmed', u"تایید شده", '10'),
        ]
        return columns

    def get_full_name(self, data):
        return unicode(data)

    def get_domains(self, data):
        return u', '.join([unicode(d) for d in data.interested_domain.filter()])

    def can_view(self):
        if PermissionController.is_admin(self.http_request.user):
            return True
        return False