Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a mixin for success messages #73

Closed
berkerpeksag opened this issue Dec 18, 2018 · 1 comment
Closed

Create a mixin for success messages #73

berkerpeksag opened this issue Dec 18, 2018 · 1 comment

Comments

@berkerpeksag
Copy link
Contributor

Şu pattern'ı neredeyse bütün view'larda kullanıyoruz:

class CreateJobView(CreateView):
    ...
    success_message = 'İlanınız başarıyle eklendi.'

    def form_valid(self, form):
        messages.success(self.request, self.success_message)
        return super(CreateJobView, self).form_valid(form)

Bunu sürekli tekrar etmek yerine bir mixin haline getirebiliriz. Böylece yukarıdaki kodu aşağıdaki gibi kısaltabiliriz:

from pyist.mixins import SuccessMessageMixin

class CreateJobView(SuccessMessageMixin, CreateView):
    ...
    success_message = 'İlanınız başarıyle eklendi.'
@berkerpeksag
Copy link
Contributor Author

PR #74'ü içeri aldım ama cleanup branch'ini kullandığımızdan burayı otomatik olarak kapatmadı.

ulgens pushed a commit that referenced this issue Oct 4, 2020
ulgens pushed a commit that referenced this issue Oct 4, 2020
ulgens pushed a commit that referenced this issue Oct 4, 2020
ulgens pushed a commit that referenced this issue Oct 4, 2020
ulgens pushed a commit that referenced this issue Oct 4, 2020
ulgens pushed a commit that referenced this issue Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant