Example #1
0
from utils.admin import HiddenModelAdmin, iportalen_admin_site, iportalen_superadmin_site
from django.contrib import admin

from .models import Tag

# Register your models here.
iportalen_admin_site.register(Tag, HiddenModelAdmin)
iportalen_superadmin_site.register(Tag)
Example #2
0
from fika_penalty.models import FikaPenalty
from utils.admin import iportalen_admin_site, iportalen_superadmin_site

iportalen_admin_site.register(FikaPenalty)

iportalen_superadmin_site.register(FikaPenalty)
Example #3
0
        Update created-by / modified-by fields.

        The date fields are updated at the model layer, but that's not got
        access to the user.
        """
        # If the object's new update the created_by field.
        if not change:
            obj.created_by = request.user

        # Either way update the updated_by field.
        obj.updated_by = request.user

        # Let the superclass do the final saving.
        return super(QuestionAdmin, self).save_model(request, obj, form, change)

    def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
        if request.user.is_superuser:
            return super(QuestionAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)

        if db_field.name == "topic":
            kwargs["queryset"] = Topic.objects.filter(faq__organisations__in=request.user.get_organisations())
        return super(QuestionAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)

iportalen_admin_site.register(Question, QuestionAdmin)
iportalen_admin_site.register(Topic, TopicAdmin)
iportalen_admin_site.register(FAQ, FAQAdmin)

iportalen_superadmin_site.register(Question)
iportalen_superadmin_site.register(Topic)
iportalen_superadmin_site.register(FAQ)
Example #4
0
from .models import Course, Reward, Evaluation, Period, Year, CourseEvaluationSettings
from utils.admin import HiddenModelAdmin
from utils.admin import iportalen_admin_site, iportalen_superadmin_site
from django.contrib import admin


iportalen_admin_site.register(Year, HiddenModelAdmin)
iportalen_admin_site.register(Course, HiddenModelAdmin)
iportalen_admin_site.register(Reward, HiddenModelAdmin)
iportalen_admin_site.register(Evaluation, HiddenModelAdmin)
iportalen_admin_site.register(Period, HiddenModelAdmin)
iportalen_admin_site.register(CourseEvaluationSettings)

iportalen_superadmin_site.register(Year)
iportalen_superadmin_site.register(Course)
iportalen_superadmin_site.register(Reward)
iportalen_superadmin_site.register(Evaluation)
iportalen_superadmin_site.register(Period)
iportalen_superadmin_site.register(CourseEvaluationSettings)
Example #5
0
from .models import Organisation, OrganisationPost
from utils.admin import HiddenModelAdmin, iportalen_admin_site, iportalen_superadmin_site
from django.contrib import admin


class OrganisationsAdmin(HiddenModelAdmin):
    readonly_fields = ("modified_by",)


class OrganisationsPostAdmin(HiddenModelAdmin):
    readonly_fields = ("modified_by",)

iportalen_admin_site.register(Organisation, OrganisationsAdmin)
iportalen_admin_site.register(OrganisationPost, OrganisationsPostAdmin)

iportalen_superadmin_site.register(Organisation)
iportalen_superadmin_site.register(OrganisationPost)
Example #6
0
from django.contrib import admin
from .models import Continent, Country, School, Liu_Course, Exchange_Course, Travel_Story, City, Feedback
from utils.admin import HiddenModelAdmin, iportalen_admin_site, iportalen_superadmin_site

iportalen_admin_site.register(Continent)
iportalen_admin_site.register(Country)
iportalen_admin_site.register(School)
iportalen_admin_site.register(City)
iportalen_admin_site.register(Liu_Course)
iportalen_admin_site.register(Exchange_Course)
iportalen_admin_site.register(Travel_Story)
iportalen_admin_site.register(Feedback)

iportalen_superadmin_site.register(Continent)
iportalen_superadmin_site.register(Country)
iportalen_superadmin_site.register(School)
iportalen_superadmin_site.register(City)
iportalen_superadmin_site.register(Liu_Course)
iportalen_superadmin_site.register(Exchange_Course)
iportalen_superadmin_site.register(Travel_Story)
iportalen_superadmin_site.register(Feedback)
Example #7
0
class ImageAttachmentInline(admin.TabularInline):
    model = ImageAttachment
    readonly_fields = ('img', 'thumbnail')
    extra = 0


class ImageAttachmentAdmin(admin.ModelAdmin):
    readonly_fields = ('thumbnail', 'modified_by')
    list_display = ('event',)
    list_filter = ('event',)


class EventAdmin(HiddenModelAdmin):
    inlines = [OtherAttachmentInline, ImageAttachmentInline]

iportalen_admin_site.register(ImageAttachment, ImageAttachmentAdmin)
iportalen_admin_site.register(OtherAttachment, OtherAttachmentAdmin)
iportalen_admin_site.register(Event)
iportalen_admin_site.register(EntryAsPreRegistered)
iportalen_admin_site.register(EntryAsReserve)
iportalen_admin_site.register(EntryAsParticipant)


iportalen_superadmin_site.register(ImageAttachment)
iportalen_superadmin_site.register(OtherAttachment)
iportalen_superadmin_site.register(Event)
iportalen_superadmin_site.register(EntryAsPreRegistered)
iportalen_superadmin_site.register(EntryAsReserve)
iportalen_superadmin_site.register(EntryAsParticipant)
Example #8
0
            'date_gdpr_accepted',
        )}),
        ('Permissions', {'fields': ('is_active', 'is_superuser', 'is_staff', 'is_member', 'must_edit')}),
    )

    add_fieldsets = (
        (None, {
            'classes': ('wide',),
            'fields': ('username', 'password1', 'password2', 'is_staff', 'is_superuser')}
         ),
    )

    search_fields = ('username',)
    ordering = ('username',)
    filter_horizontal = ('groups', 'user_permissions',)


iportalen_admin_site.unregister(Group)
iportalen_admin_site.register(Group, CustomGroup)
iportalen_admin_site.register(IUser, IUserAdmin)
iportalen_admin_site.register(MasterProfile)
iportalen_admin_site.register(BachelorProfile)
iportalen_admin_site.register(Permission, CustomPermission)
iportalen_admin_site.register(IpikureSubscriber)

iportalen_superadmin_site.register(IUser)
iportalen_superadmin_site.register(MasterProfile)
iportalen_superadmin_site.register(BachelorProfile)
iportalen_superadmin_site.register(Permission)
iportalen_superadmin_site.register(IpikureSubscriber)
Example #9
0
class ImageAttachmentInline(admin.TabularInline):
    model = ImageAttachment
    readonly_fields = ('img', 'thumbnail')
    extra = 0


class ImageAttachmentAdmin(admin.ModelAdmin):
    readonly_fields = ('thumbnail', 'modified_by')
    list_display = ('event', )
    list_filter = ('event', )


class EventAdmin(HiddenModelAdmin):
    inlines = [OtherAttachmentInline, ImageAttachmentInline]


iportalen_admin_site.register(ImageAttachment, ImageAttachmentAdmin)
iportalen_admin_site.register(OtherAttachment, OtherAttachmentAdmin)
iportalen_admin_site.register(Event)
iportalen_admin_site.register(EntryAsPreRegistered)
iportalen_admin_site.register(EntryAsReserve)
iportalen_admin_site.register(EntryAsParticipant)

iportalen_superadmin_site.register(ImageAttachment)
iportalen_superadmin_site.register(OtherAttachment)
iportalen_superadmin_site.register(Event)
iportalen_superadmin_site.register(EntryAsPreRegistered)
iportalen_superadmin_site.register(EntryAsReserve)
iportalen_superadmin_site.register(EntryAsParticipant)
Example #10
0
class OtherAttachmentAdmin(admin.ModelAdmin):
    readonly_fields = ('file_name', 'modified_by')
    list_display = ('article', 'file_name')
    list_filter = ('article', )


class ImageAttachmentInline(admin.TabularInline):
    model = ImageAttachment
    readonly_fields = ('img', 'thumbnail')
    extra = 0


class ImageAttachmentAdmin(admin.ModelAdmin):
    readonly_fields = ('thumbnail', 'modified_by')
    list_display = ('article', )
    list_filter = ('article', )


class ArticleAdmin(HiddenModelAdmin):
    inlines = [OtherAttachmentInline, ImageAttachmentInline]


iportalen_admin_site.register(ImageAttachment, ImageAttachmentAdmin)
iportalen_admin_site.register(Article, ArticleAdmin)
iportalen_admin_site.register(OtherAttachment, OtherAttachmentAdmin)

iportalen_superadmin_site.register(ImageAttachment)
iportalen_superadmin_site.register(Article)
iportalen_superadmin_site.register(OtherAttachment)
Example #11
0

class OtherAttachmentAdmin(admin.ModelAdmin):
    readonly_fields = ('file_name', 'modified_by')
    list_display = ('article', 'file_name')
    list_filter = ('article',)


class ImageAttachmentInline(admin.TabularInline):
    model = ImageAttachment
    readonly_fields = ('img', 'thumbnail')
    extra = 0


class ImageAttachmentAdmin(admin.ModelAdmin):
    readonly_fields = ('thumbnail', 'modified_by')
    list_display = ('article',)
    list_filter = ('article',)


class ArticleAdmin(HiddenModelAdmin):
    inlines = [OtherAttachmentInline, ImageAttachmentInline]

iportalen_admin_site.register(ImageAttachment, ImageAttachmentAdmin)
iportalen_admin_site.register(Article, ArticleAdmin)
iportalen_admin_site.register(OtherAttachment, OtherAttachmentAdmin)

iportalen_superadmin_site.register(ImageAttachment)
iportalen_superadmin_site.register(Article)
iportalen_superadmin_site.register(OtherAttachment)
Example #12
0
from .models import Course, Reward, Evaluation, Period, Year, CourseEvaluationSettings
from utils.admin import HiddenModelAdmin
from utils.admin import iportalen_admin_site, iportalen_superadmin_site
from django.contrib import admin

iportalen_admin_site.register(Year, HiddenModelAdmin)
iportalen_admin_site.register(Course, HiddenModelAdmin)
iportalen_admin_site.register(Reward, HiddenModelAdmin)
iportalen_admin_site.register(Evaluation, HiddenModelAdmin)
iportalen_admin_site.register(Period, HiddenModelAdmin)
iportalen_admin_site.register(CourseEvaluationSettings)

iportalen_superadmin_site.register(Year)
iportalen_superadmin_site.register(Course)
iportalen_superadmin_site.register(Reward)
iportalen_superadmin_site.register(Evaluation)
iportalen_superadmin_site.register(Period)
iportalen_superadmin_site.register(CourseEvaluationSettings)
Example #13
0
from django.contrib import admin
from .models import Hero
from utils.admin import iportalen_admin_site, iportalen_superadmin_site


class HeroAdmin(admin.ModelAdmin):
    readonly_fields = ('file_name', 'modified_by')

    def save_model(self, request, obj, form, change):
        """
        Update modified-by fields.

        The date fields are updated at the model layer, but that's not got
        access to the user.
        """

        obj.modified_by = request.user

        # Let the superclass do the final saving.
        return super(HeroAdmin, self).save_model(request, obj, form, change)

iportalen_admin_site.register(Hero, HeroAdmin)

iportalen_superadmin_site.register(Hero)
Example #14
0
from . import models
from utils.admin import iportalen_admin_site, iportalen_superadmin_site

iportalen_admin_site.register(models.Groupings)
iportalen_admin_site.register(models.Course)
iportalen_admin_site.register(models.Exam)
iportalen_admin_site.register(models.ExamResult)

iportalen_superadmin_site.register(models.Groupings)
iportalen_superadmin_site.register(models.Course)
iportalen_superadmin_site.register(models.Exam)
iportalen_superadmin_site.register(models.ExamResult)
Example #15
0
from utils.admin import iportalen_admin_site, iportalen_superadmin_site

from .models import Result

iportalen_admin_site.register(Result)

iportalen_superadmin_site.register(Result)
Example #16
0
from django.contrib import admin
from .models import Alumni_Article, Magazine
from utils.admin import HiddenModelAdmin, iportalen_admin_site, iportalen_superadmin_site


iportalen_admin_site.register(Alumni_Article)
iportalen_superadmin_site.register(Alumni_Article)

iportalen_admin_site.register(Magazine)
iportalen_superadmin_site.register(Magazine)
Example #17
0
        }),
    )

    add_fieldsets = ((None, {
        'classes': ('wide', ),
        'fields':
        ('username', 'password1', 'password2', 'is_staff', 'is_superuser')
    }), )

    search_fields = ('username', )
    ordering = ('username', )
    filter_horizontal = (
        'groups',
        'user_permissions',
    )


iportalen_admin_site.unregister(Group)
iportalen_admin_site.register(Group, CustomGroup)
iportalen_admin_site.register(IUser, IUserAdmin)
iportalen_admin_site.register(MasterProfile)
iportalen_admin_site.register(BachelorProfile)
iportalen_admin_site.register(Permission, CustomPermission)
iportalen_admin_site.register(IpikureSubscriber)

iportalen_superadmin_site.register(IUser)
iportalen_superadmin_site.register(MasterProfile)
iportalen_superadmin_site.register(BachelorProfile)
iportalen_superadmin_site.register(Permission)
iportalen_superadmin_site.register(IpikureSubscriber)
Example #18
0
            return mark_safe("<a href=\"{url}\">{text}</a>".format(url=s, text=_("Skicka email till användare")))
        except:
            return _("Ej tillgängligt")
    send_invoice_email.short_description = _("Skicka faktura")
    send_invoice_email.allow_tags = True

    inlines = [
        VariableCostInline,
        FixedCostInline,
    ]

    search_fields = ('ocr',)
    list_filter = ('status', )
    list_display = ('ocr', 'due', 'status')


iportalen_admin_site.register(Bookable, BookableAdmin)
iportalen_admin_site.register(Booking, BookingsAdmin)

iportalen_admin_site.register(Invoice, UserInvoiceAdmin)

iportalen_admin_site.register(VariableCostTemplate)
iportalen_admin_site.register(FixedCostTemplate)


iportalen_superadmin_site.register(Bookable)
iportalen_superadmin_site.register(Booking)
iportalen_superadmin_site.register(Invoice)
iportalen_superadmin_site.register(VariableCostTemplate)
iportalen_superadmin_site.register(FixedCostTemplate)
Example #19
0
    def get_queryset(self, request):
        qs = super(QuestionGroupAdmin, self).get_queryset(request)
        if request.user.is_superuser:
            return qs
        qs = qs.filter((Q(visible_from__lte=timezone.now())
                        & Q(visible_to__gte=timezone.now()))
                       & (Q(organisations__in=request.user.get_organisations())
                          | Q(creator=request.user)))
        return qs

    def get_readonly_fields(self, request, obj=None):
        if obj:
            return self.readonly_fields + ('event', 'question_status')
        return self.readonly_fields

    def has_delete_permission(self, request, obj=None):
        if request.user.is_superuser:
            return True
        return False

    inlines = [QuestionInlineHidden]


iportalen_admin_site.register(models.QuestionGroup, QuestionGroupAdmin)
iportalen_admin_site.register(models.Question, QuestionAdmin)

iportalen_superadmin_site.register(models.QuestionGroup)
iportalen_superadmin_site.register(models.Question)
iportalen_superadmin_site.register(models.Option)
Example #20
0
    def get_queryset(self, request):
        qs = super(QuestionGroupAdmin, self).get_queryset(request)
        if request.user.is_superuser:
            return qs
        qs = qs.filter((
            Q(visible_from__lte=timezone.now()) &
            Q(visible_to__gte=timezone.now())) &
            (Q(organisations__in=request.user.get_organisations()) | Q(creator=request.user)))
        return qs

    def get_readonly_fields(self, request, obj=None):
        if obj:
            return self.readonly_fields + ('event', 'question_status')
        return self.readonly_fields

    def has_delete_permission(self, request, obj=None):
        if request.user.is_superuser:
            return True
        return False

    inlines = [QuestionInlineHidden]


iportalen_admin_site.register(models.QuestionGroup, QuestionGroupAdmin)
iportalen_admin_site.register(models.Question, QuestionAdmin)

iportalen_superadmin_site.register(models.QuestionGroup)
iportalen_superadmin_site.register(models.Question)
iportalen_superadmin_site.register(models.Option)
Example #21
0
from django.contrib import admin

# Register your models here.
from speaker_list.models import SpeakerList
from utils.admin import iportalen_superadmin_site

iportalen_superadmin_site.register(SpeakerList)
Example #22
0
from .models import Organisation, OrganisationPost
from utils.admin import HiddenModelAdmin, iportalen_admin_site, iportalen_superadmin_site
from django.contrib import admin


class OrganisationsAdmin(HiddenModelAdmin):
    readonly_fields = ("modified_by", )


class OrganisationsPostAdmin(HiddenModelAdmin):
    readonly_fields = ("modified_by", )


iportalen_admin_site.register(Organisation, OrganisationsAdmin)
iportalen_admin_site.register(OrganisationPost, OrganisationsPostAdmin)

iportalen_superadmin_site.register(Organisation)
iportalen_superadmin_site.register(OrganisationPost)
Example #23
0
from django.contrib import admin
from .models import Thesis_Article
from utils.admin import HiddenModelAdmin, iportalen_admin_site, iportalen_superadmin_site

iportalen_admin_site.register(Thesis_Article)
iportalen_superadmin_site.register(Thesis_Article)